api

package
v1.9.0 Latest Latest
Warning

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

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

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

Code generated by github.com/xenking/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 QueryParams

func QueryParams(ctx *fiber.Ctx) url.Values

func RegisterHandlers

func RegisterHandlers(router FiberRouter, si ServerInterface)

RegisterHandlers adds each server route to the FiberRouter.

func RegisterHandlersWithBaseURL

func RegisterHandlersWithBaseURL(router FiberRouter, si ServerInterface, baseURL string)

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 Error

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

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

Error defines model for Error.

type FiberRouter

type FiberRouter interface {
	Connect(path string, handlers ...fiber.Handler) fiber.Router
	Delete(path string, handlers ...fiber.Handler) fiber.Router
	Get(path string, handlers ...fiber.Handler) fiber.Router
	Head(path string, handlers ...fiber.Handler) fiber.Router
	Options(path string, handlers ...fiber.Handler) fiber.Router
	Patch(path string, handlers ...fiber.Handler) fiber.Router
	Post(path string, handlers ...fiber.Handler) fiber.Router
	Put(path string, handlers ...fiber.Handler) fiber.Router
	Trace(path string, handlers ...fiber.Handler) fiber.Router
}

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

type FindPetsParams

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

	// maximum number of results to return
	Limit *int32 `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 {
	// Embedded struct due to allOf(#/components/schemas/NewPet)
	NewPet `yaml:",inline"`
	// Embedded fields due to inline allOf schema
	// Unique id of the pet
	Id int64 `json:"id"`
}

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 *fiber.Ctx) error

func (*PetStore) DeletePet

func (p *PetStore) DeletePet(ctx *fiber.Ctx, id int64) error

func (*PetStore) FindPetByID

func (p *PetStore) FindPetByID(ctx *fiber.Ctx, petId int64) error

func (*PetStore) FindPets

func (p *PetStore) FindPets(ctx *fiber.Ctx, params FindPetsParams) error

Here, we implement all of the handlers in the ServerInterface

type ServerInterface

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

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts fiber contexts to parameters.

func (*ServerInterfaceWrapper) AddPet

func (w *ServerInterfaceWrapper) AddPet(ctx *fiber.Ctx) error

AddPet converts fiber context to params.

func (*ServerInterfaceWrapper) DeletePet

func (w *ServerInterfaceWrapper) DeletePet(ctx *fiber.Ctx) error

DeletePet converts fiber context to params.

func (*ServerInterfaceWrapper) FindPetByID

func (w *ServerInterfaceWrapper) FindPetByID(ctx *fiber.Ctx) error

FindPetByID converts fiber context to params.

func (*ServerInterfaceWrapper) FindPets

func (w *ServerInterfaceWrapper) FindPets(ctx *fiber.Ctx) error

FindPets converts fiber context to params.

Jump to

Keyboard shortcuts

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