Add OpenAPI endpoint at /openapi with Swagger documentation

This commit is contained in:
2026-05-18 21:43:06 +02:00
parent c0d1aaa4d1
commit 1d77ae491c
4 changed files with 62 additions and 53 deletions
+12 -6
View File
@@ -87,12 +87,12 @@ type swaggerInfo struct {
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = swaggerInfo{
Version: "",
Host: "",
BasePath: "",
Schemes: []string{},
Title: "",
Description: "",
Version: "1.0",
Host: "localhost:8080",
BasePath: "/",
Schemes: []string{"http", "https"},
Title: "MusicServer API",
Description: "API for the MusicServer application",
}
type s struct{}
@@ -129,3 +129,9 @@ func (s *s) ReadDoc() string {
func init() {
swag.Register("swagger", &s{})
}
// GetSwaggerJSON returns the swagger JSON
func GetSwaggerJSON() string {
s := &s{}
return s.ReadDoc()
}