components

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

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

Code generated by github.com/discord-gophers/goapi-gen 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 Handler

func Handler(si ServerInterface, opts ...ServerOption) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

Types

type AdditionalPropertiesObject1

type AdditionalPropertiesObject1 struct {
	ID                   int            `json:"id"`
	Name                 string         `json:"name"`
	Optional             *string        `json:"optional,omitempty"`
	AdditionalProperties map[string]int `json:"-"`
}

Has additional properties of type int

func (AdditionalPropertiesObject1) Get

func (a AdditionalPropertiesObject1) Get(fieldName string) (value int, found bool)

Getter for additional properties for AdditionalPropertiesObject1. Returns the specified element and whether it was found

func (AdditionalPropertiesObject1) MarshalJSON

func (a AdditionalPropertiesObject1) MarshalJSON() ([]byte, error)

Override default JSON handling for AdditionalPropertiesObject1 to handle AdditionalProperties

func (*AdditionalPropertiesObject1) Set

func (a *AdditionalPropertiesObject1) Set(fieldName string, value int)

Setter for additional properties for AdditionalPropertiesObject1

func (*AdditionalPropertiesObject1) UnmarshalJSON

func (a *AdditionalPropertiesObject1) UnmarshalJSON(b []byte) error

Override default JSON handling for AdditionalPropertiesObject1 to handle AdditionalProperties

type AdditionalPropertiesObject2

type AdditionalPropertiesObject2 struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

Does not allow additional properties

type AdditionalPropertiesObject3

type AdditionalPropertiesObject3 struct {
	Name                 string                 `json:"name"`
	AdditionalProperties map[string]interface{} `json:"-"`
}

Allows any additional property

func (AdditionalPropertiesObject3) Get

func (a AdditionalPropertiesObject3) Get(fieldName string) (value interface{}, found bool)

Getter for additional properties for AdditionalPropertiesObject3. Returns the specified element and whether it was found

func (AdditionalPropertiesObject3) MarshalJSON

func (a AdditionalPropertiesObject3) MarshalJSON() ([]byte, error)

Override default JSON handling for AdditionalPropertiesObject3 to handle AdditionalProperties

func (*AdditionalPropertiesObject3) Set

func (a *AdditionalPropertiesObject3) Set(fieldName string, value interface{})

Setter for additional properties for AdditionalPropertiesObject3

func (*AdditionalPropertiesObject3) UnmarshalJSON

func (a *AdditionalPropertiesObject3) UnmarshalJSON(b []byte) error

Override default JSON handling for AdditionalPropertiesObject3 to handle AdditionalProperties

type AdditionalPropertiesObject4

type AdditionalPropertiesObject4 struct {
	Inner                AdditionalPropertiesObject4_Inner `json:"inner"`
	Name                 string                            `json:"name"`
	AdditionalProperties map[string]interface{}            `json:"-"`
}

Has anonymous field which has additional properties

func (AdditionalPropertiesObject4) Get

func (a AdditionalPropertiesObject4) Get(fieldName string) (value interface{}, found bool)

Getter for additional properties for AdditionalPropertiesObject4. Returns the specified element and whether it was found

func (AdditionalPropertiesObject4) MarshalJSON

func (a AdditionalPropertiesObject4) MarshalJSON() ([]byte, error)

Override default JSON handling for AdditionalPropertiesObject4 to handle AdditionalProperties

func (*AdditionalPropertiesObject4) Set

func (a *AdditionalPropertiesObject4) Set(fieldName string, value interface{})

Setter for additional properties for AdditionalPropertiesObject4

func (*AdditionalPropertiesObject4) UnmarshalJSON

func (a *AdditionalPropertiesObject4) UnmarshalJSON(b []byte) error

Override default JSON handling for AdditionalPropertiesObject4 to handle AdditionalProperties

type AdditionalPropertiesObject4_Inner

type AdditionalPropertiesObject4_Inner struct {
	Name                 string                 `json:"name"`
	AdditionalProperties map[string]interface{} `json:"-"`
}

AdditionalPropertiesObject4_Inner defines model for AdditionalPropertiesObject4.Inner.

func (AdditionalPropertiesObject4_Inner) Get

func (a AdditionalPropertiesObject4_Inner) Get(fieldName string) (value interface{}, found bool)

Getter for additional properties for AdditionalPropertiesObject4_Inner. Returns the specified element and whether it was found

func (AdditionalPropertiesObject4_Inner) MarshalJSON

func (a AdditionalPropertiesObject4_Inner) MarshalJSON() ([]byte, error)

Override default JSON handling for AdditionalPropertiesObject4_Inner to handle AdditionalProperties

func (*AdditionalPropertiesObject4_Inner) Set

func (a *AdditionalPropertiesObject4_Inner) Set(fieldName string, value interface{})

Setter for additional properties for AdditionalPropertiesObject4_Inner

func (*AdditionalPropertiesObject4_Inner) UnmarshalJSON

func (a *AdditionalPropertiesObject4_Inner) UnmarshalJSON(b []byte) error

Override default JSON handling for AdditionalPropertiesObject4_Inner to handle AdditionalProperties

type AdditionalPropertiesObject5

type AdditionalPropertiesObject5 struct {
	AdditionalProperties map[string]SchemaObject `json:"-"`
}

Has additional properties with schema for dictionaries

func (AdditionalPropertiesObject5) Get

func (a AdditionalPropertiesObject5) Get(fieldName string) (value SchemaObject, found bool)

Getter for additional properties for AdditionalPropertiesObject5. Returns the specified element and whether it was found

func (AdditionalPropertiesObject5) MarshalJSON

func (a AdditionalPropertiesObject5) MarshalJSON() ([]byte, error)

Override default JSON handling for AdditionalPropertiesObject5 to handle AdditionalProperties

func (*AdditionalPropertiesObject5) Set

func (a *AdditionalPropertiesObject5) Set(fieldName string, value SchemaObject)

Setter for additional properties for AdditionalPropertiesObject5

func (*AdditionalPropertiesObject5) UnmarshalJSON

func (a *AdditionalPropertiesObject5) UnmarshalJSON(b []byte) error

Override default JSON handling for AdditionalPropertiesObject5 to handle AdditionalProperties

type BodyWithAddPropsJSONBody

type BodyWithAddPropsJSONBody struct {
	Inner                BodyWithAddPropsJSONBody_Inner `json:"inner"`
	Name                 string                         `json:"name"`
	AdditionalProperties map[string]interface{}         `json:"-"`
}

BodyWithAddPropsJSONBody defines parameters for BodyWithAddProps.

func (BodyWithAddPropsJSONBody) Get

func (a BodyWithAddPropsJSONBody) Get(fieldName string) (value interface{}, found bool)

Getter for additional properties for BodyWithAddPropsJSONBody. Returns the specified element and whether it was found

func (BodyWithAddPropsJSONBody) MarshalJSON

func (a BodyWithAddPropsJSONBody) MarshalJSON() ([]byte, error)

Override default JSON handling for BodyWithAddPropsJSONBody to handle AdditionalProperties

func (*BodyWithAddPropsJSONBody) Set

func (a *BodyWithAddPropsJSONBody) Set(fieldName string, value interface{})

Setter for additional properties for BodyWithAddPropsJSONBody

func (*BodyWithAddPropsJSONBody) UnmarshalJSON

func (a *BodyWithAddPropsJSONBody) UnmarshalJSON(b []byte) error

Override default JSON handling for BodyWithAddPropsJSONBody to handle AdditionalProperties

type BodyWithAddPropsJSONBody_Inner

type BodyWithAddPropsJSONBody_Inner struct {
	AdditionalProperties map[string]int `json:"-"`
}

BodyWithAddPropsJSONBody_Inner defines parameters for BodyWithAddProps.

func (BodyWithAddPropsJSONBody_Inner) Get

func (a BodyWithAddPropsJSONBody_Inner) Get(fieldName string) (value int, found bool)

Getter for additional properties for BodyWithAddPropsJSONBody_Inner. Returns the specified element and whether it was found

func (BodyWithAddPropsJSONBody_Inner) MarshalJSON

func (a BodyWithAddPropsJSONBody_Inner) MarshalJSON() ([]byte, error)

Override default JSON handling for BodyWithAddPropsJSONBody_Inner to handle AdditionalProperties

func (*BodyWithAddPropsJSONBody_Inner) Set

func (a *BodyWithAddPropsJSONBody_Inner) Set(fieldName string, value int)

Setter for additional properties for BodyWithAddPropsJSONBody_Inner

func (*BodyWithAddPropsJSONBody_Inner) UnmarshalJSON

func (a *BodyWithAddPropsJSONBody_Inner) UnmarshalJSON(b []byte) error

Override default JSON handling for BodyWithAddPropsJSONBody_Inner to handle AdditionalProperties

type BodyWithAddPropsJSONRequestBody

type BodyWithAddPropsJSONRequestBody BodyWithAddPropsJSONBody

BodyWithAddPropsJSONRequestBody defines body for BodyWithAddProps for application/json ContentType.

func (BodyWithAddPropsJSONRequestBody) Bind

Bind implements render.Binder.

type EnsureEverythingIsReferencedJSONRequestBody

type EnsureEverythingIsReferencedJSONRequestBody RequestBody

EnsureEverythingIsReferencedJSONRequestBody defines body for EnsureEverythingIsReferenced for application/json ContentType.

func (EnsureEverythingIsReferencedJSONRequestBody) Bind

Bind implements render.Binder.

type GoStringTag added in v0.2.0

type GoStringTag struct {
	ID   int    `json:"id,string"`
	Name string `json:"name"`
}

Tests x-go-string

type InvalidParamFormatError

type InvalidParamFormatError struct {
	// contains filtered or unexported fields
}

func (InvalidParamFormatError) Error added in v0.2.0

func (err InvalidParamFormatError) Error() string

Error implements error.

func (InvalidParamFormatError) ParamName added in v0.2.0

func (err InvalidParamFormatError) ParamName() string

func (InvalidParamFormatError) Unwrap added in v0.2.0

func (err InvalidParamFormatError) Unwrap() error

type ObjectWithJSONField

type ObjectWithJSONField struct {
	Name   string          `json:"name"`
	Value1 json.RawMessage `json:"value1"`
	Value2 json.RawMessage `json:"value2,omitempty"`
}

ObjectWithJSONField defines model for ObjectWithJsonField.

type OptionalObject added in v0.2.0

type OptionalObject struct {
	Str1    string  `json:"str1,omitempty"`
	Str2    string  `json:"str2,omitempty"`
	StrPtr1 *string `json:"str_ptr1,omitempty"`
	StrPtr2 *string `json:"str_ptr2,omitempty"`
}

Tests x-go-optional-value on the whole object

type OptionalValue added in v0.2.0

type OptionalValue struct {
	Str1 string `json:"str1,omitempty"`
	Str2 string `json:"str2,omitempty"`
}

Tests x-go-optional-value

type ParameterError added in v0.2.0

type ParameterError interface {
	error
	// ParamName is the name of the parameter that the error is referring to.
	ParamName() string
}

ParameterName is an interface that is implemented by error types that are relevant to a specific parameter.

type ParamsWithAddPropsParams

type ParamsWithAddPropsParams struct {
	// This parameter has additional properties
	P1 ParamsWithAddPropsParams_P1 `json:"p1"`

	// This parameter has an anonymous inner property which needs to be
	// turned into a proper type for additionalProperties to work
	P2 struct {
		Inner ParamsWithAddPropsParams_P2_Inner `json:"inner"`
	} `json:"p2"`
}

ParamsWithAddPropsParams defines parameters for ParamsWithAddProps.

type ParamsWithAddPropsParams_P1

type ParamsWithAddPropsParams_P1 struct {
	AdditionalProperties map[string]interface{} `json:"-"`
}

ParamsWithAddPropsParams_P1 defines parameters for ParamsWithAddProps.

func (ParamsWithAddPropsParams_P1) Get

func (a ParamsWithAddPropsParams_P1) Get(fieldName string) (value interface{}, found bool)

Getter for additional properties for ParamsWithAddPropsParams_P1. Returns the specified element and whether it was found

func (ParamsWithAddPropsParams_P1) MarshalJSON

func (a ParamsWithAddPropsParams_P1) MarshalJSON() ([]byte, error)

Override default JSON handling for ParamsWithAddPropsParams_P1 to handle AdditionalProperties

func (*ParamsWithAddPropsParams_P1) Set

func (a *ParamsWithAddPropsParams_P1) Set(fieldName string, value interface{})

Setter for additional properties for ParamsWithAddPropsParams_P1

func (*ParamsWithAddPropsParams_P1) UnmarshalJSON

func (a *ParamsWithAddPropsParams_P1) UnmarshalJSON(b []byte) error

Override default JSON handling for ParamsWithAddPropsParams_P1 to handle AdditionalProperties

type ParamsWithAddPropsParams_P2_Inner

type ParamsWithAddPropsParams_P2_Inner struct {
	AdditionalProperties map[string]string `json:"-"`
}

ParamsWithAddPropsParams_P2_Inner defines parameters for ParamsWithAddProps.

func (ParamsWithAddPropsParams_P2_Inner) Get

func (a ParamsWithAddPropsParams_P2_Inner) Get(fieldName string) (value string, found bool)

Getter for additional properties for ParamsWithAddPropsParams_P2_Inner. Returns the specified element and whether it was found

func (ParamsWithAddPropsParams_P2_Inner) MarshalJSON

func (a ParamsWithAddPropsParams_P2_Inner) MarshalJSON() ([]byte, error)

Override default JSON handling for ParamsWithAddPropsParams_P2_Inner to handle AdditionalProperties

func (*ParamsWithAddPropsParams_P2_Inner) Set

func (a *ParamsWithAddPropsParams_P2_Inner) Set(fieldName string, value string)

Setter for additional properties for ParamsWithAddPropsParams_P2_Inner

func (*ParamsWithAddPropsParams_P2_Inner) UnmarshalJSON

func (a *ParamsWithAddPropsParams_P2_Inner) UnmarshalJSON(b []byte) error

Override default JSON handling for ParamsWithAddPropsParams_P2_Inner to handle AdditionalProperties

type RequestBody

type RequestBody struct {
	Field SchemaObject `json:"Field"`
}

RequestBody defines model for RequestBody.

type RequiredHeaderError

type RequiredHeaderError struct {
	// contains filtered or unexported fields
}

func (RequiredHeaderError) Error added in v0.2.0

func (err RequiredHeaderError) Error() string

Error implements error.

func (RequiredHeaderError) ParamName added in v0.2.0

func (err RequiredHeaderError) ParamName() string

type RequiredParamError

type RequiredParamError struct {
	// contains filtered or unexported fields
}

func (RequiredParamError) Error added in v0.2.0

func (err RequiredParamError) Error() string

Error implements error.

func (RequiredParamError) ParamName added in v0.2.0

func (err RequiredParamError) ParamName() string

func (RequiredParamError) Unwrap added in v0.2.0

func (err RequiredParamError) Unwrap() error

type Response

type Response struct {
	Code int
	// contains filtered or unexported fields
}

Response is a common response struct for all the API calls. A Response object may be instantiated via functions for specific operation responses. It may also be instantiated directly, for the purpose of responding with a single status code.

func EnsureEverythingIsReferencedJSON200Response

func EnsureEverythingIsReferencedJSON200Response(body struct {
	// Has additional properties with schema for dictionaries
	Five *AdditionalPropertiesObject5 `json:"five,omitempty"`

	// Has anonymous field which has additional properties
	Four *AdditionalPropertiesObject4 `json:"four,omitempty"`

	// Tests x-go-string
	GoStringTag *GoStringTag         `json:"goStringTag,omitempty"`
	JSONField   *ObjectWithJSONField `json:"jsonField,omitempty"`

	// Has additional properties of type int
	One *AdditionalPropertiesObject1 `json:"one,omitempty"`

	// Tests x-go-optional-value on the whole object
	OptionalObject OptionalObject `json:"optionalObject,omitempty"`

	// Tests x-go-optional-value
	OptionalValue *OptionalValue `json:"optionalValue,omitempty"`

	// Allows any additional property
	Three *AdditionalPropertiesObject3 `json:"three,omitempty"`

	// Does not allow additional properties
	Two *AdditionalPropertiesObject2 `json:"two,omitempty"`
}) *Response

EnsureEverythingIsReferencedJSON200Response is a constructor method for a EnsureEverythingIsReferenced response. A *Response is returned with the configured status code and content type from the spec.

func EnsureEverythingIsReferencedJSONDefaultResponse

func EnsureEverythingIsReferencedJSONDefaultResponse(body struct {
	Field SchemaObject `json:"Field"`
}) *Response

EnsureEverythingIsReferencedJSONDefaultResponse is a constructor method for a EnsureEverythingIsReferenced response. A *Response is returned with the configured status code and content type from the spec.

func (*Response) ContentType

func (resp *Response) ContentType(contentType string) *Response

ContentType is a builder method to override the default content type for a response.

func (*Response) MarshalJSON

func (resp *Response) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. This is used to only marshal the body of the response.

func (*Response) MarshalXML

func (resp *Response) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements the xml.Marshaler interface. This is used to only marshal the body of the response.

func (*Response) Render

func (resp *Response) Render(w http.ResponseWriter, r *http.Request) error

Render implements the render.Renderer interface. It sets the Content-Type header and status code based on the response definition.

func (*Response) Status

func (resp *Response) Status(code int) *Response

Status is a builder method to override the default status code for a response.

type ResponseObject

type ResponseObject struct {
	Field SchemaObject `json:"Field"`
}

ResponseObject defines model for ResponseObject.

type SchemaObject

type SchemaObject struct {
	FirstName string `json:"firstName"`
	Role      string `json:"role"`
}

SchemaObject defines model for SchemaObject.

type ServerInterface

type ServerInterface interface {

	// (GET /ensure-everything-is-referenced)
	EnsureEverythingIsReferenced(w http.ResponseWriter, r *http.Request) *Response

	// (GET /params_with_add_props)
	ParamsWithAddProps(w http.ResponseWriter, r *http.Request, params ParamsWithAddPropsParams) *Response

	// (POST /params_with_add_props)
	BodyWithAddProps(w http.ResponseWriter, r *http.Request) *Response
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

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

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) BodyWithAddProps

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

BodyWithAddProps operation middleware

func (*ServerInterfaceWrapper) EnsureEverythingIsReferenced

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

EnsureEverythingIsReferenced operation middleware

func (*ServerInterfaceWrapper) ParamsWithAddProps

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

ParamsWithAddProps operation middleware

type ServerOption

type ServerOption func(*ServerOptions)

func WithErrorHandler

func WithErrorHandler(handler func(w http.ResponseWriter, r *http.Request, err error)) ServerOption

func WithRouter

func WithRouter(r chi.Router) ServerOption

func WithServerBaseURL

func WithServerBaseURL(url string) ServerOption

type ServerOptions

type ServerOptions struct {
	BaseURL          string
	BaseRouter       chi.Router
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	NumValues int
	// contains filtered or unexported fields
}

func (TooManyValuesForParamError) Error added in v0.2.0

func (err TooManyValuesForParamError) Error() string

Error implements error.

func (TooManyValuesForParamError) ParamName added in v0.2.0

func (err TooManyValuesForParamError) ParamName() string

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	// contains filtered or unexported fields
}

func (UnescapedCookieParamError) Error added in v0.2.0

func (err UnescapedCookieParamError) Error() string

Error implements error.

func (UnescapedCookieParamError) ParamName added in v0.2.0

func (err UnescapedCookieParamError) ParamName() string

func (UnescapedCookieParamError) Unwrap added in v0.2.0

func (err UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError

type UnmarshalingParamError struct {
	// contains filtered or unexported fields
}

func (UnmarshalingParamError) Error added in v0.2.0

func (err UnmarshalingParamError) Error() string

Error implements error.

func (UnmarshalingParamError) ParamName added in v0.2.0

func (err UnmarshalingParamError) ParamName() string

func (UnmarshalingParamError) Unwrap added in v0.2.0

func (err UnmarshalingParamError) Unwrap() error

Jump to

Keyboard shortcuts

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