api

package
v1.11.1-0...-1d444b7 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 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/deepmap/oapi-codegen version (devel) DO NOT EDIT.

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

Code generated by github.com/deepmap/oapi-codegen 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 *gin.Engine, si ServerInterface) *gin.Engine

RegisterHandlers creates http.Handler with routing matching OpenAPI spec.

func RegisterHandlersWithOptions

func RegisterHandlersWithOptions(router *gin.Engine, si ServerInterface, options GinServerOptions) *gin.Engine

RegisterHandlersWithOptions creates http.Handler with additional options

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 Error

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

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

Error defines model for 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 GinServerOptions

type GinServerOptions struct {
	BaseURL     string
	Middlewares []MiddlewareFunc
}

GinServerOptions provides options for the Gin server.

type MiddlewareFunc

type MiddlewareFunc func(c *gin.Context)

type NewPet

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

	// 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"`

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

	// 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(c *gin.Context)

func (*PetStore) DeletePet

func (p *PetStore) DeletePet(c *gin.Context, id int64)

func (*PetStore) FindPetByID

func (p *PetStore) FindPetByID(c *gin.Context, petId int64)

func (*PetStore) FindPets

func (p *PetStore) FindPets(c *gin.Context, params FindPetsParams)

Here, we implement all of the handlers in the ServerInterface

type ServerInterface

type ServerInterface interface {
	// Returns all pets
	// (GET /pets)
	FindPets(c *gin.Context, params FindPetsParams)
	// Creates a new pet
	// (POST /pets)
	AddPet(c *gin.Context)
	// Deletes a pet by ID
	// (DELETE /pets/{id})
	DeletePet(c *gin.Context, id int64)
	// Returns a pet by ID
	// (GET /pets/{id})
	FindPetByID(c *gin.Context, id int64)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) AddPet

func (siw *ServerInterfaceWrapper) AddPet(c *gin.Context)

AddPet operation middleware

func (*ServerInterfaceWrapper) DeletePet

func (siw *ServerInterfaceWrapper) DeletePet(c *gin.Context)

DeletePet operation middleware

func (*ServerInterfaceWrapper) FindPetByID

func (siw *ServerInterfaceWrapper) FindPetByID(c *gin.Context)

FindPetByID operation middleware

func (*ServerInterfaceWrapper) FindPets

func (siw *ServerInterfaceWrapper) FindPets(c *gin.Context)

FindPets operation middleware

Jump to

Keyboard shortcuts

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