api

package
v2.1.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package api provides primitives to interact with the openapi HTTP API.

Code generated by github.com/KosyanMedia/oapi-codegen/v2 version (devel) DO NOT EDIT.

Package api provides primitives to interact with the openapi HTTP API.

Code generated by github.com/KosyanMedia/oapi-codegen/v2 version (devel) DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

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 PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

func RegisterHandlers

func RegisterHandlers(router EchoRouter, si ServerInterface, m ...echo.MiddlewareFunc)

RegisterHandlers adds each server route to the EchoRouter.

func RegisterHandlersWithBaseURL

func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string, m ...echo.MiddlewareFunc)

Registers handlers, and prepends BaseURL to the paths, so that the paths can be served under a prefix.

Types

type AddPetJSONBody

type AddPetJSONBody = NewPet

AddPetJSONBody defines parameters for AddPet.

type AddPetJSONRequestBody

type AddPetJSONRequestBody = AddPetJSONBody

AddPetJSONRequestBody defines body for AddPet for application/json ContentType.

type AddPetResponse

type AddPetResponse struct {
	Code        int
	JSON201     *Pet
	JSONDefault *Error
}

type DeletePetResponse

type DeletePetResponse struct {
	Code        int
	JSONDefault *Error
}

type EchoRouter

type EchoRouter interface {
	CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}

This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration

type Error

type Error struct {
	// Error code
	Code int32 `json:"code" validate:"required"`

	// Error message
	Message string `json:"message" validate:"required"`
}

Error defines model for Error.

type FindPetByIDResponse

type FindPetByIDResponse struct {
	Code        int
	JSON200     *Pet
	JSONDefault *Error
}

type FindPetsParams

type FindPetsParams struct {
	// tags to filter by
	Tags []string `form:"tags,omitempty" json:"tags,omitempty"`

	// maximum number of results to return
	Limit *int32 `form:"limit,omitempty" json:"limit,omitempty"`
}

FindPetsParams defines parameters for FindPets.

type FindPetsResponse

type FindPetsResponse struct {
	Code        int
	JSON200     []Pet
	JSONDefault *Error
}

type NewPet

type NewPet struct {
	// Name of the pet
	Name string `json:"name" validate:"required"`

	// Type of the pet
	Tag *string `json:"tag,omitempty"`
}

NewPet defines model for NewPet.

type Pet

type Pet struct {
	// Unique id of the pet
	Id int64 `json:"id" validate:"required"`

	// Name of the pet
	Name string `json:"name" validate:"required"`

	// Type of the pet
	Tag *string `json:"tag,omitempty"`
}

Pet defines model for Pet.

type PetStore

type PetStore struct {
	Pets   map[int64]Pet
	NextId int64
	Lock   sync.Mutex
}

func NewPetStore

func NewPetStore() *PetStore

func (*PetStore) AddPet

func (p *PetStore) AddPet(ctx echo.Context, requestBody AddPetJSONBody) (*AddPetResponse, error)

func (*PetStore) DeletePet

func (p *PetStore) DeletePet(ctx echo.Context, petId int64) (resp *DeletePetResponse, err error)

func (*PetStore) FindPetByID

func (p *PetStore) FindPetByID(ctx echo.Context, petId int64) (*FindPetByIDResponse, error)

func (*PetStore) FindPets

func (p *PetStore) FindPets(ctx echo.Context, params FindPetsParams) (*FindPetsResponse, error)

Here, we implement all of the handlers in the ServerInterface

type ServerInterface

type ServerInterface interface {
	// Returns all pets
	// (GET /pets)
	FindPets(ctx echo.Context, params FindPetsParams) (resp *FindPetsResponse, err error)
	// Creates a new pet
	// (POST /pets)
	AddPet(ctx echo.Context, requestBody AddPetJSONBody) (resp *AddPetResponse, err error)
	// Deletes a pet by ID
	// (DELETE /pets/{id})
	DeletePet(ctx echo.Context, id int64) (resp *DeletePetResponse, err error)
	// Returns a pet by ID
	// (GET /pets/{id})
	FindPetByID(ctx echo.Context, id int64) (resp *FindPetByIDResponse, err error)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) AddPet

func (w *ServerInterfaceWrapper) AddPet(ctx echo.Context) error

AddPet converts echo context to params.

func (*ServerInterfaceWrapper) DeletePet

func (w *ServerInterfaceWrapper) DeletePet(ctx echo.Context) error

DeletePet converts echo context to params.

func (*ServerInterfaceWrapper) FindPetByID

func (w *ServerInterfaceWrapper) FindPetByID(ctx echo.Context) error

FindPetByID converts echo context to params.

func (*ServerInterfaceWrapper) FindPets

func (w *ServerInterfaceWrapper) FindPets(ctx echo.Context) error

FindPets converts echo context to params.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL