// Package api provides primitives to interact with the openapi HTTP API. // // Code generated by github.com/deepmap/oapi-codegen/v2 version v2.1.0 DO NOT EDIT. package api import ( "bytes" "compress/gzip" "encoding/base64" "fmt" "net/url" "path" "strings" "github.com/getkin/kin-openapi/openapi3" "github.com/gofiber/fiber/v2" "github.com/oapi-codegen/runtime" openapi_types "github.com/oapi-codegen/runtime/types" "gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training" ) // Defines values for PriceCurrency. const ( CZK PriceCurrency = "CZK" EUR PriceCurrency = "EUR" USD PriceCurrency = "USD" ) // NewTraining defines model for NewTraining. type NewTraining struct { Duration int32 `json:"duration"` Length *int32 `json:"length,omitempty"` Name string `json:"name"` Price struct { Corporate *Price `json:"corporate,omitempty"` Open *Price `json:"open,omitempty"` } `json:"price"` } // NewTrainingDate defines model for NewTrainingDate. type NewTrainingDate struct { Capacity int32 `json:"capacity"` Date openapi_types.Date `json:"date"` Days int32 `json:"days"` Location string `json:"location"` Price Price `json:"price"` } // NewTrainingDateAttendee defines model for NewTrainingDateAttendee. type NewTrainingDateAttendee struct { Email string `json:"email"` Name string `json:"name"` } // NewTrainingFeedback defines model for NewTrainingFeedback. type NewTrainingFeedback struct { Anonymous *bool `json:"anonymous,omitempty"` Comment string `json:"comment"` IsSharingAllowed *bool `json:"isSharingAllowed,omitempty"` Rating int32 `json:"rating"` } // Price defines model for Price. type Price struct { Amount *float32 `json:"amount,omitempty"` Currency *PriceCurrency `json:"currency,omitempty"` } // PriceCurrency defines model for Price.Currency. type PriceCurrency string // ProblemDetails Schema that carries the details of an error in an HTTP response. See https://datatracker.ietf.org/doc/html/rfc7807 for more information. type ProblemDetails struct { // Detail A human-readable explanation specific to this occurrence of the problem. Detail string `json:"detail"` // Instance A URI reference that identifies the specific occurrence of the problem. Instance string `json:"instance"` // Status The HTTP status code generated by the origin server for this occurrence of the problem. Status int `json:"status"` // Title A human-readable summary of the problem type. Title string `json:"title"` // Type A URI reference that identifies the problem type. Type string `json:"type"` } // Training defines model for Training. type Training struct { Duration int32 `json:"duration"` Id training.ID `json:"id"` Length *int32 `json:"length,omitempty"` Name string `json:"name"` Price struct { Corporate *Price `json:"corporate,omitempty"` Open *Price `json:"open,omitempty"` } `json:"price"` } // TrainingDate defines model for TrainingDate. type TrainingDate struct { Address *string `json:"address,omitempty"` Capacity int32 `json:"capacity"` Date openapi_types.Date `json:"date"` Days int32 `json:"days"` Id training.DateID `json:"id"` Location string `json:"location"` Price Price `json:"price"` } // TrainingDateAttendee defines model for TrainingDateAttendee. type TrainingDateAttendee struct { Company *string `json:"company,omitempty"` Email string `json:"email"` Id training.AttendeeID `json:"id"` Name string `json:"name"` } // TrainingFeedback defines model for TrainingFeedback. type TrainingFeedback struct { Anonymous *bool `json:"anonymous,omitempty"` Comment string `json:"comment"` Id training.FeedbackID `json:"id"` IsSharingAllowed *bool `json:"isSharingAllowed,omitempty"` Rating int32 `json:"rating"` } // ListUpcomingTrainingDatesParams defines parameters for ListUpcomingTrainingDates. type ListUpcomingTrainingDatesParams struct { From *openapi_types.Date `form:"from,omitempty" json:"from,omitempty"` To *openapi_types.Date `form:"to,omitempty" json:"to,omitempty"` Limit *openapi_types.Date `form:"limit,omitempty" json:"limit,omitempty"` } // CreateTrainingJSONRequestBody defines body for CreateTraining for application/json ContentType. type CreateTrainingJSONRequestBody = NewTraining // UpdateTrainingJSONRequestBody defines body for UpdateTraining for application/json ContentType. type UpdateTrainingJSONRequestBody = NewTraining // CreateTrainingDateJSONRequestBody defines body for CreateTrainingDate for application/json ContentType. type CreateTrainingDateJSONRequestBody = NewTrainingDate // UpdateTrainingDateJSONRequestBody defines body for UpdateTrainingDate for application/json ContentType. type UpdateTrainingDateJSONRequestBody = NewTrainingDate // CreateTrainingDateAttendeeJSONRequestBody defines body for CreateTrainingDateAttendee for application/json ContentType. type CreateTrainingDateAttendeeJSONRequestBody = NewTrainingDateAttendee // CreateTrainingDateAttendeeFeedbackJSONRequestBody defines body for CreateTrainingDateAttendeeFeedback for application/json ContentType. type CreateTrainingDateAttendeeFeedbackJSONRequestBody = NewTrainingFeedback // ServerInterface represents all server handlers. type ServerInterface interface { // List all trainings // (GET /trainings) ListTrainings(c *fiber.Ctx) error // Create a new training // (POST /trainings) CreateTraining(c *fiber.Ctx) error // List all upcoming dates of all trainings // (GET /trainings/upcoming-dates) ListUpcomingTrainingDates(c *fiber.Ctx, params ListUpcomingTrainingDatesParams) error // Delete a training by ID // (DELETE /trainings/{trainingID}) DeleteTraining(c *fiber.Ctx, trainingID training.ID) error // Get a training by ID // (GET /trainings/{trainingID}) GetTraining(c *fiber.Ctx, trainingID training.ID) error // Update a training by ID // (PUT /trainings/{trainingID}) UpdateTraining(c *fiber.Ctx, trainingID training.ID) error // List all dates of a training // (GET /trainings/{trainingID}/dates) ListTrainingDates(c *fiber.Ctx, trainingID training.ID) error // Create a new date for a training // (POST /trainings/{trainingID}/dates) CreateTrainingDate(c *fiber.Ctx, trainingID training.ID) error // Delete a date of a training // (DELETE /trainings/{trainingID}/dates/{dateID}) DeleteTrainingDate(c *fiber.Ctx, trainingID training.ID, dateID training.DateID) error // Update a date of a training // (PUT /trainings/{trainingID}/dates/{dateID}) UpdateTrainingDate(c *fiber.Ctx, trainingID training.ID, dateID training.DateID) error // List all attendees of a date of a training // (GET /trainings/{trainingID}/dates/{dateID}/attendees) ListTrainingDateAttendees(c *fiber.Ctx, trainingID training.ID, dateID training.DateID) error // Add an attendee to a date of a training // (POST /trainings/{trainingID}/dates/{dateID}/attendees) CreateTrainingDateAttendee(c *fiber.Ctx, trainingID training.ID, dateID training.DateID) error // Delete an attendee of a date of a training // (DELETE /trainings/{trainingID}/dates/{dateID}/attendees/{attendeeID}) DeleteTrainingDateAttendee(c *fiber.Ctx, trainingID training.ID, dateID training.DateID, attendeeID training.AttendeeID) error // Submit feedback for an attendee of a date of a training // (POST /trainings/{trainingID}/dates/{dateID}/attendees/{attendeeID}/feedback) CreateTrainingDateAttendeeFeedback(c *fiber.Ctx, trainingID training.ID, dateID training.DateID, attendeeID training.AttendeeID) error // List all feedback of a date of a training // (GET /trainings/{trainingID}/dates/{dateID}/feedback) ListTrainingDateFeedback(c *fiber.Ctx, trainingID training.ID, dateID training.DateID) error // List all feedback of a training // (GET /trainings/{trainingID}/feedback) ListTrainingFeedback(c *fiber.Ctx, trainingID training.ID) error } // ServerInterfaceWrapper converts contexts to parameters. type ServerInterfaceWrapper struct { Handler ServerInterface } type MiddlewareFunc fiber.Handler // ListTrainings operation middleware func (siw *ServerInterfaceWrapper) ListTrainings(c *fiber.Ctx) error { return siw.Handler.ListTrainings(c) } // CreateTraining operation middleware func (siw *ServerInterfaceWrapper) CreateTraining(c *fiber.Ctx) error { return siw.Handler.CreateTraining(c) } // ListUpcomingTrainingDates operation middleware func (siw *ServerInterfaceWrapper) ListUpcomingTrainingDates(c *fiber.Ctx) error { var err error // Parameter object where we will unmarshal all parameters from the context var params ListUpcomingTrainingDatesParams var query url.Values query, err = url.ParseQuery(string(c.Request().URI().QueryString())) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for query string: %w", err).Error()) } // ------------- Optional query parameter "from" ------------- err = runtime.BindQueryParameter("form", true, false, "from", query, ¶ms.From) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter from: %w", err).Error()) } // ------------- Optional query parameter "to" ------------- err = runtime.BindQueryParameter("form", true, false, "to", query, ¶ms.To) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter to: %w", err).Error()) } // ------------- Optional query parameter "limit" ------------- err = runtime.BindQueryParameter("form", true, false, "limit", query, ¶ms.Limit) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter limit: %w", err).Error()) } return siw.Handler.ListUpcomingTrainingDates(c, params) } // DeleteTraining operation middleware func (siw *ServerInterfaceWrapper) DeleteTraining(c *fiber.Ctx) error { var err error // ------------- Path parameter "trainingID" ------------- var trainingID training.ID err = runtime.BindStyledParameterWithOptions("simple", "trainingID", c.Params("trainingID"), &trainingID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter trainingID: %w", err).Error()) } return siw.Handler.DeleteTraining(c, trainingID) } // GetTraining operation middleware func (siw *ServerInterfaceWrapper) GetTraining(c *fiber.Ctx) error { var err error // ------------- Path parameter "trainingID" ------------- var trainingID training.ID err = runtime.BindStyledParameterWithOptions("simple", "trainingID", c.Params("trainingID"), &trainingID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter trainingID: %w", err).Error()) } return siw.Handler.GetTraining(c, trainingID) } // UpdateTraining operation middleware func (siw *ServerInterfaceWrapper) UpdateTraining(c *fiber.Ctx) error { var err error // ------------- Path parameter "trainingID" ------------- var trainingID training.ID err = runtime.BindStyledParameterWithOptions("simple", "trainingID", c.Params("trainingID"), &trainingID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter trainingID: %w", err).Error()) } return siw.Handler.UpdateTraining(c, trainingID) } // ListTrainingDates operation middleware func (siw *ServerInterfaceWrapper) ListTrainingDates(c *fiber.Ctx) error { var err error // ------------- Path parameter "trainingID" ------------- var trainingID training.ID err = runtime.BindStyledParameterWithOptions("simple", "trainingID", c.Params("trainingID"), &trainingID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter trainingID: %w", err).Error()) } return siw.Handler.ListTrainingDates(c, trainingID) } // CreateTrainingDate operation middleware func (siw *ServerInterfaceWrapper) CreateTrainingDate(c *fiber.Ctx) error { var err error // ------------- Path parameter "trainingID" ------------- var trainingID training.ID err = runtime.BindStyledParameterWithOptions("simple", "trainingID", c.Params("trainingID"), &trainingID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter trainingID: %w", err).Error()) } return siw.Handler.CreateTrainingDate(c, trainingID) } // DeleteTrainingDate operation middleware func (siw *ServerInterfaceWrapper) DeleteTrainingDate(c *fiber.Ctx) error { var err error // ------------- Path parameter "trainingID" ------------- var trainingID training.ID err = runtime.BindStyledParameterWithOptions("simple", "trainingID", c.Params("trainingID"), &trainingID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter trainingID: %w", err).Error()) } // ------------- Path parameter "dateID" ------------- var dateID training.DateID err = runtime.BindStyledParameterWithOptions("simple", "dateID", c.Params("dateID"), &dateID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter dateID: %w", err).Error()) } return siw.Handler.DeleteTrainingDate(c, trainingID, dateID) } // UpdateTrainingDate operation middleware func (siw *ServerInterfaceWrapper) UpdateTrainingDate(c *fiber.Ctx) error { var err error // ------------- Path parameter "trainingID" ------------- var trainingID training.ID err = runtime.BindStyledParameterWithOptions("simple", "trainingID", c.Params("trainingID"), &trainingID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter trainingID: %w", err).Error()) } // ------------- Path parameter "dateID" ------------- var dateID training.DateID err = runtime.BindStyledParameterWithOptions("simple", "dateID", c.Params("dateID"), &dateID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter dateID: %w", err).Error()) } return siw.Handler.UpdateTrainingDate(c, trainingID, dateID) } // ListTrainingDateAttendees operation middleware func (siw *ServerInterfaceWrapper) ListTrainingDateAttendees(c *fiber.Ctx) error { var err error // ------------- Path parameter "trainingID" ------------- var trainingID training.ID err = runtime.BindStyledParameterWithOptions("simple", "trainingID", c.Params("trainingID"), &trainingID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter trainingID: %w", err).Error()) } // ------------- Path parameter "dateID" ------------- var dateID training.DateID err = runtime.BindStyledParameterWithOptions("simple", "dateID", c.Params("dateID"), &dateID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter dateID: %w", err).Error()) } return siw.Handler.ListTrainingDateAttendees(c, trainingID, dateID) } // CreateTrainingDateAttendee operation middleware func (siw *ServerInterfaceWrapper) CreateTrainingDateAttendee(c *fiber.Ctx) error { var err error // ------------- Path parameter "trainingID" ------------- var trainingID training.ID err = runtime.BindStyledParameterWithOptions("simple", "trainingID", c.Params("trainingID"), &trainingID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter trainingID: %w", err).Error()) } // ------------- Path parameter "dateID" ------------- var dateID training.DateID err = runtime.BindStyledParameterWithOptions("simple", "dateID", c.Params("dateID"), &dateID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter dateID: %w", err).Error()) } return siw.Handler.CreateTrainingDateAttendee(c, trainingID, dateID) } // DeleteTrainingDateAttendee operation middleware func (siw *ServerInterfaceWrapper) DeleteTrainingDateAttendee(c *fiber.Ctx) error { var err error // ------------- Path parameter "trainingID" ------------- var trainingID training.ID err = runtime.BindStyledParameterWithOptions("simple", "trainingID", c.Params("trainingID"), &trainingID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter trainingID: %w", err).Error()) } // ------------- Path parameter "dateID" ------------- var dateID training.DateID err = runtime.BindStyledParameterWithOptions("simple", "dateID", c.Params("dateID"), &dateID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter dateID: %w", err).Error()) } // ------------- Path parameter "attendeeID" ------------- var attendeeID training.AttendeeID err = runtime.BindStyledParameterWithOptions("simple", "attendeeID", c.Params("attendeeID"), &attendeeID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter attendeeID: %w", err).Error()) } return siw.Handler.DeleteTrainingDateAttendee(c, trainingID, dateID, attendeeID) } // CreateTrainingDateAttendeeFeedback operation middleware func (siw *ServerInterfaceWrapper) CreateTrainingDateAttendeeFeedback(c *fiber.Ctx) error { var err error // ------------- Path parameter "trainingID" ------------- var trainingID training.ID err = runtime.BindStyledParameterWithOptions("simple", "trainingID", c.Params("trainingID"), &trainingID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter trainingID: %w", err).Error()) } // ------------- Path parameter "dateID" ------------- var dateID training.DateID err = runtime.BindStyledParameterWithOptions("simple", "dateID", c.Params("dateID"), &dateID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter dateID: %w", err).Error()) } // ------------- Path parameter "attendeeID" ------------- var attendeeID training.AttendeeID err = runtime.BindStyledParameterWithOptions("simple", "attendeeID", c.Params("attendeeID"), &attendeeID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter attendeeID: %w", err).Error()) } return siw.Handler.CreateTrainingDateAttendeeFeedback(c, trainingID, dateID, attendeeID) } // ListTrainingDateFeedback operation middleware func (siw *ServerInterfaceWrapper) ListTrainingDateFeedback(c *fiber.Ctx) error { var err error // ------------- Path parameter "trainingID" ------------- var trainingID training.ID err = runtime.BindStyledParameterWithOptions("simple", "trainingID", c.Params("trainingID"), &trainingID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter trainingID: %w", err).Error()) } // ------------- Path parameter "dateID" ------------- var dateID training.DateID err = runtime.BindStyledParameterWithOptions("simple", "dateID", c.Params("dateID"), &dateID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter dateID: %w", err).Error()) } return siw.Handler.ListTrainingDateFeedback(c, trainingID, dateID) } // ListTrainingFeedback operation middleware func (siw *ServerInterfaceWrapper) ListTrainingFeedback(c *fiber.Ctx) error { var err error // ------------- Path parameter "trainingID" ------------- var trainingID training.ID err = runtime.BindStyledParameterWithOptions("simple", "trainingID", c.Params("trainingID"), &trainingID, runtime.BindStyledParameterOptions{Explode: false, Required: true}) if err != nil { return fiber.NewError(fiber.StatusBadRequest, fmt.Errorf("Invalid format for parameter trainingID: %w", err).Error()) } return siw.Handler.ListTrainingFeedback(c, trainingID) } // FiberServerOptions provides options for the Fiber server. type FiberServerOptions struct { BaseURL string Middlewares []MiddlewareFunc } // RegisterHandlers creates http.Handler with routing matching OpenAPI spec. func RegisterHandlers(router fiber.Router, si ServerInterface) { RegisterHandlersWithOptions(router, si, FiberServerOptions{}) } // RegisterHandlersWithOptions creates http.Handler with additional options func RegisterHandlersWithOptions(router fiber.Router, si ServerInterface, options FiberServerOptions) { wrapper := ServerInterfaceWrapper{ Handler: si, } for _, m := range options.Middlewares { router.Use(m) } router.Get(options.BaseURL+"/trainings", wrapper.ListTrainings) router.Post(options.BaseURL+"/trainings", wrapper.CreateTraining) router.Get(options.BaseURL+"/trainings/upcoming-dates", wrapper.ListUpcomingTrainingDates) router.Delete(options.BaseURL+"/trainings/:trainingID", wrapper.DeleteTraining) router.Get(options.BaseURL+"/trainings/:trainingID", wrapper.GetTraining) router.Put(options.BaseURL+"/trainings/:trainingID", wrapper.UpdateTraining) router.Get(options.BaseURL+"/trainings/:trainingID/dates", wrapper.ListTrainingDates) router.Post(options.BaseURL+"/trainings/:trainingID/dates", wrapper.CreateTrainingDate) router.Delete(options.BaseURL+"/trainings/:trainingID/dates/:dateID", wrapper.DeleteTrainingDate) router.Put(options.BaseURL+"/trainings/:trainingID/dates/:dateID", wrapper.UpdateTrainingDate) router.Get(options.BaseURL+"/trainings/:trainingID/dates/:dateID/attendees", wrapper.ListTrainingDateAttendees) router.Post(options.BaseURL+"/trainings/:trainingID/dates/:dateID/attendees", wrapper.CreateTrainingDateAttendee) router.Delete(options.BaseURL+"/trainings/:trainingID/dates/:dateID/attendees/:attendeeID", wrapper.DeleteTrainingDateAttendee) router.Post(options.BaseURL+"/trainings/:trainingID/dates/:dateID/attendees/:attendeeID/feedback", wrapper.CreateTrainingDateAttendeeFeedback) router.Get(options.BaseURL+"/trainings/:trainingID/dates/:dateID/feedback", wrapper.ListTrainingDateFeedback) router.Get(options.BaseURL+"/trainings/:trainingID/feedback", wrapper.ListTrainingFeedback) } // Base64 encoded, gzipped, json marshaled Swagger object var swaggerSpec = []string{ "H4sIAAAAAAAC/+xc3XLbuhF+FQzai3ZKi/JJOifVVX2O21NPT1tPbPeiaS5W5FJCQgIMsLSj8ehJetV3", "ad+rA4CEKImxSMeJ5EZ3EkksF9/ufvsjUvc8UUWpJEoyfHLPTTLHAtzHv+LdtQYhhZzZr6VWJWoS6E6m", "lQYSStrPmdIFEJ9wIenFdzzitCjRf8UZar6MeI5yRvOeF0so0F5anzGkrQrLiJdaJLitS6J0qTSQO/VL", "jRmf8F/Eq33F9abiS7d+GXFVoux58TJoqKbvMCF3ROOHSmhM+eSN1zZaAdKo+XZrYdSG9LzWd2MrUEIi", "aNETqbQWEi51B6Jt5FJYmL6mUkmw7Kct0A+5Nk61amGHjbBaudaNeyB3RoQyxQ4EsQCRd+r+CbfqNqcX", "s0O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JI6hFKOV04yMv3rNwzrFXmqVVon/64Fe", "kjclvl3+LwAA//9ZozlKjEYAAA==", } // 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: %w", err) } zr, err := gzip.NewReader(bytes.NewReader(zipped)) if err != nil { return nil, fmt.Errorf("error decompressing spec: %w", err) } var buf bytes.Buffer _, err = buf.ReadFrom(zr) if err != nil { return nil, fmt.Errorf("error decompressing spec: %w", err) } 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) { 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) { resolvePath := PathToRawSpec("") loader := openapi3.NewLoader() loader.IsExternalRefsAllowed = true loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) { 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 }