api

package
v0.0.0-...-b99e8af Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 13 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 v1.11.0 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.

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 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 openapi_types.UUID `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[string]Pet
	NextId uuid.UUID
	Lock   sync.Mutex
}

func NewPetStore

func NewPetStore() *PetStore

func (*PetStore) AddPet

func (p *PetStore) AddPet(w http.ResponseWriter, r *http.Request)

func (*PetStore) DeletePet

func (p *PetStore) DeletePet(w http.ResponseWriter, r *http.Request, id uuid.UUID)

func (*PetStore) FindPetByID

func (p *PetStore) FindPetByID(w http.ResponseWriter, r *http.Request, id uuid.UUID)

func (*PetStore) FindPets

func (p *PetStore) FindPets(w http.ResponseWriter, r *http.Request, params FindPetsParams)

Here, we implement all of the handlers in the ServerInterface

type ServerInterface

type ServerInterface interface {
	FindPets(w http.ResponseWriter, r *http.Request, params FindPetsParams)
	AddPet(w http.ResponseWriter, r *http.Request)
	DeletePet(w http.ResponseWriter, r *http.Request, id uuid.UUID)
	FindPetByID(w http.ResponseWriter, r *http.Request, id uuid.UUID)
}

ServerInterface represents xall server handlers.

Jump to

Keyboard shortcuts

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