mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-12-25 04:49:05 +01:00
Reconfigure Swagger integration. Regenerate API docs
This commit is contained in:
parent
8e90c954ff
commit
f1941b5e67
@ -5,9 +5,9 @@
|
||||
"title": "ClusterCockpit REST API",
|
||||
"termsOfService": "TODO",
|
||||
"contact": {
|
||||
"name": "HPC-Support",
|
||||
"name": "ClusterCockpit project",
|
||||
"url": "TODO",
|
||||
"email": "hpc-support@fau.de"
|
||||
"email": "support@clustercockpit.org"
|
||||
},
|
||||
"license": {
|
||||
"name": "MIT License",
|
||||
@ -15,7 +15,7 @@
|
||||
},
|
||||
"version": "0.1.0"
|
||||
},
|
||||
"host": "clustercockpit.localhost:8082",
|
||||
"host": "localhost:8080",
|
||||
"basePath": "/api",
|
||||
"paths": {
|
||||
"/jobs/": {
|
||||
@ -385,23 +385,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"api.TagJobApiRequest": {
|
||||
"description": "Request to tag a job.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"description": "Error Message",
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"description": "Statustext of Errorcode",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.Job": {
|
||||
"type": "object",
|
||||
"properties": {
|
@ -10,18 +10,6 @@ definitions:
|
||||
description: Statustext of Errorcode
|
||||
type: string
|
||||
type: object
|
||||
api.TagJobApiRequest:
|
||||
description: Request to tag a job boii
|
||||
items:
|
||||
properties:
|
||||
name:
|
||||
description: Tag Name
|
||||
type: string
|
||||
type:
|
||||
description: Tag Type
|
||||
type: string
|
||||
type: object
|
||||
type: array
|
||||
api.StartJobApiResponse:
|
||||
description: Successful job start response with database id of new job.
|
||||
properties:
|
||||
@ -125,11 +113,11 @@ definitions:
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
host: clustercockpit.localhost:8082
|
||||
host: localhost:8080
|
||||
info:
|
||||
contact:
|
||||
email: hpc-support@fau.de
|
||||
name: HPC-Support
|
||||
email: support@clustercockpit.org
|
||||
name: ClusterCockpit project
|
||||
url: TODO
|
||||
description: Array of tag-objects for request payload
|
||||
license:
|
@ -40,12 +40,11 @@ import (
|
||||
"github.com/google/gops/agent"
|
||||
"github.com/gorilla/handlers"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/swaggo/http-swagger"
|
||||
httpSwagger "github.com/swaggo/http-swagger"
|
||||
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
_ "github.com/santhosh-tekuri/jsonschema/v5/httploader"
|
||||
_ "github.com/ClusterCockpit/cc-backend/docs"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -264,7 +263,9 @@ func main() {
|
||||
|
||||
if flagDev {
|
||||
r.Handle("/playground", playground.Handler("GraphQL playground", "/query"))
|
||||
secured.PathPrefix("/docs").Handler(httpSwagger.WrapHandler)
|
||||
// secured.PathPrefix("/docs").Handler(httpSwagger.WrapHandler)
|
||||
r.PathPrefix("/swagger/").Handler(httpSwagger.Handler(
|
||||
httpSwagger.URL("http://localhost:8080/swagger/doc.json"))).Methods(http.MethodGet)
|
||||
}
|
||||
secured.Handle("/query", graphQLEndpoint)
|
||||
|
||||
|
1
go.mod
1
go.mod
@ -27,6 +27,7 @@ require (
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
|
||||
github.com/deepmap/oapi-codegen v1.11.0 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.3 // indirect
|
||||
github.com/ghodss/yaml v1.0.0 // indirect
|
||||
github.com/go-asn1-ber/asn1-ber v1.5.4 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.5 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.0 // indirect
|
||||
|
1
go.sum
1
go.sum
@ -35,6 +35,7 @@ github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBd
|
||||
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
|
||||
github.com/getkin/kin-openapi v0.94.0/go.mod h1:LWZfzOd7PRy8GJ1dJ6mCU6tNdSfOwRac1BUPam4aw6Q=
|
||||
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U=
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Package docs GENERATED BY SWAG; DO NOT EDIT
|
||||
// This file was generated by swaggo/swag at
|
||||
// 2022-09-15 11:56:55.737680755 +0200 CEST m=+0.135609460
|
||||
package docs
|
||||
// Package api GENERATED BY SWAG; DO NOT EDIT
|
||||
// This file was generated by swaggo/swag
|
||||
package api
|
||||
|
||||
import "github.com/swaggo/swag"
|
||||
|
||||
@ -13,9 +12,9 @@ const docTemplate = `{
|
||||
"title": "{{.Title}}",
|
||||
"termsOfService": "TODO",
|
||||
"contact": {
|
||||
"name": "HPC-Support",
|
||||
"name": "ClusterCockpit project",
|
||||
"url": "TODO",
|
||||
"email": "hpc-support@fau.de"
|
||||
"email": "support@clustercockpit.org"
|
||||
},
|
||||
"license": {
|
||||
"name": "MIT License",
|
||||
@ -393,23 +392,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"api.TagJobApiRequest": {
|
||||
"description": "Request to tag a job.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"error": {
|
||||
"description": "Error Message",
|
||||
"type": "string"
|
||||
},
|
||||
"status": {
|
||||
"description": "Statustext of Errorcode",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"schema.Job": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@ -538,11 +520,11 @@ const docTemplate = `{
|
||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||
var SwaggerInfo = &swag.Spec{
|
||||
Version: "0.1.0",
|
||||
Host: "clustercockpit.localhost:8082",
|
||||
Host: "localhost:8080",
|
||||
BasePath: "/api",
|
||||
Schemes: []string{},
|
||||
Title: "ClusterCockpit REST API",
|
||||
Description: "API for batch job control.",
|
||||
Description: "Array of tag-objects for request payload",
|
||||
InfoInstanceName: "swagger",
|
||||
SwaggerTemplate: docTemplate,
|
||||
}
|
@ -35,12 +35,12 @@ import (
|
||||
// @version 0.1.0
|
||||
// @description API for batch job control.
|
||||
// @termsOfService TODO
|
||||
// @contact.name HPC-Support
|
||||
// @contact.name ClusterCockpit project
|
||||
// @contact.url TODO
|
||||
// @contact.email hpc-support@fau.de
|
||||
// @contact.email support@clustercockpit.org
|
||||
// @license.name MIT License
|
||||
// @license.url https://opensource.org/licenses/MIT
|
||||
// @host clustercockpit.localhost:8082
|
||||
// @host localhost:8080
|
||||
// @BasePath /api
|
||||
// @securityDefinitions.apikey ApiKeyAuth
|
||||
// @in header
|
||||
@ -136,8 +136,6 @@ func decode(r io.Reader, val interface{}) error {
|
||||
return dec.Decode(val)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// getJobs godoc
|
||||
// @Summary List all jobs
|
||||
// @Description Get a list of all jobs. Filters can be applied using query parameters.
|
||||
@ -627,7 +625,6 @@ func (api *RestApi) stopJobByRequest(rw http.ResponseWriter, r *http.Request) {
|
||||
// rw.Write([]byte(`{ "status": "OK" }`))
|
||||
// }
|
||||
|
||||
|
||||
func (api *RestApi) getJobMetrics(rw http.ResponseWriter, r *http.Request) {
|
||||
id := mux.Vars(r)["id"]
|
||||
metrics := r.URL.Query()["metric"]
|
||||
@ -670,9 +667,6 @@ func (api *RestApi) getJobMetrics(rw http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
func (api *RestApi) getJWT(rw http.ResponseWriter, r *http.Request) {
|
||||
rw.Header().Set("Content-Type", "text/plain")
|
||||
username := r.FormValue("username")
|
||||
@ -787,10 +781,6 @@ func (api *RestApi) updateConfiguration(rw http.ResponseWriter, r *http.Request)
|
||||
rw.Write([]byte("success"))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
func (api *RestApi) putMachineState(rw http.ResponseWriter, r *http.Request) {
|
||||
if api.MachineStateDir == "" {
|
||||
http.Error(rw, "not enabled", http.StatusNotFound)
|
||||
|
Loading…
Reference in New Issue
Block a user