diff --git a/api/source-score.yaml b/api/source-score.yaml index bbca590..23e8068 100644 --- a/api/source-score.yaml +++ b/api/source-score.yaml @@ -522,6 +522,7 @@ components: required: true schema: type: string + default: swagger-ui description: Client identifier for authentication schemas: diff --git a/pkg/handlers/swagger-ui.html b/pkg/handlers/swagger-ui.html new file mode 100644 index 0000000..0f8553a --- /dev/null +++ b/pkg/handlers/swagger-ui.html @@ -0,0 +1,147 @@ + + + + + + Source Score API Documentation + + + + + +
+ + + + + + + + \ No newline at end of file diff --git a/pkg/handlers/swagger.go b/pkg/handlers/swagger.go index 45e0f8c..30b40b6 100644 --- a/pkg/handlers/swagger.go +++ b/pkg/handlers/swagger.go @@ -1,6 +1,7 @@ package handlers import ( + _ "embed" "net/http" "github.com/gin-gonic/gin" @@ -10,6 +11,11 @@ type SwaggerHandler struct { specFile []byte } +var ( + //go:embed "swagger-ui.html" + html string +) + func NewSwaggerHandler(specFile []byte) *SwaggerHandler { return &SwaggerHandler{ specFile: specFile, @@ -21,54 +27,5 @@ func (h *SwaggerHandler) ServeSpec(c *gin.Context) { } func (h *SwaggerHandler) ServeUI(c *gin.Context) { - html := ` - - - - Source Score API Documentation - - - - -
- - - - -` c.Data(http.StatusOK, "text/html; charset=utf-8", []byte(html)) }