// 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/+xbzXLbuhV+FQzaRTulRfkmnZtqVd/r9tbT29YT2100zeKIOJSQkAADgHY0Hj1JV32X", "9r06AEiIohiLdGRLbrQTSeDg4Dvf+YPIe5rIvJAChdF0ck91Mscc3M+/4t21Ai64mNnLQskCleHoHrJS", "geFS2N+pVDkYOqFcmFff0YiaRYH+Emeo6DKiGYqZmfccLCBHO7R6oo2yKiwjWiie4KYuiVSFVGDco18q", "TOmE/iJe7SuuNhVfuvnLiMoCRc/By6ChnH7AxLg7Cj+VXCGjk3de22gFSK3m+42JURPS80rf1laggISb", "RU+kWCUkDHU3ok3kGCx0X1PJJFj2yxboh1wTp0q1sMNaWKVcY+EeyJ0Zg4JhB4KYA886df8CrbrN6cVs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qf/BmZWiw4JehLHUPDRijQj7UevMaxT7KWSrEz8x/i9", "JLclvl/+LwAA//9BeUHGnkUAAA==", } // 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 }