Files
query-orchestration/internal/server/service/swagger.go
T
Michael McGuinness 65c0df50e6 Merged in feature/testing (pull request #102)
Minimum Testing Threshold

* mintests
2025-03-12 12:36:44 +00:00

36 lines
723 B
Go

package service
import (
"net/http"
"github.com/getkin/kin-openapi/openapi3"
"github.com/labstack/echo/v4"
"gopkg.in/yaml.v3"
)
func getSwaggerJSONFunc(opnapi *openapi3.T) (func(echo.Context) error, error) {
spec, err := opnapi.MarshalJSON()
if err != nil {
return nil, err
}
return func(c echo.Context) error {
return c.Blob(http.StatusOK, "application/json", spec)
}, nil
}
func getSwaggerYAMLFunc(opnapi *openapi3.T) (func(echo.Context) error, error) {
spec, err := opnapi.MarshalYAML()
if err != nil {
return nil, err
}
yaml, err := yaml.Marshal(spec)
if err != nil {
return nil, err
}
return func(c echo.Context) error {
return c.Blob(http.StatusOK, "application/yaml", yaml)
}, nil
}