server

package
v1.13.4 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

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

Code generated by github.com/deepmap/oapi-codegen version (devel) DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux added in v1.3.4

func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL added in v1.4.0

func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler

func HandlerWithOptions added in v1.4.2

func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

Types

type Argument

type Argument = string

Argument defines model for argument.

type ChiServerOptions added in v1.4.2

type ChiServerOptions struct {
	BaseURL          string
	BaseRouter       chi.Router
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type CreateResource2JSONRequestBody

type CreateResource2JSONRequestBody = Resource

CreateResource2JSONRequestBody defines body for CreateResource2 for application/json ContentType.

type CreateResource2Params

type CreateResource2Params struct {
	// InlineQueryArgument Some query argument
	InlineQueryArgument *int `form:"inline_query_argument,omitempty" json:"inline_query_argument,omitempty"`
}

CreateResource2Params defines parameters for CreateResource2.

type CreateResourceJSONRequestBody

type CreateResourceJSONRequestBody = EveryTypeRequired

CreateResourceJSONRequestBody defines body for CreateResource for application/json ContentType.

type EveryTypeOptional

type EveryTypeOptional struct {
	ArrayInlineField     *[]int              `json:"array_inline_field,omitempty"`
	ArrayReferencedField *[]SomeObject       `json:"array_referenced_field,omitempty"`
	BoolField            *bool               `json:"bool_field,omitempty"`
	ByteField            *[]byte             `json:"byte_field,omitempty"`
	DateField            *openapi_types.Date `json:"date_field,omitempty"`
	DateTimeField        *time.Time          `json:"date_time_field,omitempty"`
	DoubleField          *float64            `json:"double_field,omitempty"`
	FloatField           *float32            `json:"float_field,omitempty"`
	InlineObjectField    *struct {
		Name   string `json:"name"`
		Number int    `json:"number"`
	} `json:"inline_object_field,omitempty"`
	Int32Field      *int32      `json:"int32_field,omitempty"`
	Int64Field      *int64      `json:"int64_field,omitempty"`
	IntField        *int        `json:"int_field,omitempty"`
	NumberField     *float32    `json:"number_field,omitempty"`
	ReferencedField *SomeObject `json:"referenced_field,omitempty"`
	StringField     *string     `json:"string_field,omitempty"`
}

EveryTypeOptional defines model for EveryTypeOptional.

type EveryTypeRequired

type EveryTypeRequired struct {
	ArrayInlineField     []int                `json:"array_inline_field"`
	ArrayReferencedField []SomeObject         `json:"array_referenced_field"`
	BoolField            bool                 `json:"bool_field"`
	ByteField            []byte               `json:"byte_field"`
	DateField            openapi_types.Date   `json:"date_field"`
	DateTimeField        time.Time            `json:"date_time_field"`
	DoubleField          float64              `json:"double_field"`
	EmailField           *openapi_types.Email `json:"email_field,omitempty"`
	FloatField           float32              `json:"float_field"`
	InlineObjectField    struct {
		Name   string `json:"name"`
		Number int    `json:"number"`
	} `json:"inline_object_field"`
	Int32Field      int32      `json:"int32_field"`
	Int64Field      int64      `json:"int64_field"`
	IntField        int        `json:"int_field"`
	NumberField     float32    `json:"number_field"`
	ReferencedField SomeObject `json:"referenced_field"`
	StringField     string     `json:"string_field"`
}

EveryTypeRequired defines model for EveryTypeRequired.

type GetWithArgsParams

type GetWithArgsParams struct {
	// OptionalArgument An optional query argument
	OptionalArgument *int64 `form:"optional_argument,omitempty" json:"optional_argument,omitempty"`

	// RequiredArgument An optional query argument
	RequiredArgument int64 `form:"required_argument" json:"required_argument"`

	// HeaderArgument An optional query argument
	HeaderArgument *int32 `json:"header_argument,omitempty"`
}

GetWithArgsParams defines parameters for GetWithArgs.

type GetWithContentTypeParamsContentType added in v1.6.1

type GetWithContentTypeParamsContentType string

GetWithContentTypeParamsContentType defines parameters for GetWithContentType.

Defines values for GetWithContentTypeParamsContentType.

type InvalidParamFormatError added in v1.9.0

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error added in v1.9.0

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap added in v1.9.0

func (e *InvalidParamFormatError) Unwrap() error

type MiddlewareFunc added in v1.4.2

type MiddlewareFunc func(http.Handler) http.Handler

type RequiredHeaderError added in v1.9.0

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error added in v1.9.0

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap added in v1.9.0

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError added in v1.9.0

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error added in v1.9.0

func (e *RequiredParamError) Error() string

type ReservedKeyword

type ReservedKeyword struct {
	Channel *string `json:"channel,omitempty"`
}

ReservedKeyword defines model for ReservedKeyword.

type Resource

type Resource struct {
	Name  string  `json:"name"`
	Value float32 `json:"value"`
}

Resource defines model for Resource.

type ResponseWithReference

type ResponseWithReference = SomeObject

ResponseWithReference defines model for ResponseWithReference.

type ServerInterface

type ServerInterface interface {
	// get every type optional
	// (GET /every-type-optional)
	GetEveryTypeOptional(w http.ResponseWriter, r *http.Request)
	// Get resource via simple path
	// (GET /get-simple)
	GetSimple(w http.ResponseWriter, r *http.Request)
	// Getter with referenced parameter and referenced response
	// (GET /get-with-args)
	GetWithArgs(w http.ResponseWriter, r *http.Request, params GetWithArgsParams)
	// Getter with referenced parameter and referenced response
	// (GET /get-with-references/{global_argument}/{argument})
	GetWithReferences(w http.ResponseWriter, r *http.Request, globalArgument int64, argument Argument)
	// Get an object by ID
	// (GET /get-with-type/{content_type})
	GetWithContentType(w http.ResponseWriter, r *http.Request, contentType GetWithContentTypeParamsContentType)
	// get with reserved keyword
	// (GET /reserved-keyword)
	GetReservedKeyword(w http.ResponseWriter, r *http.Request)
	// Create a resource
	// (POST /resource/{argument})
	CreateResource(w http.ResponseWriter, r *http.Request, argument Argument)
	// Create a resource with inline parameter
	// (POST /resource2/{inline_argument})
	CreateResource2(w http.ResponseWriter, r *http.Request, inlineArgument int, params CreateResource2Params)
	// Update a resource with inline body. The parameter name is a reserved
	// keyword, so make sure that gets prefixed to avoid syntax errors
	// (PUT /resource3/{fallthrough})
	UpdateResource3(w http.ResponseWriter, r *http.Request, pFallthrough int)
	// get response with reference
	// (GET /response-with-reference)
	GetResponseWithReference(w http.ResponseWriter, r *http.Request)
}

ServerInterface represents all server handlers.

type ServerInterfaceMock

type ServerInterfaceMock struct {
	// CreateResourceFunc mocks the CreateResource method.
	CreateResourceFunc func(w http.ResponseWriter, r *http.Request, argument string)

	// CreateResource2Func mocks the CreateResource2 method.
	CreateResource2Func func(w http.ResponseWriter, r *http.Request, inlineArgument int, params CreateResource2Params)

	// GetEveryTypeOptionalFunc mocks the GetEveryTypeOptional method.
	GetEveryTypeOptionalFunc func(w http.ResponseWriter, r *http.Request)

	// GetReservedKeywordFunc mocks the GetReservedKeyword method.
	GetReservedKeywordFunc func(w http.ResponseWriter, r *http.Request)

	// GetResponseWithReferenceFunc mocks the GetResponseWithReference method.
	GetResponseWithReferenceFunc func(w http.ResponseWriter, r *http.Request)

	// GetSimpleFunc mocks the GetSimple method.
	GetSimpleFunc func(w http.ResponseWriter, r *http.Request)

	// GetWithArgsFunc mocks the GetWithArgs method.
	GetWithArgsFunc func(w http.ResponseWriter, r *http.Request, params GetWithArgsParams)

	// GetWithContentTypeFunc mocks the GetWithContentType method.
	GetWithContentTypeFunc func(w http.ResponseWriter, r *http.Request, contentType GetWithContentTypeParamsContentType)

	// GetWithReferencesFunc mocks the GetWithReferences method.
	GetWithReferencesFunc func(w http.ResponseWriter, r *http.Request, globalArgument int64, argument string)

	// UpdateResource3Func mocks the UpdateResource3 method.
	UpdateResource3Func func(w http.ResponseWriter, r *http.Request, pFallthrough int)
	// contains filtered or unexported fields
}

ServerInterfaceMock is a mock implementation of ServerInterface.

func TestSomethingThatUsesServerInterface(t *testing.T) {

	// make and configure a mocked ServerInterface
	mockedServerInterface := &ServerInterfaceMock{
		CreateResourceFunc: func(w http.ResponseWriter, r *http.Request, argument string)  {
			panic("mock out the CreateResource method")
		},
		CreateResource2Func: func(w http.ResponseWriter, r *http.Request, inlineArgument int, params CreateResource2Params)  {
			panic("mock out the CreateResource2 method")
		},
		GetEveryTypeOptionalFunc: func(w http.ResponseWriter, r *http.Request)  {
			panic("mock out the GetEveryTypeOptional method")
		},
		GetReservedKeywordFunc: func(w http.ResponseWriter, r *http.Request)  {
			panic("mock out the GetReservedKeyword method")
		},
		GetResponseWithReferenceFunc: func(w http.ResponseWriter, r *http.Request)  {
			panic("mock out the GetResponseWithReference method")
		},
		GetSimpleFunc: func(w http.ResponseWriter, r *http.Request)  {
			panic("mock out the GetSimple method")
		},
		GetWithArgsFunc: func(w http.ResponseWriter, r *http.Request, params GetWithArgsParams)  {
			panic("mock out the GetWithArgs method")
		},
		GetWithContentTypeFunc: func(w http.ResponseWriter, r *http.Request, contentType GetWithContentTypeParamsContentType)  {
			panic("mock out the GetWithContentType method")
		},
		GetWithReferencesFunc: func(w http.ResponseWriter, r *http.Request, globalArgument int64, argument string)  {
			panic("mock out the GetWithReferences method")
		},
		UpdateResource3Func: func(w http.ResponseWriter, r *http.Request, pFallthrough int)  {
			panic("mock out the UpdateResource3 method")
		},
	}

	// use mockedServerInterface in code that requires ServerInterface
	// and then make assertions.

}

func (*ServerInterfaceMock) CreateResource

func (mock *ServerInterfaceMock) CreateResource(w http.ResponseWriter, r *http.Request, argument string)

CreateResource calls CreateResourceFunc.

func (*ServerInterfaceMock) CreateResource2

func (mock *ServerInterfaceMock) CreateResource2(w http.ResponseWriter, r *http.Request, inlineArgument int, params CreateResource2Params)

CreateResource2 calls CreateResource2Func.

func (*ServerInterfaceMock) CreateResource2Calls

func (mock *ServerInterfaceMock) CreateResource2Calls() []struct {
	W              http.ResponseWriter
	R              *http.Request
	InlineArgument int
	Params         CreateResource2Params
}

CreateResource2Calls gets all the calls that were made to CreateResource2. Check the length with:

len(mockedServerInterface.CreateResource2Calls())

func (*ServerInterfaceMock) CreateResourceCalls

func (mock *ServerInterfaceMock) CreateResourceCalls() []struct {
	W        http.ResponseWriter
	R        *http.Request
	Argument string
}

CreateResourceCalls gets all the calls that were made to CreateResource. Check the length with:

len(mockedServerInterface.CreateResourceCalls())

func (*ServerInterfaceMock) GetEveryTypeOptional added in v1.3.7

func (mock *ServerInterfaceMock) GetEveryTypeOptional(w http.ResponseWriter, r *http.Request)

GetEveryTypeOptional calls GetEveryTypeOptionalFunc.

func (*ServerInterfaceMock) GetEveryTypeOptionalCalls added in v1.3.7

func (mock *ServerInterfaceMock) GetEveryTypeOptionalCalls() []struct {
	W http.ResponseWriter
	R *http.Request
}

GetEveryTypeOptionalCalls gets all the calls that were made to GetEveryTypeOptional. Check the length with:

len(mockedServerInterface.GetEveryTypeOptionalCalls())

func (*ServerInterfaceMock) GetReservedKeyword added in v1.3.7

func (mock *ServerInterfaceMock) GetReservedKeyword(w http.ResponseWriter, r *http.Request)

GetReservedKeyword calls GetReservedKeywordFunc.

func (*ServerInterfaceMock) GetReservedKeywordCalls added in v1.3.7

func (mock *ServerInterfaceMock) GetReservedKeywordCalls() []struct {
	W http.ResponseWriter
	R *http.Request
}

GetReservedKeywordCalls gets all the calls that were made to GetReservedKeyword. Check the length with:

len(mockedServerInterface.GetReservedKeywordCalls())

func (*ServerInterfaceMock) GetResponseWithReference added in v1.3.7

func (mock *ServerInterfaceMock) GetResponseWithReference(w http.ResponseWriter, r *http.Request)

GetResponseWithReference calls GetResponseWithReferenceFunc.

func (*ServerInterfaceMock) GetResponseWithReferenceCalls added in v1.3.7

func (mock *ServerInterfaceMock) GetResponseWithReferenceCalls() []struct {
	W http.ResponseWriter
	R *http.Request
}

GetResponseWithReferenceCalls gets all the calls that were made to GetResponseWithReference. Check the length with:

len(mockedServerInterface.GetResponseWithReferenceCalls())

func (*ServerInterfaceMock) GetSimple

func (mock *ServerInterfaceMock) GetSimple(w http.ResponseWriter, r *http.Request)

GetSimple calls GetSimpleFunc.

func (*ServerInterfaceMock) GetSimpleCalls

func (mock *ServerInterfaceMock) GetSimpleCalls() []struct {
	W http.ResponseWriter
	R *http.Request
}

GetSimpleCalls gets all the calls that were made to GetSimple. Check the length with:

len(mockedServerInterface.GetSimpleCalls())

func (*ServerInterfaceMock) GetWithArgs

func (mock *ServerInterfaceMock) GetWithArgs(w http.ResponseWriter, r *http.Request, params GetWithArgsParams)

GetWithArgs calls GetWithArgsFunc.

func (*ServerInterfaceMock) GetWithArgsCalls

func (mock *ServerInterfaceMock) GetWithArgsCalls() []struct {
	W      http.ResponseWriter
	R      *http.Request
	Params GetWithArgsParams
}

GetWithArgsCalls gets all the calls that were made to GetWithArgs. Check the length with:

len(mockedServerInterface.GetWithArgsCalls())

func (*ServerInterfaceMock) GetWithContentType

func (mock *ServerInterfaceMock) GetWithContentType(w http.ResponseWriter, r *http.Request, contentType GetWithContentTypeParamsContentType)

GetWithContentType calls GetWithContentTypeFunc.

func (*ServerInterfaceMock) GetWithContentTypeCalls

func (mock *ServerInterfaceMock) GetWithContentTypeCalls() []struct {
	W           http.ResponseWriter
	R           *http.Request
	ContentType GetWithContentTypeParamsContentType
}

GetWithContentTypeCalls gets all the calls that were made to GetWithContentType. Check the length with:

len(mockedServerInterface.GetWithContentTypeCalls())

func (*ServerInterfaceMock) GetWithReferences

func (mock *ServerInterfaceMock) GetWithReferences(w http.ResponseWriter, r *http.Request, globalArgument int64, argument string)

GetWithReferences calls GetWithReferencesFunc.

func (*ServerInterfaceMock) GetWithReferencesCalls

func (mock *ServerInterfaceMock) GetWithReferencesCalls() []struct {
	W              http.ResponseWriter
	R              *http.Request
	GlobalArgument int64
	Argument       string
}

GetWithReferencesCalls gets all the calls that were made to GetWithReferences. Check the length with:

len(mockedServerInterface.GetWithReferencesCalls())

func (*ServerInterfaceMock) UpdateResource3

func (mock *ServerInterfaceMock) UpdateResource3(w http.ResponseWriter, r *http.Request, pFallthrough int)

UpdateResource3 calls UpdateResource3Func.

func (*ServerInterfaceMock) UpdateResource3Calls

func (mock *ServerInterfaceMock) UpdateResource3Calls() []struct {
	W            http.ResponseWriter
	R            *http.Request
	PFallthrough int
}

UpdateResource3Calls gets all the calls that were made to UpdateResource3. Check the length with:

len(mockedServerInterface.UpdateResource3Calls())

type ServerInterfaceWrapper added in v1.3.10

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) CreateResource added in v1.3.10

func (siw *ServerInterfaceWrapper) CreateResource(w http.ResponseWriter, r *http.Request)

CreateResource operation middleware

func (*ServerInterfaceWrapper) CreateResource2 added in v1.3.10

func (siw *ServerInterfaceWrapper) CreateResource2(w http.ResponseWriter, r *http.Request)

CreateResource2 operation middleware

func (*ServerInterfaceWrapper) GetEveryTypeOptional added in v1.3.10

func (siw *ServerInterfaceWrapper) GetEveryTypeOptional(w http.ResponseWriter, r *http.Request)

GetEveryTypeOptional operation middleware

func (*ServerInterfaceWrapper) GetReservedKeyword added in v1.3.10

func (siw *ServerInterfaceWrapper) GetReservedKeyword(w http.ResponseWriter, r *http.Request)

GetReservedKeyword operation middleware

func (*ServerInterfaceWrapper) GetResponseWithReference added in v1.3.10

func (siw *ServerInterfaceWrapper) GetResponseWithReference(w http.ResponseWriter, r *http.Request)

GetResponseWithReference operation middleware

func (*ServerInterfaceWrapper) GetSimple added in v1.3.10

func (siw *ServerInterfaceWrapper) GetSimple(w http.ResponseWriter, r *http.Request)

GetSimple operation middleware

func (*ServerInterfaceWrapper) GetWithArgs added in v1.3.10

func (siw *ServerInterfaceWrapper) GetWithArgs(w http.ResponseWriter, r *http.Request)

GetWithArgs operation middleware

func (*ServerInterfaceWrapper) GetWithContentType added in v1.3.10

func (siw *ServerInterfaceWrapper) GetWithContentType(w http.ResponseWriter, r *http.Request)

GetWithContentType operation middleware

func (*ServerInterfaceWrapper) GetWithReferences added in v1.3.10

func (siw *ServerInterfaceWrapper) GetWithReferences(w http.ResponseWriter, r *http.Request)

GetWithReferences operation middleware

func (*ServerInterfaceWrapper) UpdateResource3 added in v1.3.10

func (siw *ServerInterfaceWrapper) UpdateResource3(w http.ResponseWriter, r *http.Request)

UpdateResource3 operation middleware

type SimpleResponse

type SimpleResponse struct {
	Name string `json:"name"`
}

SimpleResponse defines model for SimpleResponse.

type SomeObject

type SomeObject struct {
	Name string `json:"name"`
}

SomeObject defines model for some_object.

type TooManyValuesForParamError added in v1.9.0

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error added in v1.9.0

type UnescapedCookieParamError added in v1.9.0

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error added in v1.9.0

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap added in v1.9.0

func (e *UnescapedCookieParamError) Unwrap() error

type Unimplemented added in v1.13.1

type Unimplemented struct{}

func (Unimplemented) CreateResource added in v1.13.1

func (_ Unimplemented) CreateResource(w http.ResponseWriter, r *http.Request, argument Argument)

Create a resource (POST /resource/{argument})

func (Unimplemented) CreateResource2 added in v1.13.1

func (_ Unimplemented) CreateResource2(w http.ResponseWriter, r *http.Request, inlineArgument int, params CreateResource2Params)

Create a resource with inline parameter (POST /resource2/{inline_argument})

func (Unimplemented) GetEveryTypeOptional added in v1.13.1

func (_ Unimplemented) GetEveryTypeOptional(w http.ResponseWriter, r *http.Request)

get every type optional (GET /every-type-optional)

func (Unimplemented) GetReservedKeyword added in v1.13.1

func (_ Unimplemented) GetReservedKeyword(w http.ResponseWriter, r *http.Request)

get with reserved keyword (GET /reserved-keyword)

func (Unimplemented) GetResponseWithReference added in v1.13.1

func (_ Unimplemented) GetResponseWithReference(w http.ResponseWriter, r *http.Request)

get response with reference (GET /response-with-reference)

func (Unimplemented) GetSimple added in v1.13.1

func (_ Unimplemented) GetSimple(w http.ResponseWriter, r *http.Request)

Get resource via simple path (GET /get-simple)

func (Unimplemented) GetWithArgs added in v1.13.1

func (_ Unimplemented) GetWithArgs(w http.ResponseWriter, r *http.Request, params GetWithArgsParams)

Getter with referenced parameter and referenced response (GET /get-with-args)

func (Unimplemented) GetWithContentType added in v1.13.1

func (_ Unimplemented) GetWithContentType(w http.ResponseWriter, r *http.Request, contentType GetWithContentTypeParamsContentType)

Get an object by ID (GET /get-with-type/{content_type})

func (Unimplemented) GetWithReferences added in v1.13.1

func (_ Unimplemented) GetWithReferences(w http.ResponseWriter, r *http.Request, globalArgument int64, argument Argument)

Getter with referenced parameter and referenced response (GET /get-with-references/{global_argument}/{argument})

func (Unimplemented) UpdateResource3 added in v1.13.1

func (_ Unimplemented) UpdateResource3(w http.ResponseWriter, r *http.Request, pFallthrough int)

Update a resource with inline body. The parameter name is a reserved keyword, so make sure that gets prefixed to avoid syntax errors (PUT /resource3/{fallthrough})

type UnmarshalingParamError added in v1.9.0

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error added in v1.9.0

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap added in v1.9.0

func (e *UnmarshalingParamError) Unwrap() error

type UpdateResource3JSONBody added in v1.3.4

type UpdateResource3JSONBody struct {
	Id   *int    `json:"id,omitempty"`
	Name *string `json:"name,omitempty"`
}

UpdateResource3JSONBody defines parameters for UpdateResource3.

type UpdateResource3JSONRequestBody

type UpdateResource3JSONRequestBody UpdateResource3JSONBody

UpdateResource3JSONRequestBody defines body for UpdateResource3 for application/json ContentType.

Jump to

Keyboard shortcuts

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