Commit 8dd756ca authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

Merge branch 'remove-gin-swagger' into 'master'

Remove gin swagger

See merge request !28
parents 6a5379c9 70a6e49a
......@@ -29,7 +29,13 @@ build:
script:
- go mod tidy
- go install github.com/swaggo/swag/cmd/swag
- ${GOPATH}/bin/swag init -p pascalcase -g "start.go" -o "./doc/api/"
- ${GOPATH}/bin/swag init --propertyStrategy pascalcase
--generalInfo "start.go"
--output "./doc/api/"
--parseDependency
--parseInternal
--parseVendor
--parseDepth 2
- go build
artifacts:
paths:
......
FROM golang:1.13-buster AS builder
FROM golang:1.15.7-buster AS builder
RUN mkdir /build
WORKDIR /build
ADD . /build
# Make use of layer caching
ADD go.* ./
RUN go mod download
RUN go install github.com/swaggo/swag/cmd/swag
RUN swag init -p pascalcase -g "start.go" -o "./doc/api/"
ADD . .
RUN swag init --propertyStrategy pascalcase \
--generalInfo "start.go" \
--output "./doc/api/" \
--parseDependency \
--parseInternal \
--parseVendor \
--parseDepth 2
RUN go build -o villasweb-backend
FROM debian:buster
......
......@@ -19,7 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
package docs
package api
import "git.rwth-aachen.de/acs/public/villas/web-backend-go/database"
......
......@@ -10,19 +10,20 @@ require (
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/google/uuid v1.1.2
github.com/jinzhu/gorm v1.9.11
github.com/kr/pretty v0.2.1 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/lib/pq v1.1.1
github.com/nsf/jsondiff v0.0.0-20190712045011-8443391ee9b6
github.com/prometheus/client_golang v1.2.1
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271
github.com/stretchr/testify v1.4.0
github.com/swaggo/gin-swagger v1.2.0
github.com/swaggo/swag v1.6.3
github.com/stretchr/testify v1.6.1
github.com/swaggo/swag v1.7.0
github.com/urfave/cli v1.22.5 // indirect
github.com/zpatrick/go-config v0.0.0-20191104215613-50bc2709703f
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
gopkg.in/go-playground/validator.v9 v9.30.0
gopkg.in/ini.v1 v1.51.0 // indirect
)
go 1.13
go 1.15
This diff is collapsed.
......@@ -22,9 +22,10 @@
package component_configuration
import (
"git.rwth-aachen.de/acs/public/villas/web-backend-go/helper"
"net/http"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/helper"
"github.com/gin-gonic/gin"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/database"
......@@ -44,10 +45,10 @@ func RegisterComponentConfigurationEndpoints(r *gin.RouterGroup) {
// @ID getConfigs
// @Produce json
// @Tags component-configurations
// @Success 200 {object} docs.ResponseConfigs "Component configurations which belong to scenario"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseConfigs "Component configurations which belong to scenario"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param scenarioID query int true "Scenario ID"
// @Router /configs [get]
// @Security Bearer
......@@ -73,11 +74,11 @@ func getConfigs(c *gin.Context) {
// @Accept json
// @Produce json
// @Tags component-configurations
// @Success 200 {object} docs.ResponseConfig "Component configuration that was added"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseConfig "Component configuration that was added"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param inputConfig body component_configuration.addConfigRequest true "component configuration to be added incl. IDs of scenario and IC"
// @Router /configs [post]
// @Security Bearer
......@@ -120,11 +121,11 @@ func addConfig(c *gin.Context) {
// @Tags component-configurations
// @Accept json
// @Produce json
// @Success 200 {object} docs.ResponseConfig "Component configuration that was added"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseConfig "Component configuration that was added"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param inputConfig body component_configuration.updateConfigRequest true "component configuration to be updated"
// @Param configID path int true "Config ID"
// @Router /configs/{configID} [put]
......@@ -165,11 +166,11 @@ func updateConfig(c *gin.Context) {
// @ID getConfig
// @Tags component-configurations
// @Produce json
// @Success 200 {object} docs.ResponseConfig "component configuration that was requested"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseConfig "component configuration that was requested"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param configID path int true "Config ID"
// @Router /configs/{configID} [get]
// @Security Bearer
......@@ -188,11 +189,11 @@ func getConfig(c *gin.Context) {
// @ID deleteConfig
// @Tags component-configurations
// @Produce json
// @Success 200 {object} docs.ResponseConfig "component configuration that was deleted"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseConfig "component configuration that was deleted"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param configID path int true "Config ID"
// @Router /configs/{configID} [delete]
// @Security Bearer
......
......@@ -22,9 +22,10 @@
package dashboard
import (
"git.rwth-aachen.de/acs/public/villas/web-backend-go/helper"
"net/http"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/helper"
"github.com/gin-gonic/gin"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/database"
......@@ -45,10 +46,10 @@ func RegisterDashboardEndpoints(r *gin.RouterGroup) {
// @ID getDashboards
// @Produce json
// @Tags dashboards
// @Success 200 {object} docs.ResponseDashboards "Dashboards which belong to scenario"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseDashboards "Dashboards which belong to scenario"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param scenarioID query int true "Scenario ID"
// @Router /dashboards [get]
// @Security Bearer
......@@ -74,11 +75,11 @@ func getDashboards(c *gin.Context) {
// @Accept json
// @Produce json
// @Tags dashboards
// @Success 200 {object} docs.ResponseDashboard "Dashboard that was added"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseDashboard "Dashboard that was added"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param inputDab body dashboard.addDashboardRequest true "Dashboard to be added incl. ID of Scenario"
// @Router /dashboards [post]
// @Security Bearer
......@@ -120,11 +121,11 @@ func addDashboard(c *gin.Context) {
// @Tags dashboards
// @Accept json
// @Produce json
// @Success 200 {object} docs.ResponseDashboard "Dashboard that was updated"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseDashboard "Dashboard that was updated"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param inputDab body dashboard.updateDashboardRequest true "Dashboard to be updated"
// @Param dashboardID path int true "Dashboard ID"
// @Router /dashboards/{dashboardID} [put]
......@@ -163,11 +164,11 @@ func updateDashboard(c *gin.Context) {
// @ID getDashboard
// @Tags dashboards
// @Produce json
// @Success 200 {object} docs.ResponseDashboard "Dashboard that was requested"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseDashboard "Dashboard that was requested"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param dashboardID path int true "Dashboard ID"
// @Router /dashboards/{dashboardID} [get]
// @Security Bearer
......@@ -186,11 +187,11 @@ func getDashboard(c *gin.Context) {
// @ID deleteDashboard
// @Tags dashboards
// @Produce json
// @Success 200 {object} docs.ResponseDashboard "Dashboard that was deleted"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseDashboard "Dashboard that was deleted"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param dashboardID path int true "Dashboard ID"
// @Router /dashboards/{dashboardID} [delete]
// @Security Bearer
......
......@@ -23,10 +23,11 @@ package file
import (
"fmt"
"net/http"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/helper"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/scenario"
"github.com/gin-gonic/gin"
"net/http"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/database"
)
......@@ -44,10 +45,10 @@ func RegisterFileEndpoints(r *gin.RouterGroup) {
// @ID getFiles
// @Tags files
// @Produce json
// @Success 200 {object} docs.ResponseFiles "Files which belong to scenario"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseFiles "Files which belong to scenario"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param scenarioID query int true "Scenario ID"
// @Router /files [get]
// @Security Bearer
......@@ -80,11 +81,11 @@ func getFiles(c *gin.Context) {
// @Accept model/x-cim
// @Accept model/x-cim.zip
// @Accept multipart/form-data
// @Success 200 {object} docs.ResponseFile "File that was added"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseFile "File that was added"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param inputFile formData file true "File to be uploaded"
// @Param scenarioID query int true "ID of scenario to which file shall be added"
// @Router /files [post]
......@@ -130,11 +131,11 @@ func addFile(c *gin.Context) {
// @Produce gif
// @Produce model/x-cim
// @Produce model/x-cim.zip
// @Success 200 {object} docs.ResponseFile "File that was requested"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseFile "File that was requested"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param fileID path int true "ID of the file to download"
// @Router /files/{fileID} [get]
// @Security Bearer
......@@ -162,11 +163,11 @@ func getFile(c *gin.Context) {
// @Accept model/x-cim
// @Accept model/x-cim.zip
// @Accept multipart/form-data
// @Success 200 {object} docs.ResponseFile "File that was updated"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseFile "File that was updated"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param inputFile formData file true "File to be uploaded"
// @Param fileID path int true "ID of the file to update"
// @Router /files/{fileID} [put]
......@@ -197,11 +198,11 @@ func updateFile(c *gin.Context) {
// @ID deleteFile
// @Tags files
// @Produce json
// @Success 200 {object} docs.ResponseFile "File that was deleted"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseFile "File that was deleted"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param fileID path int true "ID of the file to update"
// @Router /files/{fileID} [delete]
// @Security Bearer
......
......@@ -43,8 +43,8 @@ func RegisterHealthzEndpoint(r *gin.RouterGroup) {
// @ID getHealth
// @Produce json
// @Tags healthz
// @Success 200 "Backend is healthy, database and AMQP broker connections are alive"
// @Failure 500 {object} docs.ResponseError "Backend is NOT healthy"
// @Success 204 string string "Backend is healthy, database and AMQP broker connections are alive"
// @Failure 500 {object} api.ResponseError "Backend is NOT healthy"
// @Router /healthz [get]
func getHealth(c *gin.Context) {
......@@ -80,5 +80,6 @@ func getHealth(c *gin.Context) {
}
}
c.JSON(http.StatusOK, gin.H{})
// Send a 204 reponse
c.Writer.WriteHeader(http.StatusNoContent)
}
......@@ -85,5 +85,5 @@ func TestHealthz(t *testing.T) {
// test healthz endpoint for connected DB and AMQP client
code, resp, err = helper.TestEndpoint(router, "", "healthz", http.MethodGet, nil)
assert.NoError(t, err)
assert.Equalf(t, 200, code, "Response body: \n%v\n", resp)
assert.Equalf(t, 204, code, "Response body: \n%v\n", resp)
}
......@@ -22,11 +22,12 @@
package infrastructure_component
import (
"log"
"net/http"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/database"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/helper"
"github.com/gin-gonic/gin"
"log"
"net/http"
)
func RegisterICEndpoints(r *gin.RouterGroup) {
......@@ -47,10 +48,10 @@ func RegisterAMQPEndpoint(r *gin.RouterGroup) {
// @ID getICs
// @Tags infrastructure-components
// @Produce json
// @Success 200 {object} docs.ResponseICs "ICs requested"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseICs "ICs requested"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Router /ic [get]
// @Security Bearer
func getICs(c *gin.Context) {
......@@ -72,11 +73,11 @@ func getICs(c *gin.Context) {
// @Accept json
// @Produce json
// @Tags infrastructure-components
// @Success 200 {object} docs.ResponseIC "Infrastructure Component that was added"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseIC "Infrastructure Component that was added"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param inputIC body infrastructure_component.AddICRequest true "Infrastructure Component to be added"
// @Router /ic [post]
// @Security Bearer
......@@ -125,11 +126,11 @@ func addIC(c *gin.Context) {
// @Tags infrastructure-components
// @Accept json
// @Produce json
// @Success 200 {object} docs.ResponseIC "Infrastructure Component that was updated"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseIC "Infrastructure Component that was updated"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param inputIC body infrastructure_component.UpdateICRequest true "InfrastructureComponent to be updated"
// @Param ICID path int true "InfrastructureComponent ID"
// @Router /ic/{ICID} [put]
......@@ -175,11 +176,11 @@ func updateIC(c *gin.Context) {
// @ID getIC
// @Produce json
// @Tags infrastructure-components
// @Success 200 {object} docs.ResponseIC "Infrastructure Component that was requested"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseIC "Infrastructure Component that was requested"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param ICID path int true "Infrastructure Component ID"
// @Router /ic/{ICID} [get]
// @Security Bearer
......@@ -198,11 +199,11 @@ func getIC(c *gin.Context) {
// @ID deleteIC
// @Tags infrastructure-components
// @Produce json
// @Success 200 {object} docs.ResponseIC "Infrastructure Component that was deleted"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseIC "Infrastructure Component that was deleted"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param ICID path int true "Infrastructure Component ID"
// @Router /ic/{ICID} [delete]
// @Security Bearer
......@@ -230,11 +231,11 @@ func deleteIC(c *gin.Context) {
// @ID getConfigsOfIC
// @Tags infrastructure-components
// @Produce json
// @Success 200 {object} docs.ResponseConfigs "Configs requested by user"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseConfigs "Configs requested by user"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param ICID path int true "Infrastructure Component ID"
// @Router /ic/{ICID}/configs [get]
// @Security Bearer
......@@ -259,11 +260,11 @@ func getConfigsOfIC(c *gin.Context) {
// @Tags infrastructure-components
// @Produce json
// @Param inputAction query string true "Action for IC"
// @Success 200 {object} docs.ResponseError "Action sent successfully"
// @Failure 400 {object} docs.ResponseError "Bad request"
// @Failure 404 {object} docs.ResponseError "Not found"
// @Failure 422 {object} docs.ResponseError "Unprocessable entity"
// @Failure 500 {object} docs.ResponseError "Internal server error"
// @Success 200 {object} api.ResponseError "Action sent successfully"
// @Failure 400 {object} api.ResponseError "Bad request"
// @Failure 404 {object} api.ResponseError "Not found"
// @Failure 422 {object} api.ResponseError "Unprocessable entity"
// @Failure 500 {object} api.ResponseError "Internal server error"
// @Param ICID path int true "InfrastructureComponent ID"
// @Router /ic/{ICID}/action [post]
// @Security Bearer
......
......@@ -78,7 +78,7 @@ var (
// @ID getMetrics
// @Produce json
// @Tags metrics
// @Success 200 "Returns Prometheus metrics"
// @Success 200 {string} string "Returns Prometheus metrics"
// @Router /metrics [get]
func RegisterMetricsEndpoint(rg *gin.RouterGroup) {
// use prometheus metrics exporter middleware.
......
/** Healthz package, endpoints.
*
* @author Sonja Happ <sonja.happ@eonerc.rwth-aachen.de>
* @copyright 2014-2019, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLASweb-backend-go
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
package openapi
import (
_ "git.rwth-aachen.de/acs/public/villas/web-backend-go/doc/api" // doc/api folder is used by Swag CLI, you have to import it
"git.rwth-aachen.de/acs/public/villas/web-backend-go/helper"
"github.com/gin-gonic/gin"
"github.com/swaggo/swag"
)
func RegisterOpenAPIEndpoint(r *gin.RouterGroup) {
r.GET("", getOpenAPI)
}
// getOpenAPI godoc
// @Summary Get OpenAPI 2.0 spec of API
// @ID getOpenAPI
// @Produce json
// @Tags openapi
// @Success 200 string string "A OpenAPI 2.0 specification of the API"
// @Router /openapi [get]
func getOpenAPI(c *gin.Context) {
doc, err := swag.ReadDoc()
if err != nil {
helper.InternalServerError(c, err.Error())
}
c.Header("Content-Type", "application/json")
c.String(200, doc)
}
......@@ -42,14 +42,13 @@ import (
"git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/healthz"
infrastructure_component "git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/infrastructure-component"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/metrics"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/openapi"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/result"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/scenario"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/signal"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/user"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/widget"
"github.com/gin-gonic/gin"
ginSwagger "github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
"github.com/zpatrick/go-config"
)
......@@ -80,6 +79,7 @@ func RegisterEndpoints(router *gin.Engine, api *gin.RouterGroup) {
healthz.RegisterHealthzEndpoint(api.Group("/healthz"))
metrics.RegisterMetricsEndpoint(api.Group("/metrics"))
openapi.RegisterOpenAPIEndpoint(api.Group("/openapi"))
// All endpoints (except for /healthz and /metrics) require authentication except when someone wants to
// login (POST /authenticate)
user.RegisterAuthenticate(api.Group("/authenticate"))
......@@ -96,8 +96,6 @@ func RegisterEndpoints(router *gin.Engine, api *gin.RouterGroup) {
infrastructure_component.RegisterICEndpoints(api.Group("/ic"))
result.RegisterResultEndpoints(api.Group("/results"))
router.GET("swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
metrics.InitCounters()
}
......
......@@ -24,12 +24,13 @@ package result
import (
"fmt"
"net/http"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/database"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/helper"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/file"
"git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/scenario"
"github.com/gin-gonic/gin"
"net/http"
)
f