api

package
v1.9.18 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: Apache-2.0 Imports: 17 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 NewAddPetRequest added in v1.9.9

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

NewAddPetRequest calls the generic AddPet builder with application/json body

func NewAddPetRequestWithBody added in v1.9.9

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

NewAddPetRequestWithBody generates requests for AddPet with any type of body

func NewDeletePetRequest added in v1.9.9

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

NewDeletePetRequest generates requests for DeletePet

func NewFindPetByIDRequest added in v1.9.9

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

NewFindPetByIDRequest generates requests for FindPetByID

func NewFindPetsRequest added in v1.9.9

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

NewFindPetsRequest generates requests for FindPets

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 AddPetResponse added in v1.9.9

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

func ParseAddPetResponse added in v1.9.9

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

ParseAddPetResponse parses an HTTP response from a AddPetWithResponse call

func (AddPetResponse) Status added in v1.9.9

func (r AddPetResponse) Status() string

Status returns HTTPResponse.Status

func (AddPetResponse) StatusCode added in v1.9.9

func (r AddPetResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type Client added in v1.9.9

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 added in v1.9.9

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

Creates a new Client, with reasonable defaults

func (*Client) AddPet added in v1.9.9

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

func (*Client) AddPetWithBody added in v1.9.9

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

func (*Client) DeletePet added in v1.9.9

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

func (*Client) FindPetByID added in v1.9.9

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

func (*Client) FindPets added in v1.9.9

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

type ClientInterface added in v1.9.9

type ClientInterface interface {
	// FindPets request
	FindPets(ctx context.Context, params *models.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 models.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 added in v1.9.9

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL added in v1.9.9

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient added in v1.9.9

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 added in v1.9.9

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 added in v1.9.9

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses added in v1.9.9

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

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

func (*ClientWithResponses) AddPetWithBodyWithResponse added in v1.9.9

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 added in v1.9.9

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

func (*ClientWithResponses) DeletePetWithResponse added in v1.9.9

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

DeletePetWithResponse request returning *DeletePetResponse

func (*ClientWithResponses) FindPetByIDWithResponse added in v1.9.9

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

FindPetByIDWithResponse request returning *FindPetByIDResponse

func (*ClientWithResponses) FindPetsWithResponse added in v1.9.9

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

FindPetsWithResponse request returning *FindPetsResponse

type ClientWithResponsesInterface added in v1.9.9

type ClientWithResponsesInterface interface {
	// FindPets request
	FindPetsWithResponse(ctx context.Context, params *models.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 models.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 added in v1.9.9

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

func ParseDeletePetResponse added in v1.9.9

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

ParseDeletePetResponse parses an HTTP response from a DeletePetWithResponse call

func (DeletePetResponse) Status added in v1.9.9

func (r DeletePetResponse) Status() string

Status returns HTTPResponse.Status

func (DeletePetResponse) StatusCode added in v1.9.9

func (r DeletePetResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

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 FindPetByIDResponse added in v1.9.9

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

func ParseFindPetByIDResponse added in v1.9.9

func ParseFindPetByIDResponse(rsp *http.Response) (*FindPetByIDResponse, error)

ParseFindPetByIDResponse parses an HTTP response from a FindPetByIDWithResponse call

func (FindPetByIDResponse) Status added in v1.9.9

func (r FindPetByIDResponse) Status() string

Status returns HTTPResponse.Status

func (FindPetByIDResponse) StatusCode added in v1.9.9

func (r FindPetByIDResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type FindPetsResponse added in v1.9.9

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

func ParseFindPetsResponse added in v1.9.9

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

ParseFindPetsResponse parses an HTTP response from a FindPetsWithResponse call

func (FindPetsResponse) Status added in v1.9.9

func (r FindPetsResponse) Status() string

Status returns HTTPResponse.Status

func (FindPetsResponse) StatusCode added in v1.9.9

func (r FindPetsResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HttpRequestDoer added in v1.9.9

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

Doer performs HTTP requests.

The standard http.Client implements this interface.

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 RequestEditorFn added in v1.9.9

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 {
	// 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