// 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 openapi_types.UUID, dateID openapi_types.UUID) 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 openapi_types.UUID 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 openapi_types.UUID 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/+xbzXLjuBF+FRSSQ1JFi/LOpHaiU7zrZOPKJnGt7RwymUOLbEqYIQEOANqjculJcsq7", "JO+VAkBCJMWxSFuWuWvdRBJoNL7++g8i72kkslxw5FrR2T1V0RIzsD//hnfXEhhnfGEucylylJqhfRgX", "EjQT3PxOhMxA0xllXL/5hgZUr3J0l7hASdcBTZEv9LLnYA4ZmqHlE6WlUWEd0FyyCLd1iYTMhQRtH/1a", "YkJn9FfhZl9huanw0s5fB1TkyHsOXnsNxfwjRtrekfi5YBJjOnvvtA02gFRqftiaGNQhPS/1bW0FcoiY", "XvVEKi6F+KH2RrCNXAwr1ddUIvKW/boF+iFXx6lUze+wElYqV1u4B3JnWiOPsQNBzIClnbp/h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2bvpuGt6f2k8DWJ/EaFkaLDglqFoaQs8mGLBPlRjeY1Sn2Uoq4iNxH6r0ktyV+WP8/AAD/", "/yD5hI62RAAA", } // 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 }