Files
query-orchestration/internal/server/api/swagger.go
T
Michael McGuinness 555b6d420b Merged in feature/docresult (pull request #105)
Document Result Endpoint

* testing

* cleantesting

* progress

* query

* lint

* readme

* dockerclient

* api

* passtest

* tests

* test
2025-03-17 18:14:15 +00:00

36 lines
719 B
Go

package api
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
}