api

package module
v0.0.0-...-6148fba Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 17 Imported by: 1

Documentation

Overview

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

Code generated by github.com/deepmap/oapi-codegen version v1.12.4 DO NOT EDIT.

Index

Constants

View Source
const VERSION = "1.02"

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 NewPetStructLevelValidation

func NewPetStructLevelValidation(sl validator.StructLevel)

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)

RegisterHandlers adds each server route to the EchoRouter.

func RegisterHandlersWithBaseURL

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

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

Types

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 Handler

type Handler struct {
	// Lock   sync.Mutex
	Pets   map[int64]models.Pet
	NextId int64
}

type Handler struct {}

func NewHandler

func NewHandler() *Handler
func NewHandler() Handler {
	// pong := Pong{
	// 	Index:      1,
	// 	Message:    "Pong!",
	// 	ReceivedOn: time.Now(),
	// }
	handler := Handler{}
	return handler
}

func (*Handler) AitrailblazerServiceAddPet

func (h *Handler) AitrailblazerServiceAddPet(ctx echo.Context) error

post:"/pets" body:"new_pet"

func (*Handler) AitrailblazerServiceDeletePet

func (h *Handler) AitrailblazerServiceDeletePet(ctx echo.Context, id int64) error

func (*Handler) AitrailblazerServiceEcho

func (h *Handler) AitrailblazerServiceEcho(ctx echo.Context, message string, params models.AitrailblazerServiceEchoParams) error

(GET /echo/:message) curl localhost:8080/echo/test curl localhost:8080/echo/test\?value\=test1234

func (*Handler) AitrailblazerServiceFindPetByID

func (h *Handler) AitrailblazerServiceFindPetByID(ctx echo.Context, petId int64) error

func (*Handler) AitrailblazerServiceFindPets

func (h *Handler) AitrailblazerServiceFindPets(ctx echo.Context, params models.AitrailblazerServiceFindPetsParams) error
rpc FindPets ( FindPetsParameters ) returns ( Pet ) {
    option (google.api.http) = {
      get:"/pets"
    };
 }

message FindPetsParameters {
	repeated string tags = 1;
	int32 limit = 2;
}

FindPets implements all the handlers in the ServerInterface

func (*Handler) AitrailblazerServiceListPets

func (h *Handler) AitrailblazerServiceListPets(ctx echo.Context, params models.AitrailblazerServiceListPetsParams) error

(GET /listpets)

func (*Handler) AitrailblazerServiceSendPing

func (h *Handler) AitrailblazerServiceSendPing(ctx echo.Context, params models.AitrailblazerServiceSendPingParams) error

curl localhost:8080/v1/ping curl localhost:8080/v1/ping?message=test

func (*Handler) ListPets

func (h *Handler) ListPets() []models.Pet

type NewPetValid

type NewPetValid struct {
	Name *string `validate:"min=1,max=10"`
	Tag  *string `validate:"min=1,max=10"`
}

type ServerInterface

type ServerInterface interface {

	// (GET /echo/{message})
	AitrailblazerServiceEcho(ctx echo.Context, message string, params AitrailblazerServiceEchoParams) error

	// (GET /listpets)
	AitrailblazerServiceListPets(ctx echo.Context, params AitrailblazerServiceListPetsParams) error

	// (GET /pets)
	AitrailblazerServiceFindPets(ctx echo.Context, params AitrailblazerServiceFindPetsParams) error

	// (POST /pets)
	AitrailblazerServiceAddPet(ctx echo.Context) error

	// (DELETE /pets/{id})
	AitrailblazerServiceDeletePet(ctx echo.Context, id int64) error

	// (GET /pets/{id})
	AitrailblazerServiceFindPetByID(ctx echo.Context, id int64) error

	// (GET /v1/ping)
	AitrailblazerServiceSendPing(ctx echo.Context, params AitrailblazerServiceSendPingParams) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) AitrailblazerServiceAddPet

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

AitrailblazerServiceAddPet converts echo context to params.

func (*ServerInterfaceWrapper) AitrailblazerServiceDeletePet

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

AitrailblazerServiceDeletePet converts echo context to params.

func (*ServerInterfaceWrapper) AitrailblazerServiceEcho

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

AitrailblazerServiceEcho converts echo context to params.

func (*ServerInterfaceWrapper) AitrailblazerServiceFindPetByID

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

AitrailblazerServiceFindPetByID converts echo context to params.

func (*ServerInterfaceWrapper) AitrailblazerServiceFindPets

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

AitrailblazerServiceFindPets converts echo context to params.

func (*ServerInterfaceWrapper) AitrailblazerServiceListPets

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

AitrailblazerServiceListPets converts echo context to params.

func (*ServerInterfaceWrapper) AitrailblazerServiceSendPing

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

AitrailblazerServiceSendPing converts echo context to params.

Jump to

Keyboard shortcuts

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