multijson

package
v0.0.0-...-00a6948 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

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

Code generated by github.com/jKiler/oapi-codegen version v1.0.0-00010101000000-000000000000 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 NewTestRequest

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

NewTestRequest generates requests for Test

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 gin.IRouter, si ServerInterface)

RegisterHandlers creates http.Handler with routing matching OpenAPI spec.

func RegisterHandlersWithOptions

func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options GinServerOptions)

RegisterHandlersWithOptions creates http.Handler with additional options

Types

type Bar

type Bar struct {
	Field2 *string `json:"field2,omitempty"`
}

Bar defines model for bar.

type BazApplicationBarPlusJSON

type BazApplicationBarPlusJSON = Bar

BazApplicationBarPlusJSON defines model for baz.

type BazApplicationBarPlusJSONResponse

type BazApplicationBarPlusJSONResponse Bar

type BazApplicationFooPlusJSON

type BazApplicationFooPlusJSON = Foo

BazApplicationFooPlusJSON defines model for baz.

type BazApplicationFooPlusJSONResponse

type BazApplicationFooPlusJSONResponse Foo

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) Test

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

type ClientInterface

type ClientInterface interface {
	// Test request
	Test(ctx context.Context, 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) TestWithResponse

func (c *ClientWithResponses) TestWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*TestResponse, error)

TestWithResponse request returning *TestResponse

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// TestWithResponse request
	TestWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*TestResponse, error)
}

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

type Foo

type Foo struct {
	Field1 *string `json:"field1,omitempty"`
}

Foo defines model for foo.

type GinServerOptions

type GinServerOptions struct {
	BaseURL      string
	Middlewares  []MiddlewareFunc
	ErrorHandler func(*gin.Context, error, int)
}

GinServerOptions provides options for the Gin server.

type HttpRequestDoer

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

Doer performs HTTP requests.

The standard http.Client implements this interface.

type MiddlewareFunc

type MiddlewareFunc func(c *gin.Context)

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 /test)
	Test(c *gin.Context)
}

ServerInterface represents all server handlers.

func NewStrictHandler

func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandler       func(*gin.Context, error, int)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) Test

func (siw *ServerInterfaceWrapper) Test(c *gin.Context)

Test operation middleware

type StrictHandlerFunc

type StrictHandlerFunc = strictgin.StrictGinHandlerFunc

type StrictMiddlewareFunc

type StrictMiddlewareFunc = strictgin.StrictGinMiddlewareFunc

type StrictServerInterface

type StrictServerInterface interface {

	// (GET /test)
	Test(ctx context.Context, request TestRequestObject) (TestResponseObject, error)
}

StrictServerInterface represents all server handlers.

type Test200ApplicationBarPlusJSONResponse

type Test200ApplicationBarPlusJSONResponse Bar

func (Test200ApplicationBarPlusJSONResponse) VisitTestResponse

func (response Test200ApplicationBarPlusJSONResponse) VisitTestResponse(w http.ResponseWriter) error

type Test200ApplicationFooPlusJSONResponse

type Test200ApplicationFooPlusJSONResponse Foo

func (Test200ApplicationFooPlusJSONResponse) VisitTestResponse

func (response Test200ApplicationFooPlusJSONResponse) VisitTestResponse(w http.ResponseWriter) error

type Test201ApplicationBarPlusJSONResponse

type Test201ApplicationBarPlusJSONResponse struct {
	BazApplicationBarPlusJSONResponse
}

func (Test201ApplicationBarPlusJSONResponse) VisitTestResponse

func (response Test201ApplicationBarPlusJSONResponse) VisitTestResponse(w http.ResponseWriter) error

type Test201ApplicationFooPlusJSONResponse

type Test201ApplicationFooPlusJSONResponse struct {
	BazApplicationFooPlusJSONResponse
}

func (Test201ApplicationFooPlusJSONResponse) VisitTestResponse

func (response Test201ApplicationFooPlusJSONResponse) VisitTestResponse(w http.ResponseWriter) error

type TestRequestObject

type TestRequestObject struct {
}

type TestResponse

type TestResponse struct {
	Body                  []byte
	HTTPResponse          *http.Response
	ApplicationbarJSON200 *Bar
	ApplicationfooJSON200 *Foo
	ApplicationbarJSON201 *BazApplicationBarPlusJSON
	ApplicationfooJSON201 *BazApplicationFooPlusJSON
}

func ParseTestResponse

func ParseTestResponse(rsp *http.Response) (*TestResponse, error)

ParseTestResponse parses an HTTP response from a TestWithResponse call

func (TestResponse) Status

func (r TestResponse) Status() string

Status returns HTTPResponse.Status

func (TestResponse) StatusCode

func (r TestResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type TestResponseObject

type TestResponseObject interface {
	VisitTestResponse(w http.ResponseWriter) error
}

Jump to

Keyboard shortcuts

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