go.mod: Update oapi-codegen and kin-openapi

This commit is contained in:
sanne 2022-01-11 19:00:14 +01:00 committed by Sanne Raymaekers
parent add17bba45
commit a83cf95d5b
156 changed files with 29663 additions and 2248 deletions

View file

@ -1,6 +1,6 @@
// Package api provides primitives to interact the openapi HTTP API.
// Package api provides primitives to interact with the openapi HTTP API.
//
// Code generated by github.com/deepmap/oapi-codegen DO NOT EDIT.
// Code generated by github.com/deepmap/oapi-codegen version v1.8.2 DO NOT EDIT.
package api
import (
@ -9,17 +9,24 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
"net/url"
"path"
"strings"
"github.com/deepmap/oapi-codegen/pkg/runtime"
"github.com/getkin/kin-openapi/openapi3"
"github.com/labstack/echo/v4"
"net/http"
"strings"
)
const (
BearerScopes = "Bearer.Scopes"
)
// Error defines model for Error.
type Error struct {
// Embedded struct due to allOf(#/components/schemas/ObjectReference)
ObjectReference
ObjectReference `yaml:",inline"`
// Embedded fields due to inline allOf schema
Code string `json:"code"`
@ -32,7 +39,7 @@ type Error struct {
// GetJobResponse defines model for GetJobResponse.
type GetJobResponse struct {
// Embedded struct due to allOf(#/components/schemas/ObjectReference)
ObjectReference
ObjectReference `yaml:",inline"`
// Embedded fields due to inline allOf schema
Canceled bool `json:"canceled"`
}
@ -53,7 +60,7 @@ type RequestJobRequest struct {
// RequestJobResponse defines model for RequestJobResponse.
type RequestJobResponse struct {
// Embedded struct due to allOf(#/components/schemas/ObjectReference)
ObjectReference
ObjectReference `yaml:",inline"`
// Embedded fields due to inline allOf schema
Args *json.RawMessage `json:"args,omitempty"`
ArtifactLocation string `json:"artifact_location"`
@ -65,7 +72,7 @@ type RequestJobResponse struct {
// StatusResponse defines model for StatusResponse.
type StatusResponse struct {
// Embedded struct due to allOf(#/components/schemas/ObjectReference)
ObjectReference
ObjectReference `yaml:",inline"`
// Embedded fields due to inline allOf schema
Status string `json:"status"`
}
@ -84,10 +91,10 @@ type RequestJobJSONBody RequestJobRequest
// UpdateJobJSONBody defines parameters for UpdateJob.
type UpdateJobJSONBody UpdateJobRequest
// RequestJobRequestBody defines body for RequestJob for application/json ContentType.
// RequestJobJSONRequestBody defines body for RequestJob for application/json ContentType.
type RequestJobJSONRequestBody RequestJobJSONBody
// UpdateJobRequestBody defines body for UpdateJob for application/json ContentType.
// UpdateJobJSONRequestBody defines body for UpdateJob for application/json ContentType.
type UpdateJobJSONRequestBody UpdateJobJSONBody
// ServerInterface represents all server handlers.
@ -126,12 +133,12 @@ func (w *ServerInterfaceWrapper) GetError(ctx echo.Context) error {
// ------------- Path parameter "id" -------------
var id string
err = runtime.BindStyledParameter("simple", false, "id", ctx.Param("id"), &id)
err = runtime.BindStyledParameterWithLocation("simple", false, "id", runtime.ParamLocationPath, ctx.Param("id"), &id)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter id: %s", err))
}
ctx.Set("Bearer.Scopes", []string{""})
ctx.Set(BearerScopes, []string{""})
// Invoke the callback with all the unmarshalled arguments
err = w.Handler.GetError(ctx, id)
@ -153,7 +160,7 @@ func (w *ServerInterfaceWrapper) GetJob(ctx echo.Context) error {
// ------------- Path parameter "token" -------------
var token string
err = runtime.BindStyledParameter("simple", false, "token", ctx.Param("token"), &token)
err = runtime.BindStyledParameterWithLocation("simple", false, "token", runtime.ParamLocationPath, ctx.Param("token"), &token)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter token: %s", err))
}
@ -169,7 +176,7 @@ func (w *ServerInterfaceWrapper) UpdateJob(ctx echo.Context) error {
// ------------- Path parameter "token" -------------
var token string
err = runtime.BindStyledParameter("simple", false, "token", ctx.Param("token"), &token)
err = runtime.BindStyledParameterWithLocation("simple", false, "token", runtime.ParamLocationPath, ctx.Param("token"), &token)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter token: %s", err))
}
@ -185,7 +192,7 @@ func (w *ServerInterfaceWrapper) UploadJobArtifact(ctx echo.Context) error {
// ------------- Path parameter "token" -------------
var token string
err = runtime.BindStyledParameter("simple", false, "token", ctx.Param("token"), &token)
err = runtime.BindStyledParameterWithLocation("simple", false, "token", runtime.ParamLocationPath, ctx.Param("token"), &token)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter token: %s", err))
}
@ -193,7 +200,7 @@ func (w *ServerInterfaceWrapper) UploadJobArtifact(ctx echo.Context) error {
// ------------- Path parameter "name" -------------
var name string
err = runtime.BindStyledParameter("simple", false, "name", ctx.Param("name"), &name)
err = runtime.BindStyledParameterWithLocation("simple", false, "name", runtime.ParamLocationPath, ctx.Param("name"), &name)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Invalid format for parameter name: %s", err))
}
@ -238,49 +245,55 @@ type EchoRouter interface {
// RegisterHandlers adds each server route to the EchoRouter.
func RegisterHandlers(router EchoRouter, si ServerInterface) {
RegisterHandlersWithBaseURL(router, si, "")
}
// Registers handlers, and prepends BaseURL to the paths, so that the paths
// can be served under a prefix.
func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
wrapper := ServerInterfaceWrapper{
Handler: si,
}
router.GET("/errors/:id", wrapper.GetError)
router.POST("/jobs", wrapper.RequestJob)
router.GET("/jobs/:token", wrapper.GetJob)
router.PATCH("/jobs/:token", wrapper.UpdateJob)
router.PUT("/jobs/:token/artifacts/:name", wrapper.UploadJobArtifact)
router.GET("/openapi", wrapper.GetOpenapi)
router.GET("/status", wrapper.GetStatus)
router.GET(baseURL+"/errors/:id", wrapper.GetError)
router.POST(baseURL+"/jobs", wrapper.RequestJob)
router.GET(baseURL+"/jobs/:token", wrapper.GetJob)
router.PATCH(baseURL+"/jobs/:token", wrapper.UpdateJob)
router.PUT(baseURL+"/jobs/:token/artifacts/:name", wrapper.UploadJobArtifact)
router.GET(baseURL+"/openapi", wrapper.GetOpenapi)
router.GET(baseURL+"/status", wrapper.GetStatus)
}
// Base64 encoded, gzipped, json marshaled Swagger object
var swaggerSpec = []string{
"H4sIAAAAAAAC/9xY32/bNhD+VwhuDxsgW07TvgjYQ9MNRTp0GZIVK5AFwZk6W0wkUiFPdgxD//tAUv4l",
"KXaKxg/NkxWJvB/fffzumCUXuii1QkWWJ0tuRYYF+Mc/jNHGPUCeX0x4cr3kPxuc8IT/FG82xc2O+GJ8",
"h4IucYIGlUBeR0teGl2iIYneoNApul9alMgTbslINeV1xAu0Fqb+W4pWGFmS1Ion/AzE/RxMypw/IDmW",
"uaQFm0vK2FybezSW/VeNRqfiNzY7PY0YPlSQW2YQrFY86rpy8YCzfivT3liard1P/ttDJQ2mPLkOyayX",
"twxvUrpZx6A9Pry+qSP+EemTHl+iLbWy+KIYgxKY43ZuY61zBNXNYLW0P8a2r6TtKvOB9kD4BLL3UqWH",
"cfXo+aVR8NCNLuKX+FChDRj6p250YETWG4Z74VdIwsI+uYQnHIyBRSfAsD8KDg4F9/IFBjP1v4+DqR40",
"vu+sVsNLmH9uSFe76EhOQNBtrgWE09STaLpQUEhxuzK6huSA9V2AIr7XSXhxqO7+65alvhT6iXpFQJU9",
"BtbWWz4ce7OuP7wvZQqE+6hq0FY5HYS95bTZ1cfALZcbUL4JCudMqonuSvI/mbRMWgaKvf/7nE20WSsx",
"aWZCjgxUyjJQaY7sTo/t0EmxpNyFeXF1Vsk8ZR9cGBYNG7B/vQEe8RkaG9ycNGKtoJQ84afD0XDEI14C",
"ZR6zGF13svFSprX7e4rUjfUjukiYVJac1jE9YZQh81uZLVHIicSUjRfMq85aws/TsDl0QOfVQIGExnpS",
"7To5/33HLnfA8cRHyiOuoHBJe/ub6pGpMGp6rQsbH6EoPTonp92uVd+4vaGSPvk3o1Hop4pQ+byhLHMZ",
"Tkl81/Svjfl9pQ851r7ib79+PYrdd0exW0fcoqiMpIUvyxmCQcOT6xsHmK2KAsyiYUEo+Xbh3PbYcdOf",
"R2176NMcWMvAkXjIPPXXJGHjXIt7yypFMg9L/LmYgcxh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
"Tvw/Ai1mEExdkd6j3hJM8YVGgpaXiG0t3NT/BwAA//+IToO0xRUAAA==",
}
// GetSwagger returns the Swagger specification corresponding to the generated code
// in this file.
func GetSwagger() (*openapi3.Swagger, error) {
// GetSwagger returns the content of the embedded swagger specification file
// or error if failed to decode
func decodeSpec() ([]byte, error) {
zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
if err != nil {
return nil, fmt.Errorf("error base64 decoding spec: %s", err)
@ -295,9 +308,57 @@ func GetSwagger() (*openapi3.Swagger, error) {
return nil, fmt.Errorf("error decompressing spec: %s", err)
}
swagger, err := openapi3.NewSwaggerLoader().LoadSwaggerFromData(buf.Bytes())
if err != nil {
return nil, fmt.Errorf("error loading Swagger: %s", err)
}
return swagger, nil
return buf.Bytes(), nil
}
var rawSpec = decodeSpecCached()
// a naive cached of a decoded swagger spec
func decodeSpecCached() func() ([]byte, error) {
data, err := decodeSpec()
return func() ([]byte, error) {
return data, err
}
}
// Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
var res = make(map[string]func() ([]byte, error))
if len(pathToFile) > 0 {
res[pathToFile] = rawSpec
}
return res
}
// GetSwagger returns the Swagger specification corresponding to the generated code
// in this file. The external references of Swagger specification are resolved.
// The logic of resolving external references is tightly connected to "import-mapping" feature.
// Externally referenced files must be embedded in the corresponding golang packages.
// Urls can be supported but this task was out of the scope.
func GetSwagger() (swagger *openapi3.T, err error) {
var resolvePath = PathToRawSpec("")
loader := openapi3.NewLoader()
loader.IsExternalRefsAllowed = true
loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
var pathToFile = url.String()
pathToFile = path.Clean(pathToFile)
getSpec, ok := resolvePath[pathToFile]
if !ok {
err1 := fmt.Errorf("path not found: %s", pathToFile)
return nil, err1
}
return getSpec()
}
var specData []byte
specData, err = rawSpec()
if err != nil {
return
}
swagger, err = loader.LoadFromData(specData)
if err != nil {
return
}
return
}