Documentation ¶
Index ¶
- Variables
- type CollectionFormat
- type JsonParameter
- type JsonResponseSchema
- type JsonResponseSchemeItems
- type Location
- type Option
- func WithCollectionFormat(c CollectionFormat) Option
- func WithDefault(defaultValue interface{}) Option
- func WithDescription(description string) Option
- func WithFormat(format string) Option
- func WithIn(in Location) Option
- func WithMax(max int64) Option
- func WithMaxItems(maxItems int64) Option
- func WithMaxLen(maxLen int64) Option
- func WithMin(min int64) Option
- func WithMinItems(minItems int64) Option
- func WithMinLen(minLen int64) Option
- func WithMultipleOf(multipleOf int64) Option
- func WithPattern(pattern string) Option
- func WithRequired() Option
- func WithType(t ParamType) Option
- func WithUniqueItems(uniqueItems bool) Option
- type ParamType
- type Parameter
- func BoolParam(name string, l Location, opts ...Option) *Parameter
- func FileParam(name string, opts ...Option) *Parameter
- func IntArrParam(name string, l Location, arr []int64, opts ...Option) *Parameter
- func IntEnumParam(name string, l Location, arr []int64, opts ...Option) *Parameter
- func IntParam(name string, l Location, opts ...Option) *Parameter
- func Params(params ...Parameter) (paramsArr []Parameter)
- func StrArrParam(name string, l Location, arr []string, opts ...Option) *Parameter
- func StrEnumParam(name string, l Location, arr []string, opts ...Option) *Parameter
- func StrParam(name string, l Location, opts ...Option) *Parameter
Constants ¶
This section is empty.
Variables ¶
var NoParam []Parameter
NoParam is an empty slice of parameters.
Functions ¶
This section is empty.
Types ¶
type CollectionFormat ¶
type CollectionFormat string
CollectionFormat defines the format for serializing array parameters in the URL query string.
const ( CSV CollectionFormat = "csv" SSV CollectionFormat = "ssv" TSV CollectionFormat = "tsv" Pipes CollectionFormat = "pipes" Multi CollectionFormat = "multi" )
func (CollectionFormat) String ¶
func (c CollectionFormat) String() string
String returns the string representation of the CollectionFormat.
type JsonParameter ¶
type JsonParameter struct { Type string `json:"type,omitempty"` Description string `json:"description"` Name string `json:"name"` In string `json:"in,omitempty"` Required bool `json:"required"` Schema *JsonResponseSchema `json:"schema,omitempty"` Format string `json:"format,omitempty"` Enum []interface{} `json:"enum,omitempty"` Default interface{} `json:"default,omitempty"` Min int64 `json:"minimum,omitempty"` Max int64 `json:"maximum,omitempty"` MinLen int64 `json:"minLength,omitempty"` MaxLen int64 `json:"maxLength,omitempty"` Pattern string `json:"pattern,omitempty"` MaxItems int64 `json:"maxItems,omitempty"` MinItems int64 `json:"minItems,omitempty"` UniqueItems bool `json:"uniqueItems,omitempty"` MultipleOf int64 `json:"multipleOf,omitempty"` CollenctionFormat string `json:"collectionFormat,omitempty"` }
JsonParameter is the JSON model version of Parameter object used for API purposes https://swagger.io/specification/v2/#parameterObject
type JsonResponseSchema ¶
type JsonResponseSchema struct { Ref string `json:"$ref,omitempty"` Type string `json:"type,omitempty"` Items *JsonResponseSchemeItems `json:"items,omitempty"` }
JsonResponseSchema defines the schema for a JSON response as per the Swagger 2.0 specification. It is used to describe the structure and type of a response returned by an API endpoint. https://swagger.io/specification/v2/#schema-object
type JsonResponseSchemeItems ¶
type JsonResponseSchemeItems struct { Type string `json:"type,omitempty"` Ref string `json:"$ref,omitempty"` Items *JsonResponseSchemeItems `json:"items,omitempty"` }
JsonResponseSchemeItems represents the individual items in a JsonResponseSchema, especially for arrays. It provides the type or reference for the array items.
type Location ¶
type Location string
Location specifies where in the request a parameter is expected to be located.
type Option ¶
type Option func(*Parameter)
Option represents a function that can modify a Parameter.
func WithCollectionFormat ¶
func WithCollectionFormat(c CollectionFormat) Option
WithCollectionFormat sets the CollectionFormat field of a Parameter.
func WithDefault ¶
func WithDefault(defaultValue interface{}) Option
WithDefault sets the Default field of a Parameter.
func WithDescription ¶
WithDescription sets the Description field of a Parameter.
func WithFormat ¶
WithFormat sets the Format field of a Parameter.
func WithMaxItems ¶
WithMaxItems sets the MaxItems field of a Parameter.
func WithMaxLen ¶
WithMaxLen sets the MaxLen field of a Parameter.
func WithMinItems ¶
WithMinItems sets the MinItems field of a Parameter.
func WithMinLen ¶
WithMinLen sets the MinLen field of a Parameter.
func WithMultipleOf ¶
WithMultipleOf sets the MultipleOf field of a Parameter.
func WithPattern ¶
WithPattern sets the Pattern field of a Parameter.
func WithUniqueItems ¶
WithUniqueItems sets the UniqueItems field of a Parameter.
type ParamType ¶
type ParamType string
ParamType represents the type of a parameter in the API endpoint.
type Parameter ¶
type Parameter struct {
// contains filtered or unexported fields
}
Parameter represents a parameter in an API endpoint.
func IntArrParam ¶
IntArrParam creates an integer array parameter.
func IntEnumParam ¶
IntEnumParam creates an integer enum parameter.
func StrArrParam ¶
StrArrParam creates a string array parameter.
func StrEnumParam ¶
StrEnumParam creates a string enum parameter.
func (*Parameter) AsJson ¶
func (p *Parameter) AsJson() JsonParameter
AsJson returns the json representation of Parameter