Documentation
¶
Index ¶
- Constants
- Variables
- func ExpandParameter(parameter *Parameter, basePath string) error
- func ExpandParameterWithRoot(parameter *Parameter, root any, cache ResolutionCache) error
- func ExpandResponse(response *Response, basePath string) error
- func ExpandResponseWithRoot(response *Response, root any, cache ResolutionCache) error
- func ExpandSchema(schema *Schema, root any, cache ResolutionCache) error
- func ExpandSchemaWithBasePath(schema *Schema, cache ResolutionCache, opts *ExpandOptions) error
- func ExpandSpec(spec *Swagger, options *ExpandOptions) error
- type Callback
- type CallbackProps
- type CommonValidations
- func (v *CommonValidations) ClearArrayValidations(cbs ...func(string, any))
- func (v *CommonValidations) ClearNumberValidations(cbs ...func(string, any))
- func (v *CommonValidations) ClearStringValidations(cbs ...func(string, any))
- func (v CommonValidations) HasArrayValidations() bool
- func (v CommonValidations) HasEnum() bool
- func (v CommonValidations) HasNumberValidations() bool
- func (v CommonValidations) HasStringValidations() bool
- func (v *CommonValidations) SetValidations(val SchemaValidations)
- func (v CommonValidations) Validations() SchemaValidations
- type Components
- type ComponentsProps
- type ContactInfo
- type ContactInfoProps
- type Definitions
- type Dependencies
- type Encoding
- type EncodingProps
- type Example
- type ExampleProps
- type ExpandOptions
- type Extensions
- type ExternalDocumentation
- type Header
- func (h *Header) AllowDuplicates() *Header
- func (h *Header) CollectionOf(items *Items, format string) *Header
- func (h Header) JSONLookup(token string) (any, error)
- func (h Header) MarshalJSON() ([]byte, error)
- func (h *Header) Typed(tpe, format string) *Header
- func (h *Header) UniqueValues() *Header
- func (h *Header) UnmarshalJSON(data []byte) error
- func (h *Header) WithDefault(defaultValue any) *Header
- func (h *Header) WithDescription(description string) *Header
- func (h *Header) WithEnum(values ...any) *Header
- func (h *Header) WithMaxItems(size int64) *Header
- func (h *Header) WithMaxLength(maximum int64) *Header
- func (h *Header) WithMaximum(maximum float64, exclusive bool) *Header
- func (h *Header) WithMinItems(size int64) *Header
- func (h *Header) WithMinLength(minimum int64) *Header
- func (h *Header) WithMinimum(minimum float64, exclusive bool) *Header
- func (h *Header) WithMultipleOf(number float64) *Header
- func (h *Header) WithPattern(pattern string) *Header
- func (h *Header) WithValidations(val CommonValidations) *Header
- type HeaderProps
- type Info
- type InfoProps
- type Items
- func (i *Items) AllowDuplicates() *Items
- func (i *Items) AsNullable() *Items
- func (i *Items) CollectionOf(items *Items, format string) *Items
- func (i Items) JSONLookup(token string) (any, error)
- func (i Items) MarshalJSON() ([]byte, error)
- func (i *Items) Typed(tpe, format string) *Items
- func (i *Items) UniqueValues() *Items
- func (i *Items) UnmarshalJSON(data []byte) error
- func (i *Items) WithDefault(defaultValue any) *Items
- func (i *Items) WithEnum(values ...any) *Items
- func (i *Items) WithMaxItems(size int64) *Items
- func (i *Items) WithMaxLength(maximum int64) *Items
- func (i *Items) WithMaximum(maximum float64, exclusive bool) *Items
- func (i *Items) WithMinItems(size int64) *Items
- func (i *Items) WithMinLength(minimum int64) *Items
- func (i *Items) WithMinimum(minimum float64, exclusive bool) *Items
- func (i *Items) WithMultipleOf(number float64) *Items
- func (i *Items) WithPattern(pattern string) *Items
- func (i *Items) WithValidations(val CommonValidations) *Items
- type License
- type LicenseProps
- type Link
- type LinkProps
- type MediaType
- type MediaTypeProps
- type OAuthFlow
- type OAuthFlows
- type Operation
- func (o *Operation) AddParam(param *Parameter) *Operation
- func (o *Operation) Deprecate() *Operation
- func (o *Operation) GobDecode(b []byte) error
- func (o Operation) GobEncode() ([]byte, error)
- func (o Operation) JSONLookup(token string) (any, error)
- func (o Operation) MarshalJSON() ([]byte, error)
- func (o *Operation) RemoveParam(name, in string) *Operation
- func (o *Operation) RespondsWith(code int, response *Response) *Operation
- func (o *Operation) SecuredWith(name string, scopes ...string) *Operation
- func (o *Operation) SuccessResponse() (*Response, int, bool)
- func (o *Operation) Undeprecate() *Operation
- func (o *Operation) UnmarshalJSON(data []byte) error
- func (o *Operation) WithConsumes(mediaTypes ...string) *Operation
- func (o *Operation) WithDefaultResponse(response *Response) *Operation
- func (o *Operation) WithDescription(description string) *Operation
- func (o *Operation) WithExternalDocs(description, url string) *Operation
- func (o *Operation) WithID(id string) *Operation
- func (o *Operation) WithProduces(mediaTypes ...string) *Operation
- func (o *Operation) WithSummary(summary string) *Operation
- func (o *Operation) WithTags(tags ...string) *Operation
- type OperationProps
- type OrderSchemaItem
- type OrderSchemaItems
- type ParamProps
- type Parameter
- func BodyParam(name string, schema *Schema) *Parameter
- func CookieParam(name string) *Parameter
- func FileParam(name string) *Parameter
- func FormDataParam(name string) *Parameter
- func HeaderParam(name string) *Parameter
- func ParamRef(uri string) *Parameter
- func PathParam(name string) *Parameter
- func QueryParam(name string) *Parameter
- func ResolveParameter(root any, ref Ref) (*Parameter, error)
- func ResolveParameterWithBase(root any, ref Ref, options *ExpandOptions) (*Parameter, error)
- func SimpleArrayParam(name, tpe, fmt string) *Parameter
- func (p *Parameter) AllowDuplicates() *Parameter
- func (p *Parameter) AllowsEmptyValues() *Parameter
- func (p *Parameter) AsOptional() *Parameter
- func (p *Parameter) AsRequired() *Parameter
- func (p *Parameter) CollectionOf(items *Items, format string) *Parameter
- func (p Parameter) JSONLookup(token string) (any, error)
- func (p Parameter) MarshalJSON() ([]byte, error)
- func (p *Parameter) Named(name string) *Parameter
- func (p *Parameter) NoEmptyValues() *Parameter
- func (p *Parameter) Typed(tpe, format string) *Parameter
- func (p *Parameter) UniqueValues() *Parameter
- func (p *Parameter) UnmarshalJSON(data []byte) error
- func (p *Parameter) WithDefault(defaultValue any) *Parameter
- func (p *Parameter) WithDescription(description string) *Parameter
- func (p *Parameter) WithEnum(values ...any) *Parameter
- func (p *Parameter) WithLocation(in string) *Parameter
- func (p *Parameter) WithMaxItems(size int64) *Parameter
- func (p *Parameter) WithMaxLength(maximum int64) *Parameter
- func (p *Parameter) WithMaximum(maximum float64, exclusive bool) *Parameter
- func (p *Parameter) WithMinItems(size int64) *Parameter
- func (p *Parameter) WithMinLength(minimum int64) *Parameter
- func (p *Parameter) WithMinimum(minimum float64, exclusive bool) *Parameter
- func (p *Parameter) WithMultipleOf(number float64) *Parameter
- func (p *Parameter) WithPattern(pattern string) *Parameter
- func (p *Parameter) WithValidations(val CommonValidations) *Parameter
- type PathItem
- type PathItemProps
- type Paths
- type PatternSchemaProperties
- type Ref
- type Refable
- type RequestBody
- type RequestBodyProps
- type ResolutionCache
- type Response
- func (r *Response) AddExample(mediaType string, example any) *Response
- func (r *Response) AddHeader(name string, header *Header) *Response
- func (r Response) JSONLookup(token string) (any, error)
- func (r Response) MarshalJSON() ([]byte, error)
- func (r *Response) RemoveHeader(name string) *Response
- func (r *Response) UnmarshalJSON(data []byte) error
- func (r *Response) WithDescription(description string) *Response
- func (r *Response) WithSchema(schema *Schema) *Response
- type ResponseProps
- type Responses
- type ResponsesProps
- type Schema
- func ArrayProperty(items *Schema) *Schema
- func BoolProperty() *Schema
- func BooleanProperty() *Schema
- func CharProperty() *Schema
- func ComposedSchema(schemas ...Schema) *Schema
- func DateProperty() *Schema
- func DateTimeProperty() *Schema
- func Float32Property() *Schema
- func Float64Property() *Schema
- func Int16Property() *Schema
- func Int32Property() *Schema
- func Int64Property() *Schema
- func Int8Property() *Schema
- func JSONSchemaDraft04() (*Schema, error)
- func MapProperty(property *Schema) *Schema
- func MustLoadJSONSchemaDraft04() *Schema
- func MustLoadOpenAPI32Schema() *Schema
- func MustLoadSwagger20Schema() *Schema
- func OpenAPI32Schema() (*Schema, error)
- func RefProperty(name string) *Schema
- func RefSchema(name string) *Schema
- func ResolveRef(root any, ref *Ref) (*Schema, error)
- func ResolveRefWithBase(root any, ref *Ref, options *ExpandOptions) (*Schema, error)
- func StrFmtProperty(format string) *Schema
- func StringProperty() *Schema
- func Swagger20Schema() (*Schema, error)
- func (s *Schema) AddRequired(items ...string) *Schema
- func (s *Schema) AddToAllOf(schemas ...Schema) *Schema
- func (s *Schema) AddType(tpe, format string) *Schema
- func (s *Schema) AllowDuplicates() *Schema
- func (s *Schema) AsNullable() *Schema
- func (s *Schema) AsReadOnly() *Schema
- func (s *Schema) AsUnwrappedXML() *Schema
- func (s *Schema) AsWrappedXML() *Schema
- func (s *Schema) AsWritable() *Schema
- func (s *Schema) AsXMLAttribute() *Schema
- func (s *Schema) AsXMLElement() *Schema
- func (s *Schema) CollectionOf(items Schema) *Schema
- func (s Schema) JSONLookup(token string) (any, error)
- func (s Schema) MarshalJSON() ([]byte, error)
- func (s *Schema) SetProperty(name string, schema Schema) *Schema
- func (s *Schema) SetValidations(val SchemaValidations)
- func (s *Schema) Typed(tpe, format string) *Schema
- func (s *Schema) UniqueValues() *Schema
- func (s *Schema) UnmarshalJSON(data []byte) error
- func (s Schema) Validations() SchemaValidations
- func (s *Schema) WithAllOf(schemas ...Schema) *Schema
- func (s *Schema) WithDefault(defaultValue any) *Schema
- func (s *Schema) WithDescription(description string) *Schema
- func (s *Schema) WithDiscriminator(discriminator string) *Schema
- func (s *Schema) WithEnum(values ...any) *Schema
- func (s *Schema) WithExample(example any) *Schema
- func (s *Schema) WithExternalDocs(description, url string) *Schema
- func (s *Schema) WithID(id string) *Schema
- func (s *Schema) WithMaxItems(size int64) *Schema
- func (s *Schema) WithMaxLength(maximum int64) *Schema
- func (s *Schema) WithMaxProperties(maximum int64) *Schema
- func (s *Schema) WithMaximum(maximum float64, exclusive bool) *Schema
- func (s *Schema) WithMinItems(size int64) *Schema
- func (s *Schema) WithMinLength(minimum int64) *Schema
- func (s *Schema) WithMinProperties(minimum int64) *Schema
- func (s *Schema) WithMinimum(minimum float64, exclusive bool) *Schema
- func (s *Schema) WithMultipleOf(number float64) *Schema
- func (s *Schema) WithPattern(pattern string) *Schema
- func (s *Schema) WithProperties(schemas map[string]Schema) *Schema
- func (s *Schema) WithRequired(items ...string) *Schema
- func (s *Schema) WithTitle(title string) *Schema
- func (s *Schema) WithValidations(val SchemaValidations) *Schema
- func (s *Schema) WithXMLName(name string) *Schema
- func (s *Schema) WithXMLNamespace(namespace string) *Schema
- func (s *Schema) WithXMLPrefix(prefix string) *Schema
- type SchemaOrArray
- type SchemaOrBool
- type SchemaOrStringArray
- type SchemaProperties
- type SchemaProps
- type SchemaURL
- type SchemaValidations
- type SecurityDefinitions
- type SecurityScheme
- func APIKeyAuth(fieldName, valueSource string) *SecurityScheme
- func BasicAuth() *SecurityScheme
- func OAuth2AccessToken(authorizationURL, tokenURL string) *SecurityScheme
- func OAuth2Application(tokenURL string) *SecurityScheme
- func OAuth2Implicit(authorizationURL string) *SecurityScheme
- func OAuth2Password(tokenURL string) *SecurityScheme
- type SecuritySchemeProps
- type Server
- type ServerProps
- type ServerVariable
- type ServerVariableProps
- type SimpleSchema
- type StringOrArray
- type Swagger
- type SwaggerProps
- type SwaggerSchemaProps
- type Tag
- type TagProps
- type VendorExtensible
- type XMLObject
- func (x *XMLObject) AsAttribute() *XMLObject
- func (x *XMLObject) AsElement() *XMLObject
- func (x *XMLObject) AsUnwrapped() *XMLObject
- func (x *XMLObject) AsWrapped() *XMLObject
- func (x *XMLObject) WithName(name string) *XMLObject
- func (x *XMLObject) WithNamespace(namespace string) *XMLObject
- func (x *XMLObject) WithPrefix(prefix string) *XMLObject
Constants ¶
const ( // OpenAPI32SchemaURL the url for the OpenAPI 3.2 schema to validate specs OpenAPI32SchemaURL = "https://spec.openapis.org/oas/3.2/schema/2025-09-17#" // SwaggerSchemaURL the url for the swagger 2.0 schema (now redirects to OpenAPI 3.2 schema) SwaggerSchemaURL = "http://swagger.io/v2/schema.json#" // JSONSchemaURL the url for the json schema JSONSchemaURL = "http://json-schema.org/draft-04/schema#" // OpenAPIVersion the default OpenAPI version to use OpenAPIVersion = "3.2.0" )
Variables ¶
var ( // ErrUnknownTypeForReference indicates that a resolved reference was found in an unsupported container type ErrUnknownTypeForReference = errors.New("unknown type for the resolved reference") // ErrResolveRefNeedsAPointer indicates that a $ref target must be a valid JSON pointer ErrResolveRefNeedsAPointer = errors.New("resolve ref: target needs to be a pointer") // ErrDerefUnsupportedType indicates that a resolved reference was found in an unsupported container type. // At the moment, $ref are supported only inside: schemas, parameters, responses, path items ErrDerefUnsupportedType = errors.New("deref: unsupported type") // ErrExpandUnsupportedType indicates that $ref expansion is attempted on some invalid type ErrExpandUnsupportedType = errors.New("expand: unsupported type. Input should be of type *Parameter or *Response") // ErrSpec is an error raised by the spec package ErrSpec = errors.New("spec error") )
Error codes
var Debug = os.Getenv("SWAGGER_DEBUG") != ""
Debug is true when the SWAGGER_DEBUG env var is not empty.
It enables a more verbose logging of this package.
var PathLoader = func(pth string) (json.RawMessage, error) { data, err := loading.LoadFromFileOrHTTP(pth) if err != nil { return nil, err } return json.RawMessage(data), nil }
PathLoader is a function to use when loading remote refs.
This is a package level default. It may be overridden or bypassed by specifying the loader in ExpandOptions.
NOTE: if you are using the go-openapi/loads package, it will override this value with its own default (a loader to retrieve YAML documents as well as JSON ones).
Functions ¶
func ExpandParameter ¶
ExpandParameter expands a parameter based on a basepath. This is the exported version of expandParameter all refs inside parameter will be resolved relative to basePath
func ExpandParameterWithRoot ¶
func ExpandParameterWithRoot(parameter *Parameter, root any, cache ResolutionCache) error
ExpandParameterWithRoot expands a parameter based on a root document, not a fetchable document.
Notice that it is impossible to reference a json schema in a different document other than root (use ExpandParameter to resolve external references).
func ExpandResponse ¶
ExpandResponse expands a response based on a basepath
All refs inside response will be resolved relative to basePath
func ExpandResponseWithRoot ¶
func ExpandResponseWithRoot(response *Response, root any, cache ResolutionCache) error
ExpandResponseWithRoot expands a response based on a root document, not a fetchable document
Notice that it is impossible to reference a json schema in a different document other than root (use ExpandResponse to resolve external references).
Setting the cache is optional and this parameter may safely be left to nil.
func ExpandSchema ¶
func ExpandSchema(schema *Schema, root any, cache ResolutionCache) error
ExpandSchema expands the refs in the schema object with reference to the root object.
go-openapi/validate uses this function.
Notice that it is impossible to reference a json schema in a different document other than root (use ExpandSchemaWithBasePath to resolve external references).
Setting the cache is optional and this parameter may safely be left to nil.
func ExpandSchemaWithBasePath ¶
func ExpandSchemaWithBasePath(schema *Schema, cache ResolutionCache, opts *ExpandOptions) error
ExpandSchemaWithBasePath expands the refs in the schema object, base path configured through expand options.
Setting the cache is optional and this parameter may safely be left to nil.
func ExpandSpec ¶
func ExpandSpec(spec *Swagger, options *ExpandOptions) error
ExpandSpec expands the references in a swagger spec
Types ¶
type Callback ¶
type Callback struct {
Refable
VendorExtensible
CallbackProps
}
Callback is a map of possible out-of band callbacks related to the parent operation.
For more information: https://spec.openapis.org/oas/v3.1.0#callback-object
func (Callback) JSONLookup ¶
JSONLookup look up a value by the json property name
func (Callback) MarshalJSON ¶
MarshalJSON marshals this to JSON
func (*Callback) UnmarshalJSON ¶
UnmarshalJSON unmarshals this from JSON
type CallbackProps ¶
CallbackProps describes the properties of a Callback
type CommonValidations ¶
type CommonValidations struct {
Maximum *float64 `json:"maximum,omitempty"`
ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"`
Minimum *float64 `json:"minimum,omitempty"`
ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"`
MaxLength *int64 `json:"maxLength,omitempty"`
MinLength *int64 `json:"minLength,omitempty"`
Pattern string `json:"pattern,omitempty"`
MaxItems *int64 `json:"maxItems,omitempty"`
MinItems *int64 `json:"minItems,omitempty"`
UniqueItems bool `json:"uniqueItems,omitempty"`
MultipleOf *float64 `json:"multipleOf,omitempty"`
Enum []any `json:"enum,omitempty"`
}
CommonValidations describe common JSON-schema validations
func (*CommonValidations) ClearArrayValidations ¶
func (v *CommonValidations) ClearArrayValidations(cbs ...func(string, any))
ClearArrayValidations clears all array validations.
Some callbacks may be set by the caller to capture changed values.
func (*CommonValidations) ClearNumberValidations ¶
func (v *CommonValidations) ClearNumberValidations(cbs ...func(string, any))
ClearNumberValidations clears all number validations.
Some callbacks may be set by the caller to capture changed values.
func (*CommonValidations) ClearStringValidations ¶
func (v *CommonValidations) ClearStringValidations(cbs ...func(string, any))
ClearStringValidations clears all string validations.
Some callbacks may be set by the caller to capture changed values.
func (CommonValidations) HasArrayValidations ¶
func (v CommonValidations) HasArrayValidations() bool
HasArrayValidations indicates if the validations are for arrays
func (CommonValidations) HasEnum ¶
func (v CommonValidations) HasEnum() bool
HasEnum indicates if the validation includes some enum constraint
func (CommonValidations) HasNumberValidations ¶
func (v CommonValidations) HasNumberValidations() bool
HasNumberValidations indicates if the validations are for numbers or integers
func (CommonValidations) HasStringValidations ¶
func (v CommonValidations) HasStringValidations() bool
HasStringValidations indicates if the validations are for strings
func (*CommonValidations) SetValidations ¶
func (v *CommonValidations) SetValidations(val SchemaValidations)
SetValidations defines all validations for a simple schema.
NOTE: the input is the larger set of validations available for schemas. For simple schemas, MinProperties and MaxProperties are ignored.
func (CommonValidations) Validations ¶
func (v CommonValidations) Validations() SchemaValidations
Validations returns a clone of the validations for a simple schema.
NOTE: in the context of simple schema objects, MinProperties, MaxProperties and PatternProperties remain unset.
type Components ¶
type Components struct {
VendorExtensible
ComponentsProps
}
Components holds a set of reusable objects for different aspects of the OAS. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object.
For more information: https://spec.openapis.org/oas/v3.1.0#components-object
func (Components) JSONLookup ¶
func (c Components) JSONLookup(token string) (any, error)
JSONLookup look up a value by the json property name
func (Components) MarshalJSON ¶
func (c Components) MarshalJSON() ([]byte, error)
MarshalJSON marshals this to JSON
func (*Components) UnmarshalJSON ¶
func (c *Components) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals this from JSON
type ComponentsProps ¶
type ComponentsProps struct {
Schemas map[string]Schema `json:"schemas,omitempty"`
Responses map[string]Response `json:"responses,omitempty"`
Parameters map[string]Parameter `json:"parameters,omitempty"`
Examples map[string]Example `json:"examples,omitempty"`
RequestBodies map[string]RequestBody `json:"requestBodies,omitempty"`
Headers map[string]Header `json:"headers,omitempty"`
SecuritySchemes map[string]SecurityScheme `json:"securitySchemes,omitempty"`
Links map[string]Link `json:"links,omitempty"`
Callbacks map[string]Callback `json:"callbacks,omitempty"`
}
ComponentsProps describes the properties of a Components object
type ContactInfo ¶
type ContactInfo struct {
ContactInfoProps
VendorExtensible
}
ContactInfo contact information for the exposed API.
For more information: http://goo.gl/8us55a#contactObject
func (ContactInfo) MarshalJSON ¶
func (c ContactInfo) MarshalJSON() ([]byte, error)
MarshalJSON produces ContactInfo as json
func (*ContactInfo) UnmarshalJSON ¶
func (c *ContactInfo) UnmarshalJSON(data []byte) error
UnmarshalJSON hydrates ContactInfo from json
type ContactInfoProps ¶
type ContactInfoProps struct {
Name string `json:"name,omitempty"`
URL string `json:"url,omitempty"`
Email string `json:"email,omitempty"`
}
ContactInfoProps hold the properties of a ContactInfo object
type Definitions ¶
Definitions contains the models explicitly defined in this spec An object to hold data types that can be consumed and produced by operations. These data types can be primitives, arrays or models.
For more information: http://goo.gl/8us55a#definitionsObject
type Dependencies ¶
type Dependencies map[string]SchemaOrStringArray
Dependencies represent a dependencies property
type Encoding ¶
type Encoding struct {
VendorExtensible
EncodingProps
}
Encoding represents a single encoding definition applied to a single schema property.
For more information: https://spec.openapis.org/oas/v3.1.0#encoding-object
func (Encoding) JSONLookup ¶
JSONLookup look up a value by the json property name
func (Encoding) MarshalJSON ¶
MarshalJSON marshals this to JSON
func (*Encoding) UnmarshalJSON ¶
UnmarshalJSON unmarshals this from JSON
type EncodingProps ¶
type EncodingProps struct {
ContentType string `json:"contentType,omitempty"`
Headers map[string]Header `json:"headers,omitempty"`
Style string `json:"style,omitempty"`
Explode *bool `json:"explode,omitempty"`
AllowReserved bool `json:"allowReserved,omitempty"`
Encoding map[string]Encoding `json:"encoding,omitempty"` // OpenAPI 3.2: nested encoding for complex types
PrefixEncoding []Encoding `json:"prefixEncoding,omitempty"` // OpenAPI 3.2: encoding for sequential media type prefixes
ItemEncoding *Encoding `json:"itemEncoding,omitempty"` // OpenAPI 3.2: encoding for each item in a stream
}
EncodingProps describes the properties of an Encoding
type Example ¶
type Example struct {
Refable
VendorExtensible
ExampleProps
}
Example represents an example value.
For more information: https://spec.openapis.org/oas/v3.1.0#example-object
func (Example) JSONLookup ¶
JSONLookup look up a value by the json property name
func (Example) MarshalJSON ¶
MarshalJSON marshals this to JSON
func (*Example) UnmarshalJSON ¶
UnmarshalJSON unmarshals this from JSON
type ExampleProps ¶
type ExampleProps struct {
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Value any `json:"value,omitempty"`
ExternalValue string `json:"externalValue,omitempty"`
}
ExampleProps describes the properties of an Example
type ExpandOptions ¶
type ExpandOptions struct {
RelativeBase string // the path to the root document to expand. This is a file, not a directory
SkipSchemas bool // do not expand schemas, just paths, parameters and responses
ContinueOnError bool // continue expanding even after and error is found
PathLoader func(string) (json.RawMessage, error) `json:"-"` // the document loading method that takes a path as input and yields a json document
AbsoluteCircularRef bool // circular $ref remaining after expansion remain absolute URLs
}
ExpandOptions provides options for the spec expander.
RelativeBase is the path to the root document. This can be a remote URL or a path to a local file.
If left empty, the root document is assumed to be located in the current working directory: all relative $ref's will be resolved from there.
PathLoader injects a document loading method. By default, this resolves to the function provided by the SpecLoader package variable.
type Extensions ¶
Extensions vendor specific extensions
func (Extensions) Add ¶
func (e Extensions) Add(key string, value any)
Add adds a value to these extensions
func (Extensions) GetBool ¶
func (e Extensions) GetBool(key string) (bool, bool)
GetBool gets a string value from the extensions
func (Extensions) GetInt ¶
func (e Extensions) GetInt(key string) (int, bool)
GetInt gets a int value from the extensions
func (Extensions) GetString ¶
func (e Extensions) GetString(key string) (string, bool)
GetString gets a string value from the extensions
func (Extensions) GetStringSlice ¶
func (e Extensions) GetStringSlice(key string) ([]string, bool)
GetStringSlice gets a string value from the extensions
type ExternalDocumentation ¶
type ExternalDocumentation struct {
Description string `json:"description,omitempty"`
URL string `json:"url,omitempty"`
}
ExternalDocumentation allows referencing an external resource for extended documentation.
For more information: http://goo.gl/8us55a#externalDocumentationObject
type Header ¶
type Header struct {
CommonValidations
SimpleSchema
VendorExtensible
HeaderProps
}
Header describes a header for a response of the API
For more information: http://goo.gl/8us55a#headerObject
func ResponseHeader ¶
func ResponseHeader() *Header
ResponseHeader creates a new header instance for use in a response
func (*Header) AllowDuplicates ¶
AllowDuplicates this array can have duplicates
func (*Header) CollectionOf ¶
CollectionOf a fluent builder method for an array item
func (Header) JSONLookup ¶
JSONLookup look up a value by the json property name
func (Header) MarshalJSON ¶
MarshalJSON marshal this to JSON
func (*Header) UniqueValues ¶
UniqueValues dictates that this array can only have unique items
func (*Header) UnmarshalJSON ¶
UnmarshalJSON unmarshals this header from JSON
func (*Header) WithDefault ¶
WithDefault sets the default value on this item
func (*Header) WithDescription ¶
WithDescription sets the description on this response, allows for chaining
func (*Header) WithMaxItems ¶
WithMaxItems sets the max items
func (*Header) WithMaxLength ¶
WithMaxLength sets a max length value
func (*Header) WithMaximum ¶
WithMaximum sets a maximum number value
func (*Header) WithMinItems ¶
WithMinItems sets the min items
func (*Header) WithMinLength ¶
WithMinLength sets a min length value
func (*Header) WithMinimum ¶
WithMinimum sets a minimum number value
func (*Header) WithMultipleOf ¶
WithMultipleOf sets a multiple of value
func (*Header) WithPattern ¶
WithPattern sets a pattern value
func (*Header) WithValidations ¶
func (h *Header) WithValidations(val CommonValidations) *Header
WithValidations is a fluent method to set header validations
type HeaderProps ¶
type HeaderProps struct {
Description string `json:"description,omitempty"`
}
HeaderProps describes a response header
type Info ¶
type Info struct {
VendorExtensible
InfoProps
}
Info object provides metadata about the API. The metadata can be used by the clients if needed, and can be presented in the Swagger-UI for convenience.
For more information: http://goo.gl/8us55a#infoObject
func (Info) JSONLookup ¶
JSONLookup look up a value by the json property name
func (Info) MarshalJSON ¶
MarshalJSON marshal this to JSON
func (*Info) UnmarshalJSON ¶
UnmarshalJSON marshal this from JSON
type InfoProps ¶
type InfoProps struct {
Description string `json:"description,omitempty"`
Title string `json:"title,omitempty"`
TermsOfService string `json:"termsOfService,omitempty"`
Contact *ContactInfo `json:"contact,omitempty"`
License *License `json:"license,omitempty"`
Version string `json:"version,omitempty"`
}
InfoProps the properties for an info definition
type Items ¶
type Items struct {
Refable
CommonValidations
SimpleSchema
VendorExtensible
}
Items a limited subset of JSON-Schema's items object. It is used by parameter definitions that are not located in "body".
For more information: http://goo.gl/8us55a#items-object
func ResolveItems
deprecated
func ResolveItems(root any, ref Ref, options *ExpandOptions) (*Items, error)
ResolveItems resolves parameter items reference against a context root and base path.
Deprecated: use ResolveItemsWithBase instead
func ResolveItemsWithBase ¶
func ResolveItemsWithBase(root any, ref Ref, options *ExpandOptions) (*Items, error)
ResolveItemsWithBase resolves parameter items reference against a context root and base path.
NOTE: strictly speaking, this construct is not supported by Swagger 2.0. Similarly, $ref are forbidden in response headers.
func (*Items) AllowDuplicates ¶
AllowDuplicates this array can have duplicates
func (*Items) AsNullable ¶
AsNullable flags this schema as nullable.
func (*Items) CollectionOf ¶
CollectionOf a fluent builder method for an array item
func (Items) JSONLookup ¶
JSONLookup look up a value by the json property name
func (Items) MarshalJSON ¶
MarshalJSON converts this items object to JSON
func (*Items) UniqueValues ¶
UniqueValues dictates that this array can only have unique items
func (*Items) UnmarshalJSON ¶
UnmarshalJSON hydrates this items instance with the data from JSON
func (*Items) WithDefault ¶
WithDefault sets the default value on this item
func (*Items) WithMaxItems ¶
WithMaxItems sets the max items
func (*Items) WithMaxLength ¶
WithMaxLength sets a max length value
func (*Items) WithMaximum ¶
WithMaximum sets a maximum number value
func (*Items) WithMinItems ¶
WithMinItems sets the min items
func (*Items) WithMinLength ¶
WithMinLength sets a min length value
func (*Items) WithMinimum ¶
WithMinimum sets a minimum number value
func (*Items) WithMultipleOf ¶
WithMultipleOf sets a multiple of value
func (*Items) WithPattern ¶
WithPattern sets a pattern value
func (*Items) WithValidations ¶
func (i *Items) WithValidations(val CommonValidations) *Items
WithValidations is a fluent method to set Items validations
type License ¶
type License struct {
LicenseProps
VendorExtensible
}
License information for the exposed API.
For more information: http://goo.gl/8us55a#licenseObject
func (License) MarshalJSON ¶
MarshalJSON produces License as json
func (*License) UnmarshalJSON ¶
UnmarshalJSON hydrates License from json
type LicenseProps ¶
LicenseProps holds the properties of a License object
type Link ¶
type Link struct {
Refable
VendorExtensible
LinkProps
}
Link represents a possible design-time link for a response.
For more information: https://spec.openapis.org/oas/v3.1.0#link-object
func (Link) JSONLookup ¶
JSONLookup look up a value by the json property name
func (Link) MarshalJSON ¶
MarshalJSON marshals this to JSON
func (*Link) UnmarshalJSON ¶
UnmarshalJSON unmarshals this from JSON
type LinkProps ¶
type LinkProps struct {
OperationRef string `json:"operationRef,omitempty"`
OperationID string `json:"operationId,omitempty"`
Parameters map[string]any `json:"parameters,omitempty"`
RequestBody any `json:"requestBody,omitempty"`
Description string `json:"description,omitempty"`
Server *Server `json:"server,omitempty"`
}
LinkProps describes the properties of a Link
type MediaType ¶
type MediaType struct {
VendorExtensible
MediaTypeProps
}
MediaType provides schema and examples for the media type identified by its key.
For more information: https://spec.openapis.org/oas/v3.1.0#media-type-object
func (MediaType) JSONLookup ¶
JSONLookup look up a value by the json property name
func (MediaType) MarshalJSON ¶
MarshalJSON marshals this to JSON
func (*MediaType) UnmarshalJSON ¶
UnmarshalJSON unmarshals this from JSON
type MediaTypeProps ¶
type MediaTypeProps struct {
Schema *Schema `json:"schema,omitempty"`
ItemSchema *Schema `json:"itemSchema,omitempty"` // OpenAPI 3.2: schema for each item in a stream
Example any `json:"example,omitempty"`
Examples map[string]Example `json:"examples,omitempty"`
Encoding map[string]Encoding `json:"encoding,omitempty"`
PrefixEncoding []Encoding `json:"prefixEncoding,omitempty"` // OpenAPI 3.2: encoding for sequential media type prefixes
ItemEncoding *Encoding `json:"itemEncoding,omitempty"` // OpenAPI 3.2: encoding for each item in a stream
}
MediaTypeProps describes the properties of a MediaType
type OAuthFlow ¶
type OAuthFlow struct {
AuthorizationURL string `json:"authorizationUrl,omitempty"`
TokenURL string `json:"tokenUrl,omitempty"`
RefreshURL string `json:"refreshUrl,omitempty"` // New in OpenAPI v3
Scopes map[string]string `json:"scopes"`
}
OAuthFlow represents a single OAuth flow configuration
type OAuthFlows ¶
type OAuthFlows struct {
Implicit *OAuthFlow `json:"implicit,omitempty"`
Password *OAuthFlow `json:"password,omitempty"`
ClientCredentials *OAuthFlow `json:"clientCredentials,omitempty"`
AuthorizationCode *OAuthFlow `json:"authorizationCode,omitempty"`
}
OAuthFlows represents the OAuth flows configuration for OpenAPI v3
type Operation ¶
type Operation struct {
VendorExtensible
OperationProps
}
Operation describes a single API operation on a path.
For more information: http://goo.gl/8us55a#operationObject
func NewOperation ¶
NewOperation creates a new operation instance. It expects an ID as parameter but not passing an ID is also valid.
func (*Operation) AddParam ¶
AddParam adds a parameter to this operation, when a parameter for that location and with that name already exists it will be replaced
func (*Operation) GobDecode ¶
GobDecode provides a safe gob decoder for Operation, including empty security requirements
func (Operation) GobEncode ¶
GobEncode provides a safe gob encoder for Operation, including empty security requirements
func (Operation) JSONLookup ¶
JSONLookup look up a value by the json property name
func (Operation) MarshalJSON ¶
MarshalJSON converts this items object to JSON
func (*Operation) RemoveParam ¶
RemoveParam removes a parameter from the operation
func (*Operation) RespondsWith ¶
RespondsWith adds a status code response to the operation. When the code is 0 the value of the response will be used as default response value. When the value of the response is nil it will be removed from the operation
func (*Operation) SecuredWith ¶
SecuredWith adds a security scope to this operation.
func (*Operation) SuccessResponse ¶
SuccessResponse gets a success response model
func (*Operation) Undeprecate ¶
Undeprecate marks the operation as not deprecated
func (*Operation) UnmarshalJSON ¶
UnmarshalJSON hydrates this items instance with the data from JSON
func (*Operation) WithConsumes ¶
WithConsumes is deprecated in OpenAPI v3 - use RequestBody with Content instead Kept for backward compatibility but does nothing in v3
func (*Operation) WithDefaultResponse ¶
WithDefaultResponse adds a default response to the operation. Passing a nil value will remove the response
func (*Operation) WithDescription ¶
WithDescription sets the description on this operation, allows for chaining
func (*Operation) WithExternalDocs ¶
WithExternalDocs sets/removes the external docs for/from this operation. When you pass empty strings as params the external documents will be removed. When you pass non-empty string as one value then those values will be used on the external docs object. So when you pass a non-empty description, you should also pass the url and vice versa.
func (*Operation) WithProduces ¶
WithProduces is deprecated in OpenAPI v3 - use Response with Content instead Kept for backward compatibility but does nothing in v3
func (*Operation) WithSummary ¶
WithSummary sets the summary on this operation, allows for chaining
type OperationProps ¶
type OperationProps struct {
Tags []string `json:"tags,omitempty"`
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
ID string `json:"operationId,omitempty"`
Parameters []Parameter `json:"parameters,omitempty"`
RequestBody *RequestBody `json:"requestBody,omitempty"`
Responses *Responses `json:"responses,omitempty"`
Callbacks map[string]Callback `json:"callbacks,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
Security []map[string][]string `json:"security,omitempty"`
Servers []Server `json:"servers,omitempty"`
// Deprecated Swagger 2.0 fields (kept for backward compatibility)
// In OpenAPI 3.x, content types are specified in RequestBody and Response media types
Consumes []string `json:"-"`
Produces []string `json:"-"`
}
OperationProps describes an operation (OpenAPI v3)
NOTES: - Security is handled as a special case: see MarshalJSON function - consumes/produces/schemes removed in v3 (moved to media types and servers)
func (*OperationProps) GobDecode ¶
func (op *OperationProps) GobDecode(b []byte) error
GobDecode provides a safe gob decoder for Operation, including empty security requirements
func (OperationProps) GobEncode ¶
func (op OperationProps) GobEncode() ([]byte, error)
GobEncode provides a safe gob encoder for Operation, including empty security requirements
func (OperationProps) MarshalJSON ¶
func (op OperationProps) MarshalJSON() ([]byte, error)
MarshalJSON takes care of serializing operation properties to JSON
We use a custom marhaller here to handle a special cases related to the Security field. We need to preserve zero length slice while omitting the field when the value is nil/unset.
type OrderSchemaItem ¶
OrderSchemaItem holds a named schema (e.g. from a property of an object)
type OrderSchemaItems ¶
type OrderSchemaItems []OrderSchemaItem
OrderSchemaItems is a sortable slice of named schemas. The ordering is defined by the x-order schema extension.
func (OrderSchemaItems) Len ¶
func (items OrderSchemaItems) Len() int
func (OrderSchemaItems) Less ¶
func (items OrderSchemaItems) Less(i, j int) (ret bool)
func (OrderSchemaItems) MarshalJSON ¶
func (items OrderSchemaItems) MarshalJSON() ([]byte, error)
MarshalJSON produces a json object with keys defined by the name schemas of the OrderSchemaItems slice, keeping the original order of the slice.
func (OrderSchemaItems) Swap ¶
func (items OrderSchemaItems) Swap(i, j int)
type ParamProps ¶
type ParamProps struct {
Name string `json:"name,omitempty"`
In string `json:"in,omitempty"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
Deprecated bool `json:"deprecated,omitempty"`
AllowEmptyValue bool `json:"allowEmptyValue,omitempty"`
Style string `json:"style,omitempty"`
Explode *bool `json:"explode,omitempty"`
AllowReserved bool `json:"allowReserved,omitempty"`
Schema *Schema `json:"schema,omitempty"`
Example any `json:"example,omitempty"`
Examples map[string]Example `json:"examples,omitempty"`
Content map[string]MediaType `json:"content,omitempty"`
}
ParamProps describes the specific attributes of an operation parameter (OpenAPI v3)
NOTE: - In OpenAPI v3, valid values for "in" are: query, header, path, cookie - body and formData are replaced by requestBody - Schema is now used for all parameter types (not just body) - AllowEmptyValue is allowed where "in" == "query"
type Parameter ¶
type Parameter struct {
Refable
CommonValidations
SimpleSchema
VendorExtensible
ParamProps
}
Parameter a unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn).
In OpenAPI v3, there are four possible parameter locations (in):
- Path - Used together with Path Templating, where the parameter value is actually part of the operation's URL. This does not include the host or base path of the API. For example, in `/items/{itemId}`, the path parameter is `itemId`.
- Query - Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`.
- Header - Custom headers that are expected as part of the request.
- Cookie - Used to pass a specific cookie value to the API.
For more information: https://spec.openapis.org/oas/v3.1.0#parameter-object
func BodyParam ¶
BodyParam is deprecated in OpenAPI v3 - use RequestBody instead Kept for backward compatibility but should not be used
func FileParam ¶
FileParam is deprecated in OpenAPI v3 - use RequestBody with multipart/form-data media type Kept for backward compatibility but should not be used
func FormDataParam ¶
FormDataParam is deprecated in OpenAPI v3 - use RequestBody with appropriate media type Kept for backward compatibility but should not be used
func HeaderParam ¶
HeaderParam creates a header parameter, this is always required by default
func ResolveParameter ¶
ResolveParameter resolves a parameter reference against a context root
func ResolveParameterWithBase ¶
func ResolveParameterWithBase(root any, ref Ref, options *ExpandOptions) (*Parameter, error)
ResolveParameterWithBase resolves a parameter reference against a context root and base path
func SimpleArrayParam ¶
SimpleArrayParam creates a param for a simple array (string, int, date etc)
func (*Parameter) AllowDuplicates ¶
AllowDuplicates this array can have duplicates
func (*Parameter) AllowsEmptyValues ¶
AllowsEmptyValues flags this parameter as being ok with empty values
func (*Parameter) AsOptional ¶
AsOptional flags this parameter as optional
func (*Parameter) AsRequired ¶
AsRequired flags this parameter as required
func (*Parameter) CollectionOf ¶
CollectionOf a fluent builder method for an array parameter
func (Parameter) JSONLookup ¶
JSONLookup look up a value by the json property name
func (Parameter) MarshalJSON ¶
MarshalJSON converts this items object to JSON
func (*Parameter) NoEmptyValues ¶
NoEmptyValues flags this parameter as not liking empty values
func (*Parameter) UniqueValues ¶
UniqueValues dictates that this array can only have unique items
func (*Parameter) UnmarshalJSON ¶
UnmarshalJSON hydrates this items instance with the data from JSON
func (*Parameter) WithDefault ¶
WithDefault sets the default value on this parameter
func (*Parameter) WithDescription ¶
WithDescription a fluent builder method for the description of the parameter
func (*Parameter) WithLocation ¶
WithLocation a fluent builder method to override the location of the parameter
func (*Parameter) WithMaxItems ¶
WithMaxItems sets the max items
func (*Parameter) WithMaxLength ¶
WithMaxLength sets a max length value
func (*Parameter) WithMaximum ¶
WithMaximum sets a maximum number value
func (*Parameter) WithMinItems ¶
WithMinItems sets the min items
func (*Parameter) WithMinLength ¶
WithMinLength sets a min length value
func (*Parameter) WithMinimum ¶
WithMinimum sets a minimum number value
func (*Parameter) WithMultipleOf ¶
WithMultipleOf sets a multiple of value
func (*Parameter) WithPattern ¶
WithPattern sets a pattern value
func (*Parameter) WithValidations ¶
func (p *Parameter) WithValidations(val CommonValidations) *Parameter
WithValidations is a fluent method to set parameter validations
type PathItem ¶
type PathItem struct {
Refable
VendorExtensible
PathItemProps
}
PathItem describes the operations available on a single path. A Path Item may be empty, due to [ACL constraints](http://goo.gl/8us55a#securityFiltering). The path itself is still exposed to the documentation viewer but they will not know which operations and parameters are available.
For more information: http://goo.gl/8us55a#pathItemObject
func ResolvePathItem
deprecated
func ResolvePathItem(root any, ref Ref, options *ExpandOptions) (*PathItem, error)
ResolvePathItem resolves response a path item against a context root and base path
Deprecated: use ResolvePathItemWithBase instead
func ResolvePathItemWithBase ¶
func ResolvePathItemWithBase(root any, ref Ref, options *ExpandOptions) (*PathItem, error)
ResolvePathItemWithBase resolves response a path item against a context root and base path
func (PathItem) JSONLookup ¶
JSONLookup look up a value by the json property name
func (PathItem) MarshalJSON ¶
MarshalJSON converts this items object to JSON
func (*PathItem) UnmarshalJSON ¶
UnmarshalJSON hydrates this items instance with the data from JSON
type PathItemProps ¶
type PathItemProps struct {
Get *Operation `json:"get,omitempty"`
Put *Operation `json:"put,omitempty"`
Post *Operation `json:"post,omitempty"`
Delete *Operation `json:"delete,omitempty"`
Options *Operation `json:"options,omitempty"`
Head *Operation `json:"head,omitempty"`
Patch *Operation `json:"patch,omitempty"`
Parameters []Parameter `json:"parameters,omitempty"`
}
PathItemProps the path item specific properties
type Paths ¶
type Paths struct {
VendorExtensible
Paths map[string]PathItem `json:"-"` // custom serializer to flatten this, each entry must start with "/"
}
Paths holds the relative paths to the individual endpoints. The path is appended to the [`basePath`](http://goo.gl/8us55a#swaggerBasePath) in order to construct the full URL. The Paths may be empty, due to [ACL constraints](http://goo.gl/8us55a#securityFiltering).
For more information: http://goo.gl/8us55a#pathsObject
func (Paths) JSONLookup ¶
JSONLookup look up a value by the json property name
func (Paths) MarshalJSON ¶
MarshalJSON converts this items object to JSON
func (*Paths) UnmarshalJSON ¶
UnmarshalJSON hydrates this items instance with the data from JSON
type PatternSchemaProperties ¶
type PatternSchemaProperties map[string]SchemaOrBool
PatternSchemaProperties is a map representing pattern properties of a Schema object. In JSON Schema 2020-12, pattern property values can be either a schema or a boolean.
func (PatternSchemaProperties) MarshalJSON ¶
func (properties PatternSchemaProperties) MarshalJSON() ([]byte, error)
MarshalJSON produces pattern properties as json.
type Ref ¶
type Ref struct {
jsonreference.Ref
}
Ref represents a json reference that is potentially resolved
func MustCreateRef ¶
MustCreateRef creates a ref object but panics when refURI is invalid. Use the NewRef method for a version that returns an error.
func NewRef ¶
NewRef creates a new instance of a ref object returns an error when the reference uri is an invalid uri
func (*Ref) Inherits ¶
Inherits creates a new reference from a parent and a child If the child cannot inherit from the parent, an error is returned
func (*Ref) IsValidURI ¶
IsValidURI returns true when the url the ref points to can be found
func (Ref) MarshalJSON ¶
MarshalJSON marshals this ref into a JSON object
func (*Ref) UnmarshalJSON ¶
UnmarshalJSON unmarshals this ref from a JSON object
type Refable ¶
type Refable struct {
Ref Ref
}
Refable is a struct for things that accept a $ref property
func (Refable) MarshalJSON ¶
MarshalJSON marshals the ref to json
func (*Refable) UnmarshalJSON ¶
UnmarshalJSON unmarshals the ref from json
type RequestBody ¶
type RequestBody struct {
Refable
VendorExtensible
RequestBodyProps
}
RequestBody describes a single request body.
For more information: https://spec.openapis.org/oas/v3.1.0#request-body-object
func (RequestBody) JSONLookup ¶
func (r RequestBody) JSONLookup(token string) (any, error)
JSONLookup look up a value by the json property name
func (RequestBody) MarshalJSON ¶
func (r RequestBody) MarshalJSON() ([]byte, error)
MarshalJSON marshals this to JSON
func (*RequestBody) UnmarshalJSON ¶
func (r *RequestBody) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals this from JSON
type RequestBodyProps ¶
type RequestBodyProps struct {
Description string `json:"description,omitempty"`
Content map[string]MediaType `json:"content"`
Required bool `json:"required,omitempty"`
}
RequestBodyProps describes the properties of a RequestBody
type ResolutionCache ¶
ResolutionCache a cache for resolving urls
type Response ¶
type Response struct {
Refable
ResponseProps
VendorExtensible
}
Response describes a single response from an API Operation.
For more information: https://spec.openapis.org/oas/v3.1.0#response-object
func ResolveResponse ¶
ResolveResponse resolves response a reference against a context root
func ResolveResponseWithBase ¶
func ResolveResponseWithBase(root any, ref Ref, options *ExpandOptions) (*Response, error)
ResolveResponseWithBase resolves response a reference against a context root and base path
func ResponseRef ¶
ResponseRef creates a response as a json reference
func (*Response) AddExample ¶
AddExample adds an example to this response
func (Response) JSONLookup ¶
JSONLookup look up a value by the json property name
func (Response) MarshalJSON ¶
MarshalJSON converts this items object to JSON
func (*Response) RemoveHeader ¶
RemoveHeader removes a header from this response
func (*Response) UnmarshalJSON ¶
UnmarshalJSON hydrates this items instance with the data from JSON
func (*Response) WithDescription ¶
WithDescription sets the description on this response, allows for chaining
func (*Response) WithSchema ¶
WithSchema sets the schema on this response, allows for chaining. Passing a nil argument removes the schema from this response
type ResponseProps ¶
type ResponseProps struct {
Description string `json:"description"`
Headers map[string]Header `json:"headers,omitempty"`
Content map[string]MediaType `json:"content,omitempty"`
Links map[string]Link `json:"links,omitempty"`
// Schema is deprecated in OpenAPI v3, use Content instead
Schema *Schema `json:"schema,omitempty"`
// Examples changed structure in v3, kept for backward compatibility
Examples map[string]any `json:"examples,omitempty"`
}
ResponseProps properties specific to a response (OpenAPI v3)
type Responses ¶
type Responses struct {
VendorExtensible
ResponsesProps
}
Responses is a container for the expected responses of an operation. The container maps a HTTP response code to the expected response. It is not expected from the documentation to necessarily cover all possible HTTP response codes, since they may not be known in advance. However, it is expected from the documentation to cover a successful operation response and any known errors.
The `default` can be used a default response object for all HTTP codes that are not covered individually by the specification.
The `Responses Object` MUST contain at least one response code, and it SHOULD be the response for a successful operation call.
For more information: http://goo.gl/8us55a#responsesObject
func (Responses) JSONLookup ¶
JSONLookup implements an interface to customize json pointer lookup
func (Responses) MarshalJSON ¶
MarshalJSON converts this items object to JSON
func (*Responses) UnmarshalJSON ¶
UnmarshalJSON hydrates this items instance with the data from JSON
type ResponsesProps ¶
ResponsesProps describes all responses for an operation. It tells what is the default response and maps all responses with a HTTP status code.
func (ResponsesProps) MarshalJSON ¶
func (r ResponsesProps) MarshalJSON() ([]byte, error)
MarshalJSON marshals responses as JSON
func (*ResponsesProps) UnmarshalJSON ¶
func (r *ResponsesProps) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals responses from JSON
type Schema ¶
type Schema struct {
VendorExtensible
SchemaProps
SwaggerSchemaProps
ExtraProps map[string]any `json:"-"`
}
Schema the schema object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is based on the [JSON Schema Specification Draft 4](http://json-schema.org/) and uses a predefined subset of it. On top of this subset, there are extensions provided by this specification to allow for more complete documentation.
For more information: http://goo.gl/8us55a#schemaObject
func ArrayProperty ¶
ArrayProperty creates an array property
func ComposedSchema ¶
ComposedSchema creates a schema with allOf
func DateTimeProperty ¶
func DateTimeProperty() *Schema
DateTimeProperty creates a date time property
func Float32Property ¶
func Float32Property() *Schema
Float32Property creates a float32/float property
func Float64Property ¶
func Float64Property() *Schema
Float64Property creates a float64/double property
func JSONSchemaDraft04 ¶
JSONSchemaDraft04 loads the json schema document for json schema draft04
func MustLoadJSONSchemaDraft04 ¶
func MustLoadJSONSchemaDraft04() *Schema
MustLoadJSONSchemaDraft04 panics when Swagger20Schema returns an error
func MustLoadOpenAPI32Schema ¶
func MustLoadOpenAPI32Schema() *Schema
MustLoadOpenAPI32Schema panics when OpenAPI32Schema returns an error
func MustLoadSwagger20Schema ¶
func MustLoadSwagger20Schema() *Schema
MustLoadSwagger20Schema panics when Swagger20Schema returns an error
func OpenAPI32Schema ¶
OpenAPI32Schema loads the OpenAPI 3.2 schema from the embedded assets
func ResolveRef ¶
ResolveRef resolves a reference for a schema against a context root ref is guaranteed to be in root (no need to go to external files)
ResolveRef is ONLY called from the code generation module
func ResolveRefWithBase ¶
func ResolveRefWithBase(root any, ref *Ref, options *ExpandOptions) (*Schema, error)
ResolveRefWithBase resolves a reference against a context root with preservation of base path
func StrFmtProperty ¶
StrFmtProperty creates a property for the named string format
func Swagger20Schema ¶
Swagger20Schema loads the swagger 2.0 schema from the embedded assets
func (*Schema) AddRequired ¶
AddRequired adds field names to the required properties array
func (*Schema) AddToAllOf ¶
AddToAllOf adds a schema to the allOf property
func (*Schema) AllowDuplicates ¶
AllowDuplicates this array can have duplicates
func (*Schema) AsNullable ¶
AsNullable flags this schema as nullable.
func (*Schema) AsReadOnly ¶
AsReadOnly flags this schema as readonly
func (*Schema) AsUnwrappedXML ¶
AsUnwrappedXML flags this object as an xml node
func (*Schema) AsWrappedXML ¶
AsWrappedXML flags this object as wrapped, this is mostly useful for array types
func (*Schema) AsWritable ¶
AsWritable flags this schema as writeable (not read-only)
func (*Schema) AsXMLAttribute ¶
AsXMLAttribute flags this object as xml attribute
func (*Schema) AsXMLElement ¶
AsXMLElement flags this object as an xml node
func (*Schema) CollectionOf ¶
CollectionOf a fluent builder method for an array parameter
func (Schema) JSONLookup ¶
JSONLookup implements an interface to customize json pointer lookup
func (Schema) MarshalJSON ¶
MarshalJSON marshal this to JSON
func (*Schema) SetProperty ¶
SetProperty sets a property on this schema
func (*Schema) SetValidations ¶
func (s *Schema) SetValidations(val SchemaValidations)
SetValidations defines all schema validations.
NOTE: Required, ReadOnly, AllOf, AnyOf, OneOf and Not are not considered.
func (*Schema) UniqueValues ¶
UniqueValues dictates that this array can only have unique items
func (*Schema) UnmarshalJSON ¶
UnmarshalJSON marshal this from JSON
func (Schema) Validations ¶
func (s Schema) Validations() SchemaValidations
Validations returns a clone of the validations for this schema
func (*Schema) WithDefault ¶
WithDefault sets the default value on this parameter
func (*Schema) WithDescription ¶
WithDescription sets the description for this schema, allows for chaining
func (*Schema) WithDiscriminator ¶
WithDiscriminator sets the name of the discriminator field
func (*Schema) WithExample ¶
WithExample sets the example for this schema
func (*Schema) WithExternalDocs ¶
WithExternalDocs sets/removes the external docs for/from this schema. When you pass empty strings as params the external documents will be removed. When you pass non-empty string as one value then those values will be used on the external docs object. So when you pass a non-empty description, you should also pass the url and vice versa.
func (*Schema) WithMaxItems ¶
WithMaxItems sets the max items
func (*Schema) WithMaxLength ¶
WithMaxLength sets a max length value
func (*Schema) WithMaxProperties ¶
WithMaxProperties sets the max number of properties an object can have
func (*Schema) WithMaximum ¶
WithMaximum sets a maximum number value
func (*Schema) WithMinItems ¶
WithMinItems sets the min items
func (*Schema) WithMinLength ¶
WithMinLength sets a min length value
func (*Schema) WithMinProperties ¶
WithMinProperties sets the min number of properties an object must have
func (*Schema) WithMinimum ¶
WithMinimum sets a minimum number value
func (*Schema) WithMultipleOf ¶
WithMultipleOf sets a multiple of value
func (*Schema) WithPattern ¶
WithPattern sets a pattern value
func (*Schema) WithProperties ¶
WithProperties sets the properties for this schema
func (*Schema) WithRequired ¶
WithRequired flags this parameter as required
func (*Schema) WithValidations ¶
func (s *Schema) WithValidations(val SchemaValidations) *Schema
WithValidations is a fluent method to set schema validations
func (*Schema) WithXMLName ¶
WithXMLName sets the xml name for the object
func (*Schema) WithXMLNamespace ¶
WithXMLNamespace sets the xml namespace for the object
func (*Schema) WithXMLPrefix ¶
WithXMLPrefix sets the xml prefix for the object
type SchemaOrArray ¶
SchemaOrArray represents a value that can either be a Schema or an array of Schema. Mainly here for serialization purposes
func (*SchemaOrArray) ContainsType ¶
func (s *SchemaOrArray) ContainsType(name string) bool
ContainsType returns true when one of the schemas is of the specified type
func (SchemaOrArray) JSONLookup ¶
func (s SchemaOrArray) JSONLookup(token string) (any, error)
JSONLookup implements an interface to customize json pointer lookup
func (SchemaOrArray) Len ¶
func (s SchemaOrArray) Len() int
Len returns the number of schemas in this property
func (SchemaOrArray) MarshalJSON ¶
func (s SchemaOrArray) MarshalJSON() ([]byte, error)
MarshalJSON converts this schema object or array into JSON structure
func (*SchemaOrArray) UnmarshalJSON ¶
func (s *SchemaOrArray) UnmarshalJSON(data []byte) error
UnmarshalJSON converts this schema object or array from a JSON structure
type SchemaOrBool ¶
SchemaOrBool represents a schema or boolean value, is biased towards true for the boolean property
func (SchemaOrBool) JSONLookup ¶
func (s SchemaOrBool) JSONLookup(token string) (any, error)
JSONLookup implements an interface to customize json pointer lookup
func (SchemaOrBool) MarshalJSON ¶
func (s SchemaOrBool) MarshalJSON() ([]byte, error)
MarshalJSON convert this object to JSON
func (*SchemaOrBool) UnmarshalJSON ¶
func (s *SchemaOrBool) UnmarshalJSON(data []byte) error
UnmarshalJSON converts this bool or schema object from a JSON structure
type SchemaOrStringArray ¶
SchemaOrStringArray represents a schema or a string array
func (SchemaOrStringArray) JSONLookup ¶
func (s SchemaOrStringArray) JSONLookup(token string) (any, error)
JSONLookup implements an interface to customize json pointer lookup
func (SchemaOrStringArray) MarshalJSON ¶
func (s SchemaOrStringArray) MarshalJSON() ([]byte, error)
MarshalJSON converts this schema object or array into JSON structure
func (*SchemaOrStringArray) UnmarshalJSON ¶
func (s *SchemaOrStringArray) UnmarshalJSON(data []byte) error
UnmarshalJSON converts this schema object or array from a JSON structure
type SchemaProperties ¶
SchemaProperties is a map representing the properties of a Schema object. It knows how to transform its keys into an ordered slice.
func (SchemaProperties) MarshalJSON ¶
func (properties SchemaProperties) MarshalJSON() ([]byte, error)
MarshalJSON produces properties as json, keeping their order.
func (SchemaProperties) ToOrderedSchemaItems ¶
func (properties SchemaProperties) ToOrderedSchemaItems() OrderSchemaItems
ToOrderedSchemaItems transforms the map of properties into a sortable slice
func (*SchemaProperties) UnmarshalJSON ¶
func (properties *SchemaProperties) UnmarshalJSON(data []byte) error
UnmarshalJSON handles JSON Schema 2020-12 where property values can be either a schema object or a boolean (true/false). Boolean values are converted to empty schemas with appropriate semantics (true = allows any, false = allows none).
type SchemaProps ¶
type SchemaProps struct {
ID string `json:"id,omitempty"`
Ref Ref `json:"-"`
Schema SchemaURL `json:"-"`
Description string `json:"description,omitempty"`
Type StringOrArray `json:"type,omitempty"`
Nullable *bool `json:"nullable,omitempty"`
Format string `json:"format,omitempty"`
Title string `json:"title,omitempty"`
Default any `json:"default,omitempty"`
Maximum *float64 `json:"maximum,omitempty"`
ExclusiveMaximum bool `json:"exclusiveMaximum,omitempty"`
Minimum *float64 `json:"minimum,omitempty"`
ExclusiveMinimum bool `json:"exclusiveMinimum,omitempty"`
MaxLength *int64 `json:"maxLength,omitempty"`
MinLength *int64 `json:"minLength,omitempty"`
Pattern string `json:"pattern,omitempty"`
MaxItems *int64 `json:"maxItems,omitempty"`
MinItems *int64 `json:"minItems,omitempty"`
UniqueItems bool `json:"uniqueItems,omitempty"`
MultipleOf *float64 `json:"multipleOf,omitempty"`
Enum []any `json:"enum,omitempty"`
MaxProperties *int64 `json:"maxProperties,omitempty"`
MinProperties *int64 `json:"minProperties,omitempty"`
Required []string `json:"required,omitempty"`
Items *SchemaOrArray `json:"items,omitempty"`
AllOf []Schema `json:"allOf,omitempty"`
OneOf []Schema `json:"oneOf,omitempty"`
AnyOf []Schema `json:"anyOf,omitempty"`
Not *Schema `json:"not,omitempty"`
Properties SchemaProperties `json:"properties,omitempty"`
AdditionalProperties *SchemaOrBool `json:"additionalProperties,omitempty"`
PatternProperties PatternSchemaProperties `json:"patternProperties,omitempty"`
Dependencies Dependencies `json:"dependencies,omitempty"`
AdditionalItems *SchemaOrBool `json:"additionalItems,omitempty"`
Definitions Definitions `json:"definitions,omitempty"`
Defs Definitions `json:"$defs,omitempty"` // JSON Schema 2020-12
}
SchemaProps describes a JSON schema (draft 4)
type SchemaURL ¶
type SchemaURL string
SchemaURL represents a schema url
func (SchemaURL) MarshalJSON ¶
MarshalJSON marshal this to JSON
func (*SchemaURL) UnmarshalJSON ¶
UnmarshalJSON unmarshal this from JSON
type SchemaValidations ¶
type SchemaValidations struct {
CommonValidations
PatternProperties PatternSchemaProperties `json:"patternProperties,omitempty"`
MaxProperties *int64 `json:"maxProperties,omitempty"`
MinProperties *int64 `json:"minProperties,omitempty"`
}
SchemaValidations describes the validation properties of a schema
NOTE: at this moment, this is not embedded in SchemaProps because this would induce a breaking change in the exported members: all initializers using literals would fail.
func (*SchemaValidations) ClearObjectValidations ¶
func (v *SchemaValidations) ClearObjectValidations(cbs ...func(string, any))
ClearObjectValidations returns a clone of the validations with all object validations cleared.
Some callbacks may be set by the caller to capture changed values.
func (SchemaValidations) HasObjectValidations ¶
func (v SchemaValidations) HasObjectValidations() bool
HasObjectValidations indicates if the validations are for objects
func (*SchemaValidations) SetValidations ¶
func (v *SchemaValidations) SetValidations(val SchemaValidations)
SetValidations for schema validations
func (SchemaValidations) Validations ¶
func (v SchemaValidations) Validations() SchemaValidations
Validations for a schema
type SecurityDefinitions ¶
type SecurityDefinitions map[string]*SecurityScheme
SecurityDefinitions a declaration of the security schemes available to be used in the specification. This does not enforce the security schemes on the operations and only serves to provide the relevant details for each scheme.
For more information: http://goo.gl/8us55a#securityDefinitionsObject
type SecurityScheme ¶
type SecurityScheme struct {
VendorExtensible
SecuritySchemeProps
}
SecurityScheme allows the definition of a security scheme that can be used by the operations.
OpenAPI v3 supported schemes: - http: HTTP authentication (basic, bearer, etc.) - apiKey: API key (header, query, or cookie) - oauth2: OAuth 2.0 flows (implicit, password, clientCredentials, authorizationCode) - openIdConnect: OpenID Connect Discovery
OpenAPI v2 (deprecated) schemes: - basic: Basic authentication (use "http" with scheme="basic" in v3) - apiKey: API key - oauth2: OAuth 2.0 (use Flows in v3)
For more information: https://spec.openapis.org/oas/v3.0.3#security-scheme-object
func APIKeyAuth ¶
func APIKeyAuth(fieldName, valueSource string) *SecurityScheme
APIKeyAuth creates an api key auth security scheme
func OAuth2AccessToken ¶
func OAuth2AccessToken(authorizationURL, tokenURL string) *SecurityScheme
OAuth2AccessToken creates an access token flow oauth2 security scheme
func OAuth2Application ¶
func OAuth2Application(tokenURL string) *SecurityScheme
OAuth2Application creates an application flow oauth2 security scheme
func OAuth2Implicit ¶
func OAuth2Implicit(authorizationURL string) *SecurityScheme
OAuth2Implicit creates an implicit flow oauth2 security scheme
func OAuth2Password ¶
func OAuth2Password(tokenURL string) *SecurityScheme
OAuth2Password creates a password flow oauth2 security scheme
func (SecurityScheme) JSONLookup ¶
func (s SecurityScheme) JSONLookup(token string) (any, error)
JSONLookup implements an interface to customize json pointer lookup
func (SecurityScheme) MarshalJSON ¶
func (s SecurityScheme) MarshalJSON() ([]byte, error)
MarshalJSON marshal this to JSON
func (*SecurityScheme) UnmarshalJSON ¶
func (s *SecurityScheme) UnmarshalJSON(data []byte) error
UnmarshalJSON marshal this from JSON
type SecuritySchemeProps ¶
type SecuritySchemeProps struct {
Description string `json:"description,omitempty"`
Type string `json:"type"`
Name string `json:"name,omitempty"` // apiKey
In string `json:"in,omitempty"` // apiKey, http
Scheme string `json:"scheme,omitempty"` // http (e.g., "basic", "bearer")
BearerFormat string `json:"bearerFormat,omitempty"` // http bearer
OpenIdConnectURL string `json:"openIdConnectUrl,omitempty"` // openIdConnect
Flows *OAuthFlows `json:"flows,omitempty"` // oauth2
// Deprecated OpenAPI v2 fields (kept for backward compatibility during migration)
Flow string `json:"flow,omitempty"` // Deprecated: use Flows
AuthorizationURL string `json:"authorizationUrl,omitempty"` // Deprecated: use Flows
TokenURL string `json:"tokenUrl,omitempty"` // Deprecated: use Flows
Scopes map[string]string `json:"scopes,omitempty"` // Deprecated: use Flows
}
SecuritySchemeProps describes an OpenAPI v3 security scheme in the components/securitySchemes section
func (*SecuritySchemeProps) AddScope ¶
func (s *SecuritySchemeProps) AddScope(scope, description string)
AddScope adds a scope to this security scheme For v2 backward compatibility, it adds to the deprecated Scopes field For v3, scopes should be added to the appropriate flow in Flows
type Server ¶
type Server struct {
VendorExtensible
ServerProps
}
Server represents a Server.
For more information: https://spec.openapis.org/oas/v3.1.0#server-object
func (Server) JSONLookup ¶
JSONLookup look up a value by the json property name
func (Server) MarshalJSON ¶
MarshalJSON marshals this to JSON
func (*Server) UnmarshalJSON ¶
UnmarshalJSON unmarshals this from JSON
type ServerProps ¶
type ServerProps struct {
URL string `json:"url"`
Description string `json:"description,omitempty"`
Variables map[string]ServerVariable `json:"variables,omitempty"`
}
ServerProps describes the properties of a Server
type ServerVariable ¶
type ServerVariable struct {
VendorExtensible
ServerVariableProps
}
ServerVariable represents a Server Variable for server URL template substitution.
For more information: https://spec.openapis.org/oas/v3.1.0#server-variable-object
func (ServerVariable) JSONLookup ¶
func (s ServerVariable) JSONLookup(token string) (any, error)
JSONLookup look up a value by the json property name
func (ServerVariable) MarshalJSON ¶
func (s ServerVariable) MarshalJSON() ([]byte, error)
MarshalJSON marshals this to JSON
func (*ServerVariable) UnmarshalJSON ¶
func (s *ServerVariable) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals this from JSON
type ServerVariableProps ¶
type ServerVariableProps struct {
Enum []string `json:"enum,omitempty"`
Default string `json:"default"`
Description string `json:"description,omitempty"`
}
ServerVariableProps describes the properties of a Server Variable
type SimpleSchema ¶
type SimpleSchema struct {
Type string `json:"type,omitempty"`
Nullable bool `json:"nullable,omitempty"`
Format string `json:"format,omitempty"`
Items *Items `json:"items,omitempty"`
CollectionFormat string `json:"collectionFormat,omitempty"`
Default any `json:"default,omitempty"`
Example any `json:"example,omitempty"`
}
SimpleSchema describe swagger simple schemas for parameters and headers
func (*SimpleSchema) ItemsTypeName ¶
func (s *SimpleSchema) ItemsTypeName() string
ItemsTypeName yields the type of items in a simple schema array
func (*SimpleSchema) TypeName ¶
func (s *SimpleSchema) TypeName() string
TypeName return the type (or format) of a simple schema
type StringOrArray ¶
type StringOrArray []string
StringOrArray represents a value that can either be a string or an array of strings. Mainly here for serialization purposes
func (StringOrArray) Contains ¶
func (s StringOrArray) Contains(value string) bool
Contains returns true when the value is contained in the slice
func (StringOrArray) MarshalJSON ¶
func (s StringOrArray) MarshalJSON() ([]byte, error)
MarshalJSON converts this string or array to a JSON array or JSON string
func (*StringOrArray) UnmarshalJSON ¶
func (s *StringOrArray) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals this string or array object from a JSON array or JSON string
type Swagger ¶
type Swagger struct {
VendorExtensible
SwaggerProps
}
Swagger this is the root document object for the API specification (now OpenAPI v3). This structure represents an OpenAPI v3.x document.
For more information: https://spec.openapis.org/oas/v3.1.0#openapi-object
func (Swagger) JSONLookup ¶
JSONLookup look up a value by the json property name
func (Swagger) MarshalJSON ¶
MarshalJSON marshals this swagger structure to json
func (*Swagger) UnmarshalJSON ¶
UnmarshalJSON unmarshals a swagger spec from json
type SwaggerProps ¶
type SwaggerProps struct {
ID string `json:"id,omitempty"`
OpenAPI string `json:"openapi"`
Info *Info `json:"info"`
JSONSchemaDialect string `json:"jsonSchemaDialect,omitempty"`
Servers []Server `json:"servers,omitempty"`
Paths *Paths `json:"paths"`
Webhooks map[string]PathItem `json:"webhooks,omitempty"`
Components *Components `json:"components,omitempty"`
Security []map[string][]string `json:"security,omitempty"`
Tags []Tag `json:"tags,omitempty"`
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
// Deprecated Swagger 2.0 fields (kept for backward compatibility)
// In OpenAPI 3.x these map to different locations:
// - Definitions -> Components.Schemas
// - Parameters -> Components.Parameters
// - Responses -> Components.Responses
// - SecurityDefinitions -> Components.SecuritySchemes
// - Consumes/Produces are now in individual operations or media types
// - Host/BasePath/Schemes -> Servers
// These fields are kept for backward compatibility with Swagger 2.0 specs
Swagger string `json:"swagger,omitempty"` // Swagger 2.0 version field
Definitions Definitions `json:"definitions,omitempty"`
Parameters map[string]Parameter `json:"parameters,omitempty"`
Responses map[string]Response `json:"responses,omitempty"`
SecurityDefinitions SecurityDefinitions `json:"securityDefinitions,omitempty"`
Consumes []string `json:"consumes,omitempty"`
Produces []string `json:"produces,omitempty"`
Host string `json:"host,omitempty"`
BasePath string `json:"basePath,omitempty"`
Schemes []string `json:"schemes,omitempty"`
}
SwaggerProps captures the top-level properties of an OpenAPI v3 specification
NOTE: validation rules - OpenAPI version is required - Info is required - Paths is required (can be empty)
func (*SwaggerProps) GobDecode ¶
func (o *SwaggerProps) GobDecode(b []byte) error
GobDecode provides a safe gob decoder for SwaggerProps, including empty security requirements
func (SwaggerProps) GobEncode ¶
func (o SwaggerProps) GobEncode() ([]byte, error)
GobEncode provides a safe gob encoder for SwaggerProps, including empty security requirements
type SwaggerSchemaProps ¶
type SwaggerSchemaProps struct {
Discriminator string `json:"discriminator,omitempty"`
ReadOnly bool `json:"readOnly,omitempty"`
XML *XMLObject `json:"xml,omitempty"`
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
Example any `json:"example,omitempty"`
}
SwaggerSchemaProps are additional properties supported by swagger schemas, but not JSON-schema (draft 4)
type Tag ¶
type Tag struct {
VendorExtensible
TagProps
}
Tag allows adding meta data to a single tag that is used by the [Operation Object](http://goo.gl/8us55a#operationObject). It is not mandatory to have a Tag Object per tag used there.
For more information: http://goo.gl/8us55a#tagObject
func NewTag ¶
func NewTag(name, description string, externalDocs *ExternalDocumentation) Tag
NewTag creates a new tag
func (Tag) JSONLookup ¶
JSONLookup implements an interface to customize json pointer lookup
func (Tag) MarshalJSON ¶
MarshalJSON marshal this to JSON
func (*Tag) UnmarshalJSON ¶
UnmarshalJSON marshal this from JSON
type TagProps ¶
type TagProps struct {
Description string `json:"description,omitempty"`
Name string `json:"name,omitempty"`
ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
}
TagProps describe a tag entry in the top level tags section of a swagger spec
type VendorExtensible ¶
type VendorExtensible struct {
Extensions Extensions
}
VendorExtensible composition block.
func (*VendorExtensible) AddExtension ¶
func (v *VendorExtensible) AddExtension(key string, value any)
AddExtension adds an extension to this extensible object
func (VendorExtensible) MarshalJSON ¶
func (v VendorExtensible) MarshalJSON() ([]byte, error)
MarshalJSON marshals the extensions to json
func (*VendorExtensible) UnmarshalJSON ¶
func (v *VendorExtensible) UnmarshalJSON(data []byte) error
UnmarshalJSON for this extensible object
type XMLObject ¶
type XMLObject struct {
Name string `json:"name,omitempty"`
Namespace string `json:"namespace,omitempty"`
Prefix string `json:"prefix,omitempty"`
Attribute bool `json:"attribute,omitempty"`
Wrapped bool `json:"wrapped,omitempty"`
}
XMLObject a metadata object that allows for more fine-tuned XML model definitions.
For more information: http://goo.gl/8us55a#xmlObject
func (*XMLObject) AsAttribute ¶
AsAttribute flags this object as xml attribute
func (*XMLObject) AsUnwrapped ¶
AsUnwrapped flags this object as an xml node
func (*XMLObject) AsWrapped ¶
AsWrapped flags this object as wrapped, this is mostly useful for array types
func (*XMLObject) WithNamespace ¶
WithNamespace sets the xml namespace for the object
func (*XMLObject) WithPrefix ¶
WithPrefix sets the xml prefix for the object
Source Files
¶
- cache.go
- components.go
- contact_info.go
- debug.go
- embed.go
- errors.go
- expander.go
- external_docs.go
- header.go
- info.go
- items.go
- license.go
- media_type.go
- normalizer.go
- normalizer_nonwindows.go
- operation.go
- parameter.go
- path_item.go
- paths.go
- properties.go
- ref.go
- request_body.go
- resolver.go
- response.go
- responses.go
- schema.go
- schema_loader.go
- security_scheme.go
- server.go
- spec.go
- swagger.go
- tag.go
- url_go19.go
- validations.go
- xml_object.go