api

package
v1.9.8 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 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/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 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 PetStore

type PetStore struct {
	Pets   map[int64]models.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 models.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 models.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.

Directories

Path Synopsis
Package models provides primitives to interact with the openapi HTTP API.
Package models provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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