708 lines
28 KiB
Go
708 lines
28 KiB
Go
// 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/+xczXLjuBF+FRSSQ1KhRHlnUjvRKd51snFlN3Gt7Rwy8aFFNCXMkAAHAG2rXHqSnPIu",
|
|
"yXulAJAQRXEs0uMZyTu68Q+NxtfdX3dDpB5oIvNCChRG0+kD1ckCc3CHf8O7KwVccDG3p4WSBSrD0d1k",
|
|
"pQLDpbDHqVQ5GDqlXJhX39CImmWB/hTnqOgqohmKuVn0fFhAjvbR6o42yqqwimiheILbuiRSFVKBcbd+",
|
|
"rTClU/qreL2uuFpUfOHGryIqCxQ9H14FDeXsHSbGXVH4oeQKGZ2+9dpGa0BqNW+2BkZNSM8qfVtLgQIS",
|
|
"bpY9kWKVkPCouxBtI8dgqfuaSibBsh+3QD/kmjhVqoUV1sIq5RoT90Du1BgUDDsQxBx41qn7R9yq25xe",
|
|
"zA5N/ozIZpC839YChBTLXJY+VjCFMjN0mkKmMYicSZkhCCszkXmOwnSqzfXlAuzJaZbJO6tkH4nWGX3c",
|
|
"bpk8h3uelzmdnkwimnPhTybbvtBCphK51rYLnYvuEIVcln59QZ00k2BopwaizGfeGZNSKRSJiwcU9qm3",
|
|
"9Pt//pVG9E/XP9OIXl+eNdRomLRDMTnLMD9DAzyrzKITxQvv6/TSOS8xCzAkAaU4amIWSJgfQGRKQBBU",
|
|
"SirChT3+y9XV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|
"RgAA",
|
|
}
|
|
|
|
// 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
|
|
}
|