api

package
v0.0.0-...-6faef24 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: MIT Imports: 15 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.9.1 DO NOT EDIT.

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

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

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

Code generated by github.com/deepmap/oapi-codegen version v1.9.1 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 NewAddPetRequest

func NewAddPetRequest(server string, body AddPetJSONRequestBody) (*http.Request, error)

NewAddPetRequest calls the generic AddPet builder with application/json body

func NewAddPetRequestWithBody

func NewAddPetRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewAddPetRequestWithBody generates requests for AddPet with any type of body

func NewDeletePetRequest

func NewDeletePetRequest(server string, id int64) (*http.Request, error)

NewDeletePetRequest generates requests for DeletePet

func NewFindPetByIdRequest

func NewFindPetByIdRequest(server string, id int64) (*http.Request, error)

NewFindPetByIdRequest generates requests for FindPetById

func NewFindPetsRequest

func NewFindPetsRequest(server string, params *FindPetsParams) (*http.Request, error)

NewFindPetsRequest generates requests for FindPets

func NewHealthCheckRequest

func NewHealthCheckRequest(server string) (*http.Request, error)

NewHealthCheckRequest generates requests for HealthCheck

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 AddPetJSONBody

type AddPetJSONBody NewPet

AddPetJSONBody defines parameters for AddPet.

type AddPetJSONRequestBody

type AddPetJSONRequestBody AddPetJSONBody

AddPetJSONRequestBody defines body for AddPet for application/json ContentType.

type AddPetResponse

type AddPetResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *Pet
	JSONDefault  *Error
}

func ParseAddPetResponse

func ParseAddPetResponse(rsp *http.Response) (*AddPetResponse, error)

ParseAddPetResponse parses an HTTP response from a AddPetWithResponse call

func (AddPetResponse) Status

func (r AddPetResponse) Status() string

Status returns HTTPResponse.Status

func (AddPetResponse) StatusCode

func (r AddPetResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) AddPet

func (c *Client) AddPet(ctx context.Context, body AddPetJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) AddPetWithBody

func (c *Client) AddPetWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) DeletePet

func (c *Client) DeletePet(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) FindPetById

func (c *Client) FindPetById(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) FindPets

func (c *Client) FindPets(ctx context.Context, params *FindPetsParams, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) HealthCheck

func (c *Client) HealthCheck(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// HealthCheck request
	HealthCheck(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

	// FindPets request
	FindPets(ctx context.Context, params *FindPetsParams, reqEditors ...RequestEditorFn) (*http.Response, error)

	// AddPet request with any body
	AddPetWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	AddPet(ctx context.Context, body AddPetJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// DeletePet request
	DeletePet(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (*http.Response, error)

	// FindPetById request
	FindPetById(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) AddPetWithBodyWithResponse

func (c *ClientWithResponses) AddPetWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddPetResponse, error)

AddPetWithBodyWithResponse request with arbitrary body returning *AddPetResponse

func (*ClientWithResponses) AddPetWithResponse

func (c *ClientWithResponses) AddPetWithResponse(ctx context.Context, body AddPetJSONRequestBody, reqEditors ...RequestEditorFn) (*AddPetResponse, error)

func (*ClientWithResponses) DeletePetWithResponse

func (c *ClientWithResponses) DeletePetWithResponse(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (*DeletePetResponse, error)

DeletePetWithResponse request returning *DeletePetResponse

func (*ClientWithResponses) FindPetByIdWithResponse

func (c *ClientWithResponses) FindPetByIdWithResponse(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (*FindPetByIdResponse, error)

FindPetByIdWithResponse request returning *FindPetByIdResponse

func (*ClientWithResponses) FindPetsWithResponse

func (c *ClientWithResponses) FindPetsWithResponse(ctx context.Context, params *FindPetsParams, reqEditors ...RequestEditorFn) (*FindPetsResponse, error)

FindPetsWithResponse request returning *FindPetsResponse

func (*ClientWithResponses) HealthCheckWithResponse

func (c *ClientWithResponses) HealthCheckWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*HealthCheckResponse, error)

HealthCheckWithResponse request returning *HealthCheckResponse

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// HealthCheck request
	HealthCheckWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*HealthCheckResponse, error)

	// FindPets request
	FindPetsWithResponse(ctx context.Context, params *FindPetsParams, reqEditors ...RequestEditorFn) (*FindPetsResponse, error)

	// AddPet request with any body
	AddPetWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddPetResponse, error)

	AddPetWithResponse(ctx context.Context, body AddPetJSONRequestBody, reqEditors ...RequestEditorFn) (*AddPetResponse, error)

	// DeletePet request
	DeletePetWithResponse(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (*DeletePetResponse, error)

	// FindPetById request
	FindPetByIdWithResponse(ctx context.Context, id int64, reqEditors ...RequestEditorFn) (*FindPetByIdResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type DeletePetResponse

type DeletePetResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSONDefault  *Error
}

func ParseDeletePetResponse

func ParseDeletePetResponse(rsp *http.Response) (*DeletePetResponse, error)

ParseDeletePetResponse parses an HTTP response from a DeletePetWithResponse call

func (DeletePetResponse) Status

func (r DeletePetResponse) Status() string

Status returns HTTPResponse.Status

func (DeletePetResponse) StatusCode

func (r DeletePetResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

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 Error

type Error struct {
	Code    int32  `json:"code"`
	Message string `json:"message"`
}

Error defines model for Error.

type FindPetByIdResponse

type FindPetByIdResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *Pet
	JSONDefault  *Error
}

func ParseFindPetByIdResponse

func ParseFindPetByIdResponse(rsp *http.Response) (*FindPetByIdResponse, error)

ParseFindPetByIdResponse parses an HTTP response from a FindPetByIdWithResponse call

func (FindPetByIdResponse) Status

func (r FindPetByIdResponse) Status() string

Status returns HTTPResponse.Status

func (FindPetByIdResponse) StatusCode

func (r FindPetByIdResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

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 FindPetsResponse

type FindPetsResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *[]Pet
	JSONDefault  *Error
}

func ParseFindPetsResponse

func ParseFindPetsResponse(rsp *http.Response) (*FindPetsResponse, error)

ParseFindPetsResponse parses an HTTP response from a FindPetsWithResponse call

func (FindPetsResponse) Status

func (r FindPetsResponse) Status() string

Status returns HTTPResponse.Status

func (FindPetsResponse) StatusCode

func (r FindPetsResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HealthCheckResponse

type HealthCheckResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSONDefault  *Error
}

func ParseHealthCheckResponse

func ParseHealthCheckResponse(rsp *http.Response) (*HealthCheckResponse, error)

ParseHealthCheckResponse parses an HTTP response from a HealthCheckWithResponse call

func (HealthCheckResponse) Status

func (r HealthCheckResponse) Status() string

Status returns HTTPResponse.Status

func (HealthCheckResponse) StatusCode

func (r HealthCheckResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type NewPet

type NewPet struct {
	Name string  `json:"name"`
	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
	Id int64 `json:"id"`
}

Pet defines model for Pet.

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

type ServerInterface

type ServerInterface interface {

	// (GET /)
	HealthCheck(ctx echo.Context) error

	// (GET /pets)
	FindPets(ctx echo.Context, params FindPetsParams) error

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

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

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

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) AddPet

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

AddPet converts echo context to params.

func (*ServerInterfaceWrapper) DeletePet

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

DeletePet converts echo context to params.

func (*ServerInterfaceWrapper) FindPetById

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

FindPetById converts echo context to params.

func (*ServerInterfaceWrapper) FindPets

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

FindPets converts echo context to params.

func (*ServerInterfaceWrapper) HealthCheck

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

HealthCheck converts echo context to params.

Jump to

Keyboard shortcuts

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