...

Package spec

import "github.com/go-openapi/spec"
Overview
Index

Overview ▾

Index ▾

Constants
Variables
func ExpandParameter(parameter *Parameter, basePath string) error
func ExpandParameterWithRoot(parameter *Parameter, root interface{}, cache ResolutionCache) error
func ExpandResponse(response *Response, basePath string) error
func ExpandResponseWithRoot(response *Response, root interface{}, cache ResolutionCache) error
func ExpandSchema(schema *Schema, root interface{}, cache ResolutionCache) error
func ExpandSchemaWithBasePath(schema *Schema, cache ResolutionCache, opts *ExpandOptions) error
func ExpandSpec(spec *Swagger, options *ExpandOptions) error
type CommonValidations
    func (v *CommonValidations) ClearArrayValidations(cbs ...func(string, interface{}))
    func (v *CommonValidations) ClearNumberValidations(cbs ...func(string, interface{}))
    func (v *CommonValidations) ClearStringValidations(cbs ...func(string, interface{}))
    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 ContactInfo
    func (c ContactInfo) MarshalJSON() ([]byte, error)
    func (c *ContactInfo) UnmarshalJSON(data []byte) error
type ContactInfoProps
type Definitions
type Dependencies
type ExpandOptions
type Extensions
    func (e Extensions) Add(key string, value interface{})
    func (e Extensions) GetBool(key string) (bool, bool)
    func (e Extensions) GetInt(key string) (int, bool)
    func (e Extensions) GetString(key string) (string, bool)
    func (e Extensions) GetStringSlice(key string) ([]string, bool)
type ExternalDocumentation
type Header
    func ResponseHeader() *Header
    func (h *Header) AllowDuplicates() *Header
    func (h *Header) CollectionOf(items *Items, format string) *Header
    func (h Header) JSONLookup(token string) (interface{}, 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 interface{}) *Header
    func (h *Header) WithDescription(description string) *Header
    func (h *Header) WithEnum(values ...interface{}) *Header
    func (h *Header) WithMaxItems(size int64) *Header
    func (h *Header) WithMaxLength(max int64) *Header
    func (h *Header) WithMaximum(max float64, exclusive bool) *Header
    func (h *Header) WithMinItems(size int64) *Header
    func (h *Header) WithMinLength(min int64) *Header
    func (h *Header) WithMinimum(min 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
    func (i Info) JSONLookup(token string) (interface{}, error)
    func (i Info) MarshalJSON() ([]byte, error)
    func (i *Info) UnmarshalJSON(data []byte) error
type InfoProps
type Items
    func NewItems() *Items
    func ResolveItems(root interface{}, ref Ref, options *ExpandOptions) (*Items, error)
    func ResolveItemsWithBase(root interface{}, ref Ref, options *ExpandOptions) (*Items, error)
    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) (interface{}, 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 interface{}) *Items
    func (i *Items) WithEnum(values ...interface{}) *Items
    func (i *Items) WithMaxItems(size int64) *Items
    func (i *Items) WithMaxLength(max int64) *Items
    func (i *Items) WithMaximum(max float64, exclusive bool) *Items
    func (i *Items) WithMinItems(size int64) *Items
    func (i *Items) WithMinLength(min int64) *Items
    func (i *Items) WithMinimum(min 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
    func (l License) MarshalJSON() ([]byte, error)
    func (l *License) UnmarshalJSON(data []byte) error
type LicenseProps
type Operation
    func NewOperation(id string) *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) (interface{}, 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
    func (op *OperationProps) GobDecode(b []byte) error
    func (op OperationProps) GobEncode() ([]byte, error)
    func (op OperationProps) MarshalJSON() ([]byte, error)
type OrderSchemaItem
type OrderSchemaItems
    func (items OrderSchemaItems) Len() int
    func (items OrderSchemaItems) Less(i, j int) (ret bool)
    func (items OrderSchemaItems) MarshalJSON() ([]byte, error)
    func (items OrderSchemaItems) Swap(i, j int)
type ParamProps
type Parameter
    func BodyParam(name string, schema *Schema) *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 interface{}, ref Ref) (*Parameter, error)
    func ResolveParameterWithBase(root interface{}, 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) (interface{}, 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 interface{}) *Parameter
    func (p *Parameter) WithDescription(description string) *Parameter
    func (p *Parameter) WithEnum(values ...interface{}) *Parameter
    func (p *Parameter) WithLocation(in string) *Parameter
    func (p *Parameter) WithMaxItems(size int64) *Parameter
    func (p *Parameter) WithMaxLength(max int64) *Parameter
    func (p *Parameter) WithMaximum(max float64, exclusive bool) *Parameter
    func (p *Parameter) WithMinItems(size int64) *Parameter
    func (p *Parameter) WithMinLength(min int64) *Parameter
    func (p *Parameter) WithMinimum(min 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
    func ResolvePathItem(root interface{}, ref Ref, options *ExpandOptions) (*PathItem, error)
    func ResolvePathItemWithBase(root interface{}, ref Ref, options *ExpandOptions) (*PathItem, error)
    func (p PathItem) JSONLookup(token string) (interface{}, error)
    func (p PathItem) MarshalJSON() ([]byte, error)
    func (p *PathItem) UnmarshalJSON(data []byte) error
type PathItemProps
type Paths
    func (p Paths) JSONLookup(token string) (interface{}, error)
    func (p Paths) MarshalJSON() ([]byte, error)
    func (p *Paths) UnmarshalJSON(data []byte) error
type Ref
    func MustCreateRef(refURI string) Ref
    func NewRef(refURI string) (Ref, error)
    func (r *Ref) GobDecode(b []byte) error
    func (r Ref) GobEncode() ([]byte, error)
    func (r *Ref) Inherits(child Ref) (*Ref, error)
    func (r *Ref) IsValidURI(basepaths ...string) bool
    func (r Ref) MarshalJSON() ([]byte, error)
    func (r *Ref) RemoteURI() string
    func (r *Ref) UnmarshalJSON(d []byte) error
type Refable
    func (r Refable) MarshalJSON() ([]byte, error)
    func (r *Refable) UnmarshalJSON(d []byte) error
type ResolutionCache
type Response
    func NewResponse() *Response
    func ResolveResponse(root interface{}, ref Ref) (*Response, error)
    func ResolveResponseWithBase(root interface{}, ref Ref, options *ExpandOptions) (*Response, error)
    func ResponseRef(url string) *Response
    func (r *Response) AddExample(mediaType string, example interface{}) *Response
    func (r *Response) AddHeader(name string, header *Header) *Response
    func (r Response) JSONLookup(token string) (interface{}, 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
    func (r Responses) JSONLookup(token string) (interface{}, error)
    func (r Responses) MarshalJSON() ([]byte, error)
    func (r *Responses) UnmarshalJSON(data []byte) error
type ResponsesProps
    func (r ResponsesProps) MarshalJSON() ([]byte, error)
    func (r *ResponsesProps) UnmarshalJSON(data []byte) error
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 MustLoadSwagger20Schema() *Schema
    func RefProperty(name string) *Schema
    func RefSchema(name string) *Schema
    func ResolveRef(root interface{}, ref *Ref) (*Schema, error)
    func ResolveRefWithBase(root interface{}, 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) (interface{}, 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 interface{}) *Schema
    func (s *Schema) WithDescription(description string) *Schema
    func (s *Schema) WithDiscriminator(discriminator string) *Schema
    func (s *Schema) WithEnum(values ...interface{}) *Schema
    func (s *Schema) WithExample(example interface{}) *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(max int64) *Schema
    func (s *Schema) WithMaxProperties(max int64) *Schema
    func (s *Schema) WithMaximum(max float64, exclusive bool) *Schema
    func (s *Schema) WithMinItems(size int64) *Schema
    func (s *Schema) WithMinLength(min int64) *Schema
    func (s *Schema) WithMinProperties(min int64) *Schema
    func (s *Schema) WithMinimum(min 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
    func (s *SchemaOrArray) ContainsType(name string) bool
    func (s SchemaOrArray) JSONLookup(token string) (interface{}, error)
    func (s SchemaOrArray) Len() int
    func (s SchemaOrArray) MarshalJSON() ([]byte, error)
    func (s *SchemaOrArray) UnmarshalJSON(data []byte) error
type SchemaOrBool
    func (s SchemaOrBool) JSONLookup(token string) (interface{}, error)
    func (s SchemaOrBool) MarshalJSON() ([]byte, error)
    func (s *SchemaOrBool) UnmarshalJSON(data []byte) error
type SchemaOrStringArray
    func (s SchemaOrStringArray) JSONLookup(token string) (interface{}, error)
    func (s SchemaOrStringArray) MarshalJSON() ([]byte, error)
    func (s *SchemaOrStringArray) UnmarshalJSON(data []byte) error
type SchemaProperties
    func (properties SchemaProperties) MarshalJSON() ([]byte, error)
    func (properties SchemaProperties) ToOrderedSchemaItems() OrderSchemaItems
type SchemaProps
type SchemaURL
    func (r SchemaURL) MarshalJSON() ([]byte, error)
    func (r *SchemaURL) UnmarshalJSON(data []byte) error
type SchemaValidations
    func (v *SchemaValidations) ClearObjectValidations(cbs ...func(string, interface{}))
    func (v SchemaValidations) HasObjectValidations() bool
    func (v *SchemaValidations) SetValidations(val SchemaValidations)
    func (v SchemaValidations) Validations() 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
    func (s SecurityScheme) JSONLookup(token string) (interface{}, error)
    func (s SecurityScheme) MarshalJSON() ([]byte, error)
    func (s *SecurityScheme) UnmarshalJSON(data []byte) error
type SecuritySchemeProps
    func (s *SecuritySchemeProps) AddScope(scope, description string)
type SimpleSchema
    func (s *SimpleSchema) ItemsTypeName() string
    func (s *SimpleSchema) TypeName() string
type StringOrArray
    func (s StringOrArray) Contains(value string) bool
    func (s StringOrArray) MarshalJSON() ([]byte, error)
    func (s *StringOrArray) UnmarshalJSON(data []byte) error
type Swagger
    func (s *Swagger) GobDecode(b []byte) error
    func (s Swagger) GobEncode() ([]byte, error)
    func (s Swagger) JSONLookup(token string) (interface{}, error)
    func (s Swagger) MarshalJSON() ([]byte, error)
    func (s *Swagger) UnmarshalJSON(data []byte) error
type SwaggerProps
    func (o *SwaggerProps) GobDecode(b []byte) error
    func (o SwaggerProps) GobEncode() ([]byte, error)
type SwaggerSchemaProps
type Tag
    func NewTag(name, description string, externalDocs *ExternalDocumentation) Tag
    func (t Tag) JSONLookup(token string) (interface{}, error)
    func (t Tag) MarshalJSON() ([]byte, error)
    func (t *Tag) UnmarshalJSON(data []byte) error
type TagProps
type VendorExtensible
    func (v *VendorExtensible) AddExtension(key string, value interface{})
    func (v VendorExtensible) MarshalJSON() ([]byte, error)
    func (v *VendorExtensible) UnmarshalJSON(data []byte) error
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

Package files

cache.go contact_info.go debug.go embed.go errors.go expander.go external_docs.go header.go info.go items.go license.go normalizer.go normalizer_nonwindows.go operation.go parameter.go path_item.go paths.go properties.go ref.go resolver.go response.go responses.go schema.go schema_loader.go security_scheme.go spec.go swagger.go tag.go url_go19.go validations.go xml_object.go

Constants

const (
    // SwaggerSchemaURL the url for the swagger 2.0 schema to validate specs
    SwaggerSchemaURL = "http://swagger.io/v2/schema.json#"
    // JSONSchemaURL the url for the json schema
    JSONSchemaURL = "http://json-schema.org/draft-04/schema#"
)

Variables

Error codes

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

Debug is true when the SWAGGER_DEBUG env var is not empty.

It enables a more verbose logging of this package.

var Debug = os.Getenv("SWAGGER_DEBUG") != ""

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

var PathLoader = func(pth string) (json.RawMessage, error) {
    data, err := swag.LoadFromFileOrHTTP(pth)
    if err != nil {
        return nil, err
    }
    return json.RawMessage(data), nil
}

func ExpandParameter

func ExpandParameter(parameter *Parameter, basePath string) error

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 interface{}, 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

func ExpandResponse(response *Response, basePath string) error

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 interface{}, 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 interface{}, 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

type CommonValidations

CommonValidations describe common JSON-schema validations

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             []interface{} `json:"enum,omitempty"`
}

func (*CommonValidations) ClearArrayValidations

func (v *CommonValidations) ClearArrayValidations(cbs ...func(string, interface{}))

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, interface{}))

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, interface{}))

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 ContactInfo

ContactInfo contact information for the exposed API.

For more information: http://goo.gl/8us55a#contactObject

type ContactInfo struct {
    ContactInfoProps
    VendorExtensible
}

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

ContactInfoProps hold the properties of a ContactInfo object

type ContactInfoProps struct {
    Name  string `json:"name,omitempty"`
    URL   string `json:"url,omitempty"`
    Email string `json:"email,omitempty"`
}

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 Definitions map[string]Schema

type Dependencies

Dependencies represent a dependencies property

type Dependencies map[string]SchemaOrStringArray

type ExpandOptions

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 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
}

type Extensions

Extensions vendor specific extensions

type Extensions map[string]interface{}

func (Extensions) Add

func (e Extensions) Add(key string, value interface{})

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

ExternalDocumentation allows referencing an external resource for extended documentation.

For more information: http://goo.gl/8us55a#externalDocumentationObject

type ExternalDocumentation struct {
    Description string `json:"description,omitempty"`
    URL         string `json:"url,omitempty"`
}

Header describes a header for a response of the API

For more information: http://goo.gl/8us55a#headerObject

type Header struct {
    CommonValidations
    SimpleSchema
    VendorExtensible
    HeaderProps
}

func ResponseHeader

func ResponseHeader() *Header

ResponseHeader creates a new header instance for use in a response

func (*Header) AllowDuplicates

func (h *Header) AllowDuplicates() *Header

AllowDuplicates this array can have duplicates

func (*Header) CollectionOf

func (h *Header) CollectionOf(items *Items, format string) *Header

CollectionOf a fluent builder method for an array item

func (Header) JSONLookup

func (h Header) JSONLookup(token string) (interface{}, error)

JSONLookup look up a value by the json property name

func (Header) MarshalJSON

func (h Header) MarshalJSON() ([]byte, error)

MarshalJSON marshal this to JSON

func (*Header) Typed

func (h *Header) Typed(tpe, format string) *Header

Typed a fluent builder method for the type of parameter

func (*Header) UniqueValues

func (h *Header) UniqueValues() *Header

UniqueValues dictates that this array can only have unique items

func (*Header) UnmarshalJSON

func (h *Header) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals this header from JSON

func (*Header) WithDefault

func (h *Header) WithDefault(defaultValue interface{}) *Header

WithDefault sets the default value on this item

func (*Header) WithDescription

func (h *Header) WithDescription(description string) *Header

WithDescription sets the description on this response, allows for chaining

func (*Header) WithEnum

func (h *Header) WithEnum(values ...interface{}) *Header

WithEnum sets a the enum values (replace)

func (*Header) WithMaxItems

func (h *Header) WithMaxItems(size int64) *Header

WithMaxItems sets the max items

func (*Header) WithMaxLength

func (h *Header) WithMaxLength(max int64) *Header

WithMaxLength sets a max length value

func (*Header) WithMaximum

func (h *Header) WithMaximum(max float64, exclusive bool) *Header

WithMaximum sets a maximum number value

func (*Header) WithMinItems

func (h *Header) WithMinItems(size int64) *Header

WithMinItems sets the min items

func (*Header) WithMinLength

func (h *Header) WithMinLength(min int64) *Header

WithMinLength sets a min length value

func (*Header) WithMinimum

func (h *Header) WithMinimum(min float64, exclusive bool) *Header

WithMinimum sets a minimum number value

func (*Header) WithMultipleOf

func (h *Header) WithMultipleOf(number float64) *Header

WithMultipleOf sets a multiple of value

func (*Header) WithPattern

func (h *Header) WithPattern(pattern string) *Header

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

HeaderProps describes a response header

type HeaderProps struct {
    Description string `json:"description,omitempty"`
}

type Info

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

type Info struct {
    VendorExtensible
    InfoProps
}

func (Info) JSONLookup

func (i Info) JSONLookup(token string) (interface{}, error)

JSONLookup look up a value by the json property name

func (Info) MarshalJSON

func (i Info) MarshalJSON() ([]byte, error)

MarshalJSON marshal this to JSON

func (*Info) UnmarshalJSON

func (i *Info) UnmarshalJSON(data []byte) error

UnmarshalJSON marshal this from JSON

type InfoProps

InfoProps the properties for an info definition

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"`
}

type Items

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

type Items struct {
    Refable
    CommonValidations
    SimpleSchema
    VendorExtensible
}

func NewItems

func NewItems() *Items

NewItems creates a new instance of items

func ResolveItems

func ResolveItems(root interface{}, 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 interface{}, ref Ref, options *ExpandOptions) (*Items, error)

ResolveItemsWithBase resolves parameter items reference against a context root and base path.

NOTE: stricly speaking, this construct is not supported by Swagger 2.0. Similarly, $ref are forbidden in response headers.

func (*Items) AllowDuplicates

func (i *Items) AllowDuplicates() *Items

AllowDuplicates this array can have duplicates

func (*Items) AsNullable

func (i *Items) AsNullable() *Items

AsNullable flags this schema as nullable.

func (*Items) CollectionOf

func (i *Items) CollectionOf(items *Items, format string) *Items

CollectionOf a fluent builder method for an array item

func (Items) JSONLookup

func (i Items) JSONLookup(token string) (interface{}, error)

JSONLookup look up a value by the json property name

func (Items) MarshalJSON

func (i Items) MarshalJSON() ([]byte, error)

MarshalJSON converts this items object to JSON

func (*Items) Typed

func (i *Items) Typed(tpe, format string) *Items

Typed a fluent builder method for the type of item

func (*Items) UniqueValues

func (i *Items) UniqueValues() *Items

UniqueValues dictates that this array can only have unique items

func (*Items) UnmarshalJSON

func (i *Items) UnmarshalJSON(data []byte) error

UnmarshalJSON hydrates this items instance with the data from JSON

func (*Items) WithDefault

func (i *Items) WithDefault(defaultValue interface{}) *Items

WithDefault sets the default value on this item

func (*Items) WithEnum

func (i *Items) WithEnum(values ...interface{}) *Items

WithEnum sets a the enum values (replace)

func (*Items) WithMaxItems

func (i *Items) WithMaxItems(size int64) *Items

WithMaxItems sets the max items

func (*Items) WithMaxLength

func (i *Items) WithMaxLength(max int64) *Items

WithMaxLength sets a max length value

func (*Items) WithMaximum

func (i *Items) WithMaximum(max float64, exclusive bool) *Items

WithMaximum sets a maximum number value

func (*Items) WithMinItems

func (i *Items) WithMinItems(size int64) *Items

WithMinItems sets the min items

func (*Items) WithMinLength

func (i *Items) WithMinLength(min int64) *Items

WithMinLength sets a min length value

func (*Items) WithMinimum

func (i *Items) WithMinimum(min float64, exclusive bool) *Items

WithMinimum sets a minimum number value

func (*Items) WithMultipleOf

func (i *Items) WithMultipleOf(number float64) *Items

WithMultipleOf sets a multiple of value

func (*Items) WithPattern

func (i *Items) WithPattern(pattern string) *Items

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

License information for the exposed API.

For more information: http://goo.gl/8us55a#licenseObject

type License struct {
    LicenseProps
    VendorExtensible
}

func (License) MarshalJSON

func (l License) MarshalJSON() ([]byte, error)

MarshalJSON produces License as json

func (*License) UnmarshalJSON

func (l *License) UnmarshalJSON(data []byte) error

UnmarshalJSON hydrates License from json

type LicenseProps

LicenseProps holds the properties of a License object

type LicenseProps struct {
    Name string `json:"name,omitempty"`
    URL  string `json:"url,omitempty"`
}

type Operation

Operation describes a single API operation on a path.

For more information: http://goo.gl/8us55a#operationObject

type Operation struct {
    VendorExtensible
    OperationProps
}

func NewOperation

func NewOperation(id string) *Operation

NewOperation creates a new operation instance. It expects an ID as parameter but not passing an ID is also valid.

func (*Operation) AddParam

func (o *Operation) AddParam(param *Parameter) *Operation

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

func (o *Operation) Deprecate() *Operation

Deprecate marks the operation as deprecated

func (*Operation) GobDecode

func (o *Operation) GobDecode(b []byte) error

GobDecode provides a safe gob decoder for Operation, including empty security requirements

func (Operation) GobEncode

func (o Operation) GobEncode() ([]byte, error)

GobEncode provides a safe gob encoder for Operation, including empty security requirements

func (Operation) JSONLookup

func (o Operation) JSONLookup(token string) (interface{}, error)

JSONLookup look up a value by the json property name

func (Operation) MarshalJSON

func (o Operation) MarshalJSON() ([]byte, error)

MarshalJSON converts this items object to JSON

func (*Operation) RemoveParam

func (o *Operation) RemoveParam(name, in string) *Operation

RemoveParam removes a parameter from the operation

func (*Operation) RespondsWith

func (o *Operation) RespondsWith(code int, response *Response) *Operation

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

func (o *Operation) SecuredWith(name string, scopes ...string) *Operation

SecuredWith adds a security scope to this operation.

func (*Operation) SuccessResponse

func (o *Operation) SuccessResponse() (*Response, int, bool)

SuccessResponse gets a success response model

func (*Operation) Undeprecate

func (o *Operation) Undeprecate() *Operation

Undeprecate marks the operation as not deprected

func (*Operation) UnmarshalJSON

func (o *Operation) UnmarshalJSON(data []byte) error

UnmarshalJSON hydrates this items instance with the data from JSON

func (*Operation) WithConsumes

func (o *Operation) WithConsumes(mediaTypes ...string) *Operation

WithConsumes adds media types for incoming body values

func (*Operation) WithDefaultResponse

func (o *Operation) WithDefaultResponse(response *Response) *Operation

WithDefaultResponse adds a default response to the operation. Passing a nil value will remove the response

func (*Operation) WithDescription

func (o *Operation) WithDescription(description string) *Operation

WithDescription sets the description on this operation, allows for chaining

func (*Operation) WithExternalDocs

func (o *Operation) WithExternalDocs(description, url string) *Operation

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

func (o *Operation) WithID(id string) *Operation

WithID sets the ID property on this operation, allows for chaining.

func (*Operation) WithProduces

func (o *Operation) WithProduces(mediaTypes ...string) *Operation

WithProduces adds media types for outgoing body values

func (*Operation) WithSummary

func (o *Operation) WithSummary(summary string) *Operation

WithSummary sets the summary on this operation, allows for chaining

func (*Operation) WithTags

func (o *Operation) WithTags(tags ...string) *Operation

WithTags adds tags for this operation

type OperationProps

OperationProps describes an operation

NOTES: - schemes, when present must be from [http, https, ws, wss]: see validate - Security is handled as a special case: see MarshalJSON function

type OperationProps struct {
    Description  string                 `json:"description,omitempty"`
    Consumes     []string               `json:"consumes,omitempty"`
    Produces     []string               `json:"produces,omitempty"`
    Schemes      []string               `json:"schemes,omitempty"`
    Tags         []string               `json:"tags,omitempty"`
    Summary      string                 `json:"summary,omitempty"`
    ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
    ID           string                 `json:"operationId,omitempty"`
    Deprecated   bool                   `json:"deprecated,omitempty"`
    Security     []map[string][]string  `json:"security,omitempty"`
    Parameters   []Parameter            `json:"parameters,omitempty"`
    Responses    *Responses             `json:"responses,omitempty"`
}

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 OrderSchemaItem struct {
    Name string
    Schema
}

type OrderSchemaItems

OrderSchemaItems is a sortable slice of named schemas. The ordering is defined by the x-order schema extension.

type OrderSchemaItems []OrderSchemaItem

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

ParamProps describes the specific attributes of an operation parameter

NOTE: - Schema is defined when "in" == "body": see validate - AllowEmptyValue is allowed where "in" == "query" || "formData"

type ParamProps struct {
    Description     string  `json:"description,omitempty"`
    Name            string  `json:"name,omitempty"`
    In              string  `json:"in,omitempty"`
    Required        bool    `json:"required,omitempty"`
    Schema          *Schema `json:"schema,omitempty"`
    AllowEmptyValue bool    `json:"allowEmptyValue,omitempty"`
}

type Parameter

Parameter a unique parameter is defined by a combination of a [name](#parameterName) and [location](#parameterIn).

There are five possible parameter types.

For more information: http://goo.gl/8us55a#parameterObject

type Parameter struct {
    Refable
    CommonValidations
    SimpleSchema
    VendorExtensible
    ParamProps
}

func BodyParam

func BodyParam(name string, schema *Schema) *Parameter

BodyParam creates a body parameter

func FileParam

func FileParam(name string) *Parameter

FileParam creates a body parameter

func FormDataParam

func FormDataParam(name string) *Parameter

FormDataParam creates a body parameter

func HeaderParam

func HeaderParam(name string) *Parameter

HeaderParam creates a header parameter, this is always required by default

func ParamRef

func ParamRef(uri string) *Parameter

ParamRef creates a parameter that's a json reference

func PathParam

func PathParam(name string) *Parameter

PathParam creates a path parameter, this is always required

func QueryParam

func QueryParam(name string) *Parameter

QueryParam creates a query parameter

func ResolveParameter

func ResolveParameter(root interface{}, ref Ref) (*Parameter, error)

ResolveParameter resolves a parameter reference against a context root

func ResolveParameterWithBase

func ResolveParameterWithBase(root interface{}, ref Ref, options *ExpandOptions) (*Parameter, error)

ResolveParameterWithBase resolves a parameter reference against a context root and base path

func SimpleArrayParam

func SimpleArrayParam(name, tpe, fmt string) *Parameter

SimpleArrayParam creates a param for a simple array (string, int, date etc)

func (*Parameter) AllowDuplicates

func (p *Parameter) AllowDuplicates() *Parameter

AllowDuplicates this array can have duplicates

func (*Parameter) AllowsEmptyValues

func (p *Parameter) AllowsEmptyValues() *Parameter

AllowsEmptyValues flags this parameter as being ok with empty values

func (*Parameter) AsOptional

func (p *Parameter) AsOptional() *Parameter

AsOptional flags this parameter as optional

func (*Parameter) AsRequired

func (p *Parameter) AsRequired() *Parameter

AsRequired flags this parameter as required

func (*Parameter) CollectionOf

func (p *Parameter) CollectionOf(items *Items, format string) *Parameter

CollectionOf a fluent builder method for an array parameter

func (Parameter) JSONLookup

func (p Parameter) JSONLookup(token string) (interface{}, error)

JSONLookup look up a value by the json property name

func (Parameter) MarshalJSON

func (p Parameter) MarshalJSON() ([]byte, error)

MarshalJSON converts this items object to JSON

func (*Parameter) Named

func (p *Parameter) Named(name string) *Parameter

Named a fluent builder method to override the name of the parameter

func (*Parameter) NoEmptyValues

func (p *Parameter) NoEmptyValues() *Parameter

NoEmptyValues flags this parameter as not liking empty values

func (*Parameter) Typed

func (p *Parameter) Typed(tpe, format string) *Parameter

Typed a fluent builder method for the type of the parameter value

func (*Parameter) UniqueValues

func (p *Parameter) UniqueValues() *Parameter

UniqueValues dictates that this array can only have unique items

func (*Parameter) UnmarshalJSON

func (p *Parameter) UnmarshalJSON(data []byte) error

UnmarshalJSON hydrates this items instance with the data from JSON

func (*Parameter) WithDefault

func (p *Parameter) WithDefault(defaultValue interface{}) *Parameter

WithDefault sets the default value on this parameter

func (*Parameter) WithDescription

func (p *Parameter) WithDescription(description string) *Parameter

WithDescription a fluent builder method for the description of the parameter

func (*Parameter) WithEnum

func (p *Parameter) WithEnum(values ...interface{}) *Parameter

WithEnum sets a the enum values (replace)

func (*Parameter) WithLocation

func (p *Parameter) WithLocation(in string) *Parameter

WithLocation a fluent builder method to override the location of the parameter

func (*Parameter) WithMaxItems

func (p *Parameter) WithMaxItems(size int64) *Parameter

WithMaxItems sets the max items

func (*Parameter) WithMaxLength

func (p *Parameter) WithMaxLength(max int64) *Parameter

WithMaxLength sets a max length value

func (*Parameter) WithMaximum

func (p *Parameter) WithMaximum(max float64, exclusive bool) *Parameter

WithMaximum sets a maximum number value

func (*Parameter) WithMinItems

func (p *Parameter) WithMinItems(size int64) *Parameter

WithMinItems sets the min items

func (*Parameter) WithMinLength

func (p *Parameter) WithMinLength(min int64) *Parameter

WithMinLength sets a min length value

func (*Parameter) WithMinimum

func (p *Parameter) WithMinimum(min float64, exclusive bool) *Parameter

WithMinimum sets a minimum number value

func (*Parameter) WithMultipleOf

func (p *Parameter) WithMultipleOf(number float64) *Parameter

WithMultipleOf sets a multiple of value

func (*Parameter) WithPattern

func (p *Parameter) WithPattern(pattern string) *Parameter

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

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

type PathItem struct {
    Refable
    VendorExtensible
    PathItemProps
}

func ResolvePathItem

func ResolvePathItem(root interface{}, 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 interface{}, ref Ref, options *ExpandOptions) (*PathItem, error)

ResolvePathItemWithBase resolves response a path item against a context root and base path

func (PathItem) JSONLookup

func (p PathItem) JSONLookup(token string) (interface{}, error)

JSONLookup look up a value by the json property name

func (PathItem) MarshalJSON

func (p PathItem) MarshalJSON() ([]byte, error)

MarshalJSON converts this items object to JSON

func (*PathItem) UnmarshalJSON

func (p *PathItem) UnmarshalJSON(data []byte) error

UnmarshalJSON hydrates this items instance with the data from JSON

type PathItemProps

PathItemProps the path item specific properties

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"`
}

type Paths

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

type Paths struct {
    VendorExtensible
    Paths map[string]PathItem `json:"-"` // custom serializer to flatten this, each entry must start with "/"
}

func (Paths) JSONLookup

func (p Paths) JSONLookup(token string) (interface{}, error)

JSONLookup look up a value by the json property name

func (Paths) MarshalJSON

func (p Paths) MarshalJSON() ([]byte, error)

MarshalJSON converts this items object to JSON

func (*Paths) UnmarshalJSON

func (p *Paths) UnmarshalJSON(data []byte) error

UnmarshalJSON hydrates this items instance with the data from JSON

type Ref

Ref represents a json reference that is potentially resolved

type Ref struct {
    jsonreference.Ref
}

func MustCreateRef

func MustCreateRef(refURI string) Ref

MustCreateRef creates a ref object but panics when refURI is invalid. Use the NewRef method for a version that returns an error.

func NewRef

func NewRef(refURI string) (Ref, error)

NewRef creates a new instance of a ref object returns an error when the reference uri is an invalid uri

func (*Ref) GobDecode

func (r *Ref) GobDecode(b []byte) error

GobDecode provides a safe gob decoder for Ref

func (Ref) GobEncode

func (r Ref) GobEncode() ([]byte, error)

GobEncode provides a safe gob encoder for Ref

func (*Ref) Inherits

func (r *Ref) Inherits(child Ref) (*Ref, error)

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

func (r *Ref) IsValidURI(basepaths ...string) bool

IsValidURI returns true when the url the ref points to can be found

func (Ref) MarshalJSON

func (r Ref) MarshalJSON() ([]byte, error)

MarshalJSON marshals this ref into a JSON object

func (*Ref) RemoteURI

func (r *Ref) RemoteURI() string

RemoteURI gets the remote uri part of the ref

func (*Ref) UnmarshalJSON

func (r *Ref) UnmarshalJSON(d []byte) error

UnmarshalJSON unmarshals this ref from a JSON object

type Refable

Refable is a struct for things that accept a $ref property

type Refable struct {
    Ref Ref
}

func (Refable) MarshalJSON

func (r Refable) MarshalJSON() ([]byte, error)

MarshalJSON marshals the ref to json

func (*Refable) UnmarshalJSON

func (r *Refable) UnmarshalJSON(d []byte) error

UnmarshalJSON unmarshalss the ref from json

type ResolutionCache

ResolutionCache a cache for resolving urls

type ResolutionCache interface {
    Get(string) (interface{}, bool)
    Set(string, interface{})
}

type Response

Response describes a single response from an API Operation.

For more information: http://goo.gl/8us55a#responseObject

type Response struct {
    Refable
    ResponseProps
    VendorExtensible
}

func NewResponse

func NewResponse() *Response

NewResponse creates a new response instance

func ResolveResponse

func ResolveResponse(root interface{}, ref Ref) (*Response, error)

ResolveResponse resolves response a reference against a context root

func ResolveResponseWithBase

func ResolveResponseWithBase(root interface{}, ref Ref, options *ExpandOptions) (*Response, error)

ResolveResponseWithBase resolves response a reference against a context root and base path

func ResponseRef

func ResponseRef(url string) *Response

ResponseRef creates a response as a json reference

func (*Response) AddExample

func (r *Response) AddExample(mediaType string, example interface{}) *Response

AddExample adds an example to this response

func (*Response) AddHeader

func (r *Response) AddHeader(name string, header *Header) *Response

AddHeader adds a header to this response

func (Response) JSONLookup

func (r Response) JSONLookup(token string) (interface{}, error)

JSONLookup look up a value by the json property name

func (Response) MarshalJSON

func (r Response) MarshalJSON() ([]byte, error)

MarshalJSON converts this items object to JSON

func (*Response) RemoveHeader

func (r *Response) RemoveHeader(name string) *Response

RemoveHeader removes a header from this response

func (*Response) UnmarshalJSON

func (r *Response) UnmarshalJSON(data []byte) error

UnmarshalJSON hydrates this items instance with the data from JSON

func (*Response) WithDescription

func (r *Response) WithDescription(description string) *Response

WithDescription sets the description on this response, allows for chaining

func (*Response) WithSchema

func (r *Response) WithSchema(schema *Schema) *Response

WithSchema sets the schema on this response, allows for chaining. Passing a nil argument removes the schema from this response

type ResponseProps

ResponseProps properties specific to a response

type ResponseProps struct {
    Description string                 `json:"description"`
    Schema      *Schema                `json:"schema,omitempty"`
    Headers     map[string]Header      `json:"headers,omitempty"`
    Examples    map[string]interface{} `json:"examples,omitempty"`
}

type Responses

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

type Responses struct {
    VendorExtensible
    ResponsesProps
}

func (Responses) JSONLookup

func (r Responses) JSONLookup(token string) (interface{}, error)

JSONLookup implements an interface to customize json pointer lookup

func (Responses) MarshalJSON

func (r Responses) MarshalJSON() ([]byte, error)

MarshalJSON converts this items object to JSON

func (*Responses) UnmarshalJSON

func (r *Responses) UnmarshalJSON(data []byte) error

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.

type ResponsesProps struct {
    Default             *Response
    StatusCodeResponses map[int]Response
}

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

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

type Schema struct {
    VendorExtensible
    SchemaProps
    SwaggerSchemaProps
    ExtraProps map[string]interface{} `json:"-"`
}

func ArrayProperty

func ArrayProperty(items *Schema) *Schema

ArrayProperty creates an array property

func BoolProperty

func BoolProperty() *Schema

BoolProperty creates a boolean property

func BooleanProperty

func BooleanProperty() *Schema

BooleanProperty creates a boolean property

func CharProperty

func CharProperty() *Schema

CharProperty creates a string property

func ComposedSchema

func ComposedSchema(schemas ...Schema) *Schema

ComposedSchema creates a schema with allOf

func DateProperty

func DateProperty() *Schema

DateProperty creates a date property

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 Int16Property

func Int16Property() *Schema

Int16Property creates an int16 property

func Int32Property

func Int32Property() *Schema

Int32Property creates an int32 property

func Int64Property

func Int64Property() *Schema

Int64Property creates an int64 property

func Int8Property

func Int8Property() *Schema

Int8Property creates an int8 property

func JSONSchemaDraft04

func JSONSchemaDraft04() (*Schema, error)

JSONSchemaDraft04 loads the json schema document for json shema draft04

func MapProperty

func MapProperty(property *Schema) *Schema

MapProperty creates a map property

func MustLoadJSONSchemaDraft04

func MustLoadJSONSchemaDraft04() *Schema

MustLoadJSONSchemaDraft04 panics when Swagger20Schema returns an error

func MustLoadSwagger20Schema

func MustLoadSwagger20Schema() *Schema

MustLoadSwagger20Schema panics when Swagger20Schema returns an error

func RefProperty

func RefProperty(name string) *Schema

RefProperty creates a ref property

func RefSchema

func RefSchema(name string) *Schema

RefSchema creates a ref property

func ResolveRef

func ResolveRef(root interface{}, ref *Ref) (*Schema, error)

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 interface{}, ref *Ref, options *ExpandOptions) (*Schema, error)

ResolveRefWithBase resolves a reference against a context root with preservation of base path

func StrFmtProperty

func StrFmtProperty(format string) *Schema

StrFmtProperty creates a property for the named string format

func StringProperty

func StringProperty() *Schema

StringProperty creates a string property

func Swagger20Schema

func Swagger20Schema() (*Schema, error)

Swagger20Schema loads the swagger 2.0 schema from the embedded assets

func (*Schema) AddRequired

func (s *Schema) AddRequired(items ...string) *Schema

AddRequired adds field names to the required properties array

func (*Schema) AddToAllOf

func (s *Schema) AddToAllOf(schemas ...Schema) *Schema

AddToAllOf adds a schema to the allOf property

func (*Schema) AddType

func (s *Schema) AddType(tpe, format string) *Schema

AddType adds a type with potential format to the types for this schema

func (*Schema) AllowDuplicates

func (s *Schema) AllowDuplicates() *Schema

AllowDuplicates this array can have duplicates

func (*Schema) AsNullable

func (s *Schema) AsNullable() *Schema

AsNullable flags this schema as nullable.

func (*Schema) AsReadOnly

func (s *Schema) AsReadOnly() *Schema

AsReadOnly flags this schema as readonly

func (*Schema) AsUnwrappedXML

func (s *Schema) AsUnwrappedXML() *Schema

AsUnwrappedXML flags this object as an xml node

func (*Schema) AsWrappedXML

func (s *Schema) AsWrappedXML() *Schema

AsWrappedXML flags this object as wrapped, this is mostly useful for array types

func (*Schema) AsWritable

func (s *Schema) AsWritable() *Schema

AsWritable flags this schema as writeable (not read-only)

func (*Schema) AsXMLAttribute

func (s *Schema) AsXMLAttribute() *Schema

AsXMLAttribute flags this object as xml attribute

func (*Schema) AsXMLElement

func (s *Schema) AsXMLElement() *Schema

AsXMLElement flags this object as an xml node

func (*Schema) CollectionOf

func (s *Schema) CollectionOf(items Schema) *Schema

CollectionOf a fluent builder method for an array parameter

func (Schema) JSONLookup

func (s Schema) JSONLookup(token string) (interface{}, error)

JSONLookup implements an interface to customize json pointer lookup

func (Schema) MarshalJSON

func (s Schema) MarshalJSON() ([]byte, error)

MarshalJSON marshal this to JSON

func (*Schema) SetProperty

func (s *Schema) SetProperty(name string, schema Schema) *Schema

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

func (s *Schema) Typed(tpe, format string) *Schema

Typed sets the type of this schema for a single value item

func (*Schema) UniqueValues

func (s *Schema) UniqueValues() *Schema

UniqueValues dictates that this array can only have unique items

func (*Schema) UnmarshalJSON

func (s *Schema) UnmarshalJSON(data []byte) error

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

func (s *Schema) WithAllOf(schemas ...Schema) *Schema

WithAllOf sets the all of property

func (*Schema) WithDefault

func (s *Schema) WithDefault(defaultValue interface{}) *Schema

WithDefault sets the default value on this parameter

func (*Schema) WithDescription

func (s *Schema) WithDescription(description string) *Schema

WithDescription sets the description for this schema, allows for chaining

func (*Schema) WithDiscriminator

func (s *Schema) WithDiscriminator(discriminator string) *Schema

WithDiscriminator sets the name of the discriminator field

func (*Schema) WithEnum

func (s *Schema) WithEnum(values ...interface{}) *Schema

WithEnum sets a the enum values (replace)

func (*Schema) WithExample

func (s *Schema) WithExample(example interface{}) *Schema

WithExample sets the example for this schema

func (*Schema) WithExternalDocs

func (s *Schema) WithExternalDocs(description, url string) *Schema

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

func (s *Schema) WithID(id string) *Schema

WithID sets the id for this schema, allows for chaining

func (*Schema) WithMaxItems

func (s *Schema) WithMaxItems(size int64) *Schema

WithMaxItems sets the max items

func (*Schema) WithMaxLength

func (s *Schema) WithMaxLength(max int64) *Schema

WithMaxLength sets a max length value

func (*Schema) WithMaxProperties

func (s *Schema) WithMaxProperties(max int64) *Schema

WithMaxProperties sets the max number of properties an object can have

func (*Schema) WithMaximum

func (s *Schema) WithMaximum(max float64, exclusive bool) *Schema

WithMaximum sets a maximum number value

func (*Schema) WithMinItems

func (s *Schema) WithMinItems(size int64) *Schema

WithMinItems sets the min items

func (*Schema) WithMinLength

func (s *Schema) WithMinLength(min int64) *Schema

WithMinLength sets a min length value

func (*Schema) WithMinProperties

func (s *Schema) WithMinProperties(min int64) *Schema

WithMinProperties sets the min number of properties an object must have

func (*Schema) WithMinimum

func (s *Schema) WithMinimum(min float64, exclusive bool) *Schema

WithMinimum sets a minimum number value

func (*Schema) WithMultipleOf

func (s *Schema) WithMultipleOf(number float64) *Schema

WithMultipleOf sets a multiple of value

func (*Schema) WithPattern

func (s *Schema) WithPattern(pattern string) *Schema

WithPattern sets a pattern value

func (*Schema) WithProperties

func (s *Schema) WithProperties(schemas map[string]Schema) *Schema

WithProperties sets the properties for this schema

func (*Schema) WithRequired

func (s *Schema) WithRequired(items ...string) *Schema

WithRequired flags this parameter as required

func (*Schema) WithTitle

func (s *Schema) WithTitle(title string) *Schema

WithTitle sets the title for this schema, allows for chaining

func (*Schema) WithValidations

func (s *Schema) WithValidations(val SchemaValidations) *Schema

WithValidations is a fluent method to set schema validations

func (*Schema) WithXMLName

func (s *Schema) WithXMLName(name string) *Schema

WithXMLName sets the xml name for the object

func (*Schema) WithXMLNamespace

func (s *Schema) WithXMLNamespace(namespace string) *Schema

WithXMLNamespace sets the xml namespace for the object

func (*Schema) WithXMLPrefix

func (s *Schema) WithXMLPrefix(prefix string) *Schema

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

type SchemaOrArray struct {
    Schema  *Schema
    Schemas []Schema
}

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) (interface{}, 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

type SchemaOrBool struct {
    Allows bool
    Schema *Schema
}

func (SchemaOrBool) JSONLookup

func (s SchemaOrBool) JSONLookup(token string) (interface{}, 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

type SchemaOrStringArray struct {
    Schema   *Schema
    Property []string
}

func (SchemaOrStringArray) JSONLookup

func (s SchemaOrStringArray) JSONLookup(token string) (interface{}, 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.

type SchemaProperties map[string]Schema

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

type SchemaProps

SchemaProps describes a JSON schema (draft 4)

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              interface{}      `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                 []interface{}    `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    SchemaProperties `json:"patternProperties,omitempty"`
    Dependencies         Dependencies     `json:"dependencies,omitempty"`
    AdditionalItems      *SchemaOrBool    `json:"additionalItems,omitempty"`
    Definitions          Definitions      `json:"definitions,omitempty"`
}

type SchemaURL

SchemaURL represents a schema url

type SchemaURL string

func (SchemaURL) MarshalJSON

func (r SchemaURL) MarshalJSON() ([]byte, error)

MarshalJSON marshal this to JSON

func (*SchemaURL) UnmarshalJSON

func (r *SchemaURL) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal this from JSON

type SchemaValidations

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 litterals would fail.

type SchemaValidations struct {
    CommonValidations

    PatternProperties SchemaProperties `json:"patternProperties,omitempty"`
    MaxProperties     *int64           `json:"maxProperties,omitempty"`
    MinProperties     *int64           `json:"minProperties,omitempty"`
}

func (*SchemaValidations) ClearObjectValidations

func (v *SchemaValidations) ClearObjectValidations(cbs ...func(string, interface{}))

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

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 SecurityDefinitions map[string]*SecurityScheme

type SecurityScheme

SecurityScheme allows the definition of a security scheme that can be used by the operations. Supported schemes are basic authentication, an API key (either as a header or as a query parameter) and OAuth2's common flows (implicit, password, application and access code).

For more information: http://goo.gl/8us55a#securitySchemeObject

type SecurityScheme struct {
    VendorExtensible
    SecuritySchemeProps
}

func APIKeyAuth

func APIKeyAuth(fieldName, valueSource string) *SecurityScheme

APIKeyAuth creates an api key auth security scheme

func BasicAuth

func BasicAuth() *SecurityScheme

BasicAuth creates a basic 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) (interface{}, 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

SecuritySchemeProps describes a swagger security scheme in the securityDefinitions section

type SecuritySchemeProps struct {
    Description      string            `json:"description,omitempty"`
    Type             string            `json:"type"`
    Name             string            `json:"name,omitempty"`     // api key
    In               string            `json:"in,omitempty"`       // api key
    Flow             string            `json:"flow,omitempty"`     // oauth2
    AuthorizationURL string            `json:"authorizationUrl"`   // oauth2
    TokenURL         string            `json:"tokenUrl,omitempty"` // oauth2
    Scopes           map[string]string `json:"scopes,omitempty"`   // oauth2
}

func (*SecuritySchemeProps) AddScope

func (s *SecuritySchemeProps) AddScope(scope, description string)

AddScope adds a scope to this security scheme

type SimpleSchema

SimpleSchema describe swagger simple schemas for parameters and headers

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          interface{} `json:"default,omitempty"`
    Example          interface{} `json:"example,omitempty"`
}

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

StringOrArray represents a value that can either be a string or an array of strings. Mainly here for serialization purposes

type StringOrArray []string

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

Swagger this is the root document object for the API specification. It combines what previously was the Resource Listing and API Declaration (version 1.2 and earlier) together into one document.

For more information: http://goo.gl/8us55a#swagger-object-

type Swagger struct {
    VendorExtensible
    SwaggerProps
}

func (*Swagger) GobDecode

func (s *Swagger) GobDecode(b []byte) error

GobDecode provides a safe gob decoder for Swagger, including extensions

func (Swagger) GobEncode

func (s Swagger) GobEncode() ([]byte, error)

GobEncode provides a safe gob encoder for Swagger, including extensions

func (Swagger) JSONLookup

func (s Swagger) JSONLookup(token string) (interface{}, error)

JSONLookup look up a value by the json property name

func (Swagger) MarshalJSON

func (s Swagger) MarshalJSON() ([]byte, error)

MarshalJSON marshals this swagger structure to json

func (*Swagger) UnmarshalJSON

func (s *Swagger) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a swagger spec from json

type SwaggerProps

SwaggerProps captures the top-level properties of an Api specification

NOTE: validation rules - the scheme, when present must be from [http, https, ws, wss] - BasePath must start with a leading "/" - Paths is required

type SwaggerProps struct {
    ID                  string                 `json:"id,omitempty"`
    Consumes            []string               `json:"consumes,omitempty"`
    Produces            []string               `json:"produces,omitempty"`
    Schemes             []string               `json:"schemes,omitempty"`
    Swagger             string                 `json:"swagger,omitempty"`
    Info                *Info                  `json:"info,omitempty"`
    Host                string                 `json:"host,omitempty"`
    BasePath            string                 `json:"basePath,omitempty"`
    Paths               *Paths                 `json:"paths"`
    Definitions         Definitions            `json:"definitions,omitempty"`
    Parameters          map[string]Parameter   `json:"parameters,omitempty"`
    Responses           map[string]Response    `json:"responses,omitempty"`
    SecurityDefinitions SecurityDefinitions    `json:"securityDefinitions,omitempty"`
    Security            []map[string][]string  `json:"security,omitempty"`
    Tags                []Tag                  `json:"tags,omitempty"`
    ExternalDocs        *ExternalDocumentation `json:"externalDocs,omitempty"`
}

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

SwaggerSchemaProps are additional properties supported by swagger schemas, but not JSON-schema (draft 4)

type SwaggerSchemaProps struct {
    Discriminator string                 `json:"discriminator,omitempty"`
    ReadOnly      bool                   `json:"readOnly,omitempty"`
    XML           *XMLObject             `json:"xml,omitempty"`
    ExternalDocs  *ExternalDocumentation `json:"externalDocs,omitempty"`
    Example       interface{}            `json:"example,omitempty"`
}

type Tag

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

type Tag struct {
    VendorExtensible
    TagProps
}

func NewTag

func NewTag(name, description string, externalDocs *ExternalDocumentation) Tag

NewTag creates a new tag

func (Tag) JSONLookup

func (t Tag) JSONLookup(token string) (interface{}, error)

JSONLookup implements an interface to customize json pointer lookup

func (Tag) MarshalJSON

func (t Tag) MarshalJSON() ([]byte, error)

MarshalJSON marshal this to JSON

func (*Tag) UnmarshalJSON

func (t *Tag) UnmarshalJSON(data []byte) error

UnmarshalJSON marshal this from JSON

type TagProps

TagProps describe a tag entry in the top level tags section of a swagger spec

type TagProps struct {
    Description  string                 `json:"description,omitempty"`
    Name         string                 `json:"name,omitempty"`
    ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
}

type VendorExtensible

VendorExtensible composition block.

type VendorExtensible struct {
    Extensions Extensions
}

func (*VendorExtensible) AddExtension

func (v *VendorExtensible) AddExtension(key string, value interface{})

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

XMLObject a metadata object that allows for more fine-tuned XML model definitions.

For more information: http://goo.gl/8us55a#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"`
}

func (*XMLObject) AsAttribute

func (x *XMLObject) AsAttribute() *XMLObject

AsAttribute flags this object as xml attribute

func (*XMLObject) AsElement

func (x *XMLObject) AsElement() *XMLObject

AsElement flags this object as an xml node

func (*XMLObject) AsUnwrapped

func (x *XMLObject) AsUnwrapped() *XMLObject

AsUnwrapped flags this object as an xml node

func (*XMLObject) AsWrapped

func (x *XMLObject) AsWrapped() *XMLObject

AsWrapped flags this object as wrapped, this is mostly useful for array types

func (*XMLObject) WithName

func (x *XMLObject) WithName(name string) *XMLObject

WithName sets the xml name for the object

func (*XMLObject) WithNamespace

func (x *XMLObject) WithNamespace(namespace string) *XMLObject

WithNamespace sets the xml namespace for the object

func (*XMLObject) WithPrefix

func (x *XMLObject) WithPrefix(prefix string) *XMLObject

WithPrefix sets the xml prefix for the object