api

package
v0.0.0-...-bc77d18 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

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

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.3.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.

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 GetTodosParams

type GetTodosParams struct {
	Limit *int `form:"limit,omitempty" json:"limit,omitempty"`
}

GetTodosParams defines parameters for GetTodos.

type PostTodosJSONRequestBody

type PostTodosJSONRequestBody = TodoInput

PostTodosJSONRequestBody defines body for PostTodos for application/json ContentType.

type PutTodosTodoIdJSONRequestBody

type PutTodosTodoIdJSONRequestBody = TodoInput

PutTodosTodoIdJSONRequestBody defines body for PutTodosTodoId for application/json ContentType.

type ServerInterface

type ServerInterface interface {
	// List all TODO items
	// (GET /todos)
	GetTodos(ctx echo.Context, params GetTodosParams) error
	// Create a new TODO item
	// (POST /todos)
	PostTodos(ctx echo.Context) error
	// Delete a TODO item
	// (DELETE /todos/{todoId})
	DeleteTodosTodoId(ctx echo.Context, todoId int) error
	// Get a specific TODO item
	// (GET /todos/{todoId})
	GetTodosTodoId(ctx echo.Context, todoId int) error
	// Update a TODO item
	// (PUT /todos/{todoId})
	PutTodosTodoId(ctx echo.Context, todoId int) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) DeleteTodosTodoId

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

DeleteTodosTodoId converts echo context to params.

func (*ServerInterfaceWrapper) GetTodos

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

GetTodos converts echo context to params.

func (*ServerInterfaceWrapper) GetTodosTodoId

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

GetTodosTodoId converts echo context to params.

func (*ServerInterfaceWrapper) PostTodos

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

PostTodos converts echo context to params.

func (*ServerInterfaceWrapper) PutTodosTodoId

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

PutTodosTodoId converts echo context to params.

type Todo

type Todo struct {
	Completed   *bool     `json:"completed,omitempty"`
	CreatedAt   time.Time `json:"createdAt"`
	Description *string   `json:"description,omitempty"`
	Id          int       `json:"id"`
	Title       string    `json:"title"`
}

Todo defines model for Todo.

type TodoInput

type TodoInput struct {
	Completed   *bool   `json:"completed,omitempty"`
	Description *string `json:"description,omitempty"`
	Title       string  `json:"title"`
}

TodoInput defines model for TodoInput.

Jump to

Keyboard shortcuts

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