spec: github.com/go-openapi/spec Index | Files

package spec

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

Index

Package Files

bindata.go cache.go contact_info.go debug.go expander.go external_docs.go header.go info.go items.go license.go normalizer.go operation.go parameter.go path_item.go paths.go ref.go response.go responses.go schema.go schema_loader.go security_scheme.go spec.go swagger.go tag.go unused.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 schema
    JSONSchemaURL = "http://json-schema.org/draft-04/schema#"
)

Variables

var (
    // Debug is true when the SWAGGER_DEBUG env var is not empty.
    // It enables a more verbose logging of this package.
    Debug = os.Getenv("SWAGGER_DEBUG") != ""
)
var PathLoader func(string) (json.RawMessage, error)

PathLoader function to use when loading remote refs

func Asset Uses

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDigest Uses

func AssetDigest(name string) ([sha256.Size]byte, error)

AssetDigest returns the digest of the file with the given name. It returns an error if the asset could not be found or the digest could not be loaded.

func AssetDir Uses

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"}, AssetDir("data/img") would return []string{"a.png", "b.png"}, AssetDir("foo.txt") and AssetDir("notexist") would return an error, and AssetDir("") will return []string{"data"}.

func AssetInfo Uses

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames Uses

func AssetNames() []string

AssetNames returns the names of the assets.

func AssetString Uses

func AssetString(name string) (string, error)

AssetString returns the asset contents as a string (instead of a []byte).

func Digests Uses

func Digests() (map[string][sha256.Size]byte, error)

Digests returns a map of all known files and their checksums.

func ExpandParameter Uses

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 Uses

func ExpandParameterWithRoot(parameter *Parameter, root interface{}, cache ResolutionCache) error

ExpandParameterWithRoot expands a parameter based on a root document, not a fetchable document

func ExpandResponse Uses

func ExpandResponse(response *Response, basePath string) error

ExpandResponse expands a response based on a basepath This is the exported version of expandResponse all refs inside response will be resolved relative to basePath

func ExpandResponseWithRoot Uses

func ExpandResponseWithRoot(response *Response, root interface{}, cache ResolutionCache) error

ExpandResponseWithRoot expands a response based on a root document, not a fetchable document

func ExpandSchema Uses

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 file other than root

func ExpandSchemaWithBasePath Uses

func ExpandSchemaWithBasePath(schema *Schema, cache ResolutionCache, opts *ExpandOptions) error

ExpandSchemaWithBasePath expands the refs in the schema object, base path configured through expand options

func ExpandSpec Uses

func ExpandSpec(spec *Swagger, options *ExpandOptions) error

ExpandSpec expands the references in a swagger spec

func MustAsset Uses

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func MustAssetString Uses

func MustAssetString(name string) string

MustAssetString is like AssetString but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset Uses

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory.

func RestoreAssets Uses

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively.

type CommonValidations Uses

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

CommonValidations describe common JSON-schema validations

type ContactInfo Uses

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

ContactInfo contact information for the exposed API.

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

type Definitions Uses

type Definitions map[string]Schema

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 Uses

type Dependencies map[string]SchemaOrStringArray

Dependencies represent a dependencies property

type ExpandOptions Uses

type ExpandOptions struct {
    RelativeBase        string
    SkipSchemas         bool
    ContinueOnError     bool
    AbsoluteCircularRef bool
}

ExpandOptions provides options for spec expand

type Extensions Uses

type Extensions map[string]interface{}

Extensions vendor specific extensions

func (Extensions) Add Uses

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

Add adds a value to these extensions

func (Extensions) GetBool Uses

func (e Extensions) GetBool(key string) (bool, bool)

GetBool gets a string value from the extensions

func (Extensions) GetString Uses

func (e Extensions) GetString(key string) (string, bool)

GetString gets a string value from the extensions

func (Extensions) GetStringSlice Uses

func (e Extensions) GetStringSlice(key string) ([]string, bool)

GetStringSlice gets a string value from the extensions

type ExternalDocumentation Uses

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

func ResponseHeader() *Header

ResponseHeader creates a new header instance for use in a response

func (*Header) AllowDuplicates Uses

func (h *Header) AllowDuplicates() *Header

AllowDuplicates this array can have duplicates

func (*Header) CollectionOf Uses

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

CollectionOf a fluent builder method for an array item

func (Header) JSONLookup Uses

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

JSONLookup look up a value by the json property name

func (Header) MarshalJSON Uses

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

MarshalJSON marshal this to JSON

func (*Header) Typed Uses

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

Typed a fluent builder method for the type of parameter

func (*Header) UniqueValues Uses

func (h *Header) UniqueValues() *Header

UniqueValues dictates that this array can only have unique items

func (*Header) UnmarshalJSON Uses

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

UnmarshalJSON unmarshals this header from JSON

func (*Header) WithDefault Uses

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

WithDefault sets the default value on this item

func (*Header) WithDescription Uses

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

WithDescription sets the description on this response, allows for chaining

func (*Header) WithEnum Uses

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

WithEnum sets a the enum values (replace)

func (*Header) WithMaxItems Uses

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

WithMaxItems sets the max items

func (*Header) WithMaxLength Uses

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

WithMaxLength sets a max length value

func (*Header) WithMaximum Uses

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

WithMaximum sets a maximum number value

func (*Header) WithMinItems Uses

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

WithMinItems sets the min items

func (*Header) WithMinLength Uses

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

WithMinLength sets a min length value

func (*Header) WithMinimum Uses

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

WithMinimum sets a minimum number value

func (*Header) WithMultipleOf Uses

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

WithMultipleOf sets a multiple of value

func (*Header) WithPattern Uses

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

WithPattern sets a pattern value

type HeaderProps Uses

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

HeaderProps describes a response header

type Info Uses

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 Uses

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

JSONLookup look up a value by the json property name

func (Info) MarshalJSON Uses

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

MarshalJSON marshal this to JSON

func (*Info) UnmarshalJSON Uses

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

UnmarshalJSON marshal this from JSON

type InfoProps Uses

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 Uses

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 NewItems Uses

func NewItems() *Items

NewItems creates a new instance of items

func ResolveItems Uses

func ResolveItems(root interface{}, ref Ref, opts *ExpandOptions) (*Items, error)

ResolveItems 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 Uses

func (i *Items) AllowDuplicates() *Items

AllowDuplicates this array can have duplicates

func (*Items) AsNullable Uses

func (i *Items) AsNullable() *Items

AsNullable flags this schema as nullable.

func (*Items) CollectionOf Uses

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

CollectionOf a fluent builder method for an array item

func (Items) JSONLookup Uses

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

JSONLookup look up a value by the json property name

func (Items) MarshalJSON Uses

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

MarshalJSON converts this items object to JSON

func (*Items) Typed Uses

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

Typed a fluent builder method for the type of item

func (*Items) UniqueValues Uses

func (i *Items) UniqueValues() *Items

UniqueValues dictates that this array can only have unique items

func (*Items) UnmarshalJSON Uses

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

UnmarshalJSON hydrates this items instance with the data from JSON

func (*Items) WithDefault Uses

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

WithDefault sets the default value on this item

func (*Items) WithEnum Uses

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

WithEnum sets a the enum values (replace)

func (*Items) WithMaxItems Uses

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

WithMaxItems sets the max items

func (*Items) WithMaxLength Uses

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

WithMaxLength sets a max length value

func (*Items) WithMaximum Uses

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

WithMaximum sets a maximum number value

func (*Items) WithMinItems Uses

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

WithMinItems sets the min items

func (*Items) WithMinLength Uses

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

WithMinLength sets a min length value

func (*Items) WithMinimum Uses

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

WithMinimum sets a minimum number value

func (*Items) WithMultipleOf Uses

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

WithMultipleOf sets a multiple of value

func (*Items) WithPattern Uses

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

WithPattern sets a pattern value

type License Uses

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

License information for the exposed API.

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

type Operation Uses

type Operation struct {
    VendorExtensible
    OperationProps
}

Operation describes a single API operation on a path.

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

func NewOperation Uses

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 Uses

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 Uses

func (o *Operation) Deprecate() *Operation

Deprecate marks the operation as deprecated

func (*Operation) GobDecode Uses

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

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

func (Operation) GobEncode Uses

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

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

func (Operation) JSONLookup Uses

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

JSONLookup look up a value by the json property name

func (Operation) MarshalJSON Uses

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

MarshalJSON converts this items object to JSON

func (*Operation) RemoveParam Uses

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

RemoveParam removes a parameter from the operation

func (*Operation) RespondsWith Uses

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 Uses

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

SecuredWith adds a security scope to this operation.

func (*Operation) SuccessResponse Uses

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

SuccessResponse gets a success response model

func (*Operation) Undeprecate Uses

func (o *Operation) Undeprecate() *Operation

Undeprecate marks the operation as not deprected

func (*Operation) UnmarshalJSON Uses

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

UnmarshalJSON hydrates this items instance with the data from JSON

func (*Operation) WithConsumes Uses

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

WithConsumes adds media types for incoming body values

func (*Operation) WithDefaultResponse Uses

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 Uses

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

WithDescription sets the description on this operation, allows for chaining

func (*Operation) WithExternalDocs Uses

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 Uses

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

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

func (*Operation) WithProduces Uses

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

WithProduces adds media types for outgoing body values

func (*Operation) WithSummary Uses

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

WithSummary sets the summary on this operation, allows for chaining

func (*Operation) WithTags Uses

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

WithTags adds tags for this operation

type OperationProps Uses

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

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

func (*OperationProps) GobDecode Uses

func (op *OperationProps) GobDecode(b []byte) error

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

func (OperationProps) GobEncode Uses

func (op OperationProps) GobEncode() ([]byte, error)

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

func (OperationProps) MarshalJSON Uses

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 ParamProps Uses

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

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 Parameter Uses

type Parameter struct {
    Refable
    CommonValidations
    SimpleSchema
    VendorExtensible
    ParamProps
}

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

There are five possible parameter types. * Path - Used together with [Path Templating](#pathTemplating), 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. * Body - The payload that's appended to the HTTP request. Since there can only be one payload, there can only be

_one_ body parameter. The name of the body parameter has no effect on the parameter itself and is used for
documentation purposes only. Since Form parameters are also in the payload, body and form parameters cannot exist
together for the same operation.

* Form - Used to describe the payload of an HTTP request when either `application/x-www-form-urlencoded` or

`multipart/form-data` are used as the content type of the request (in Swagger's definition,
the [`consumes`](#operationConsumes) property of an operation). This is the only parameter type that can be used
to send files, thus supporting the `file` type. Since form parameters are sent in the payload, they cannot be
declared together with a body parameter for the same operation. Form parameters have a different format based on
the content-type used (for further details, consult http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4).
* `application/x-www-form-urlencoded` - Similar to the format of Query parameters but as a payload.
For example, `foo=1&bar=swagger` - both `foo` and `bar` are form parameters. This is normally used for simple
parameters that are being transferred.
* `multipart/form-data` - each parameter takes a section in the payload with an internal header.
For example, for the header `Content-Disposition: form-data; name="submit-name"` the name of the parameter is
`submit-name`. This type of form parameters is more commonly used for file transfers.

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

func BodyParam Uses

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

BodyParam creates a body parameter

func FileParam Uses

func FileParam(name string) *Parameter

FileParam creates a body parameter

func FormDataParam Uses

func FormDataParam(name string) *Parameter

FormDataParam creates a body parameter

func HeaderParam Uses

func HeaderParam(name string) *Parameter

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

func ParamRef Uses

func ParamRef(uri string) *Parameter

ParamRef creates a parameter that's a json reference

func PathParam Uses

func PathParam(name string) *Parameter

PathParam creates a path parameter, this is always required

func QueryParam Uses

func QueryParam(name string) *Parameter

QueryParam creates a query parameter

func ResolveParameter Uses

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

ResolveParameter resolves a parameter reference against a context root

func ResolveParameterWithBase Uses

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

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

func SimpleArrayParam Uses

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

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

func (*Parameter) AllowDuplicates Uses

func (p *Parameter) AllowDuplicates() *Parameter

AllowDuplicates this array can have duplicates

func (*Parameter) AllowsEmptyValues Uses

func (p *Parameter) AllowsEmptyValues() *Parameter

AllowsEmptyValues flags this parameter as being ok with empty values

func (*Parameter) AsOptional Uses

func (p *Parameter) AsOptional() *Parameter

AsOptional flags this parameter as optional

func (*Parameter) AsRequired Uses

func (p *Parameter) AsRequired() *Parameter

AsRequired flags this parameter as required

func (*Parameter) CollectionOf Uses

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

CollectionOf a fluent builder method for an array parameter

func (Parameter) JSONLookup Uses

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

JSONLookup look up a value by the json property name

func (Parameter) MarshalJSON Uses

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

MarshalJSON converts this items object to JSON

func (*Parameter) Named Uses

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

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

func (*Parameter) NoEmptyValues Uses

func (p *Parameter) NoEmptyValues() *Parameter

NoEmptyValues flags this parameter as not liking empty values

func (*Parameter) Typed Uses

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

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

func (*Parameter) UniqueValues Uses

func (p *Parameter) UniqueValues() *Parameter

UniqueValues dictates that this array can only have unique items

func (*Parameter) UnmarshalJSON Uses

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

UnmarshalJSON hydrates this items instance with the data from JSON

func (*Parameter) WithDefault Uses

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

WithDefault sets the default value on this parameter

func (*Parameter) WithDescription Uses

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

WithDescription a fluent builder method for the description of the parameter

func (*Parameter) WithEnum Uses

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

WithEnum sets a the enum values (replace)

func (*Parameter) WithLocation Uses

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

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

func (*Parameter) WithMaxItems Uses

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

WithMaxItems sets the max items

func (*Parameter) WithMaxLength Uses

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

WithMaxLength sets a max length value

func (*Parameter) WithMaximum Uses

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

WithMaximum sets a maximum number value

func (*Parameter) WithMinItems Uses

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

WithMinItems sets the min items

func (*Parameter) WithMinLength Uses

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

WithMinLength sets a min length value

func (*Parameter) WithMinimum Uses

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

WithMinimum sets a minimum number value

func (*Parameter) WithMultipleOf Uses

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

WithMultipleOf sets a multiple of value

func (*Parameter) WithPattern Uses

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

WithPattern sets a pattern value

type PathItem Uses

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 Uses

func ResolvePathItem(root interface{}, ref Ref, opts *ExpandOptions) (*PathItem, error)

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

func (PathItem) JSONLookup Uses

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

JSONLookup look up a value by the json property name

func (PathItem) MarshalJSON Uses

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

MarshalJSON converts this items object to JSON

func (*PathItem) UnmarshalJSON Uses

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

UnmarshalJSON hydrates this items instance with the data from JSON

type PathItemProps Uses

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 Uses

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 Uses

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

JSONLookup look up a value by the json property name

func (Paths) MarshalJSON Uses

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

MarshalJSON converts this items object to JSON

func (*Paths) UnmarshalJSON Uses

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

UnmarshalJSON hydrates this items instance with the data from JSON

type Ref Uses

type Ref struct {
    jsonreference.Ref
}

Ref represents a json reference that is potentially resolved

func MustCreateRef Uses

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 Uses

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 Uses

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

GobDecode provides a safe gob decoder for Ref

func (Ref) GobEncode Uses

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

GobEncode provides a safe gob encoder for Ref

func (*Ref) Inherits Uses

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 Uses

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

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

func (Ref) MarshalJSON Uses

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

MarshalJSON marshals this ref into a JSON object

func (*Ref) RemoteURI Uses

func (r *Ref) RemoteURI() string

RemoteURI gets the remote uri part of the ref

func (*Ref) UnmarshalJSON Uses

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

UnmarshalJSON unmarshals this ref from a JSON object

type Refable Uses

type Refable struct {
    Ref Ref
}

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

func (Refable) MarshalJSON Uses

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

MarshalJSON marshals the ref to json

func (*Refable) UnmarshalJSON Uses

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

UnmarshalJSON unmarshalss the ref from json

type ResolutionCache Uses

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

ResolutionCache a cache for resolving urls

type Response Uses

type Response struct {
    Refable
    ResponseProps
    VendorExtensible
}

Response describes a single response from an API Operation.

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

func NewResponse Uses

func NewResponse() *Response

NewResponse creates a new response instance

func ResolveResponse Uses

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

ResolveResponse resolves response a reference against a context root

func ResolveResponseWithBase Uses

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

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

func ResponseRef Uses

func ResponseRef(url string) *Response

ResponseRef creates a response as a json reference

func (*Response) AddExample Uses

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

AddExample adds an example to this response

func (*Response) AddHeader Uses

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

AddHeader adds a header to this response

func (Response) JSONLookup Uses

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

JSONLookup look up a value by the json property name

func (Response) MarshalJSON Uses

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

MarshalJSON converts this items object to JSON

func (*Response) RemoveHeader Uses

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

RemoveHeader removes a header from this response

func (*Response) UnmarshalJSON Uses

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

UnmarshalJSON hydrates this items instance with the data from JSON

func (*Response) WithDescription Uses

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

WithDescription sets the description on this response, allows for chaining

func (*Response) WithSchema Uses

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 Uses

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

ResponseProps properties specific to a response

type Responses Uses

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 Uses

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

JSONLookup implements an interface to customize json pointer lookup

func (Responses) MarshalJSON Uses

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

MarshalJSON converts this items object to JSON

func (*Responses) UnmarshalJSON Uses

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

UnmarshalJSON hydrates this items instance with the data from JSON

type ResponsesProps Uses

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

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 Uses

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

MarshalJSON marshals responses as JSON

func (*ResponsesProps) UnmarshalJSON Uses

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

UnmarshalJSON unmarshals responses from JSON

type Schema Uses

type Schema struct {
    VendorExtensible
    SchemaProps
    SwaggerSchemaProps
    ExtraProps map[string]interface{} `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 Uses

func ArrayProperty(items *Schema) *Schema

ArrayProperty creates an array property

func BoolProperty Uses

func BoolProperty() *Schema

BoolProperty creates a boolean property

func BooleanProperty Uses

func BooleanProperty() *Schema

BooleanProperty creates a boolean property

func CharProperty Uses

func CharProperty() *Schema

CharProperty creates a string property

func ComposedSchema Uses

func ComposedSchema(schemas ...Schema) *Schema

ComposedSchema creates a schema with allOf

func DateProperty Uses

func DateProperty() *Schema

DateProperty creates a date property

func DateTimeProperty Uses

func DateTimeProperty() *Schema

DateTimeProperty creates a date time property

func Float32Property Uses

func Float32Property() *Schema

Float32Property creates a float32/float property

func Float64Property Uses

func Float64Property() *Schema

Float64Property creates a float64/double property

func Int16Property Uses

func Int16Property() *Schema

Int16Property creates an int16 property

func Int32Property Uses

func Int32Property() *Schema

Int32Property creates an int32 property

func Int64Property Uses

func Int64Property() *Schema

Int64Property creates an int64 property

func Int8Property Uses

func Int8Property() *Schema

Int8Property creates an int8 property

func JSONSchemaDraft04 Uses

func JSONSchemaDraft04() (*Schema, error)

JSONSchemaDraft04 loads the json schema document for json shema draft04

func MapProperty Uses

func MapProperty(property *Schema) *Schema

MapProperty creates a map property

func MustLoadJSONSchemaDraft04 Uses

func MustLoadJSONSchemaDraft04() *Schema

MustLoadJSONSchemaDraft04 panics when Swagger20Schema returns an error

func MustLoadSwagger20Schema Uses

func MustLoadSwagger20Schema() *Schema

MustLoadSwagger20Schema panics when Swagger20Schema returns an error

func RefProperty Uses

func RefProperty(name string) *Schema

RefProperty creates a ref property

func RefSchema Uses

func RefSchema(name string) *Schema

RefSchema creates a ref property

func ResolveRef Uses

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

ResolveRef resolves a reference 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 Uses

func ResolveRefWithBase(root interface{}, ref *Ref, opts *ExpandOptions) (*Schema, error)

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

func StrFmtProperty Uses

func StrFmtProperty(format string) *Schema

StrFmtProperty creates a property for the named string format

func StringProperty Uses

func StringProperty() *Schema

StringProperty creates a string property

func Swagger20Schema Uses

func Swagger20Schema() (*Schema, error)

Swagger20Schema loads the swagger 2.0 schema from the embedded assets

func (*Schema) AddRequired Uses

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

AddRequired adds field names to the required properties array

func (*Schema) AddToAllOf Uses

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

AddToAllOf adds a schema to the allOf property

func (*Schema) AddType Uses

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

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

func (*Schema) AllowDuplicates Uses

func (s *Schema) AllowDuplicates() *Schema

AllowDuplicates this array can have duplicates

func (*Schema) AsNullable Uses

func (s *Schema) AsNullable() *Schema

AsNullable flags this schema as nullable.

func (*Schema) AsReadOnly Uses

func (s *Schema) AsReadOnly() *Schema

AsReadOnly flags this schema as readonly

func (*Schema) AsUnwrappedXML Uses

func (s *Schema) AsUnwrappedXML() *Schema

AsUnwrappedXML flags this object as an xml node

func (*Schema) AsWrappedXML Uses

func (s *Schema) AsWrappedXML() *Schema

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

func (*Schema) AsWritable Uses

func (s *Schema) AsWritable() *Schema

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

func (*Schema) AsXMLAttribute Uses

func (s *Schema) AsXMLAttribute() *Schema

AsXMLAttribute flags this object as xml attribute

func (*Schema) AsXMLElement Uses

func (s *Schema) AsXMLElement() *Schema

AsXMLElement flags this object as an xml node

func (*Schema) CollectionOf Uses

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

CollectionOf a fluent builder method for an array parameter

func (Schema) JSONLookup Uses

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

JSONLookup implements an interface to customize json pointer lookup

func (Schema) MarshalJSON Uses

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

MarshalJSON marshal this to JSON

func (*Schema) SetProperty Uses

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

SetProperty sets a property on this schema

func (*Schema) Typed Uses

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

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

func (*Schema) UniqueValues Uses

func (s *Schema) UniqueValues() *Schema

UniqueValues dictates that this array can only have unique items

func (*Schema) UnmarshalJSON Uses

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

UnmarshalJSON marshal this from JSON

func (*Schema) WithAllOf Uses

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

WithAllOf sets the all of property

func (*Schema) WithDefault Uses

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

WithDefault sets the default value on this parameter

func (*Schema) WithDescription Uses

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

WithDescription sets the description for this schema, allows for chaining

func (*Schema) WithDiscriminator Uses

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

WithDiscriminator sets the name of the discriminator field

func (*Schema) WithEnum Uses

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

WithEnum sets a the enum values (replace)

func (*Schema) WithExample Uses

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

WithExample sets the example for this schema

func (*Schema) WithExternalDocs Uses

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 Uses

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

WithID sets the id for this schema, allows for chaining

func (*Schema) WithMaxItems Uses

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

WithMaxItems sets the max items

func (*Schema) WithMaxLength Uses

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

WithMaxLength sets a max length value

func (*Schema) WithMaxProperties Uses

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

WithMaxProperties sets the max number of properties an object can have

func (*Schema) WithMaximum Uses

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

WithMaximum sets a maximum number value

func (*Schema) WithMinItems Uses

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

WithMinItems sets the min items

func (*Schema) WithMinLength Uses

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

WithMinLength sets a min length value

func (*Schema) WithMinProperties Uses

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

WithMinProperties sets the min number of properties an object must have

func (*Schema) WithMinimum Uses

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

WithMinimum sets a minimum number value

func (*Schema) WithMultipleOf Uses

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

WithMultipleOf sets a multiple of value

func (*Schema) WithPattern Uses

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

WithPattern sets a pattern value

func (*Schema) WithProperties Uses

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

WithProperties sets the properties for this schema

func (*Schema) WithRequired Uses

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

WithRequired flags this parameter as required

func (*Schema) WithTitle Uses

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

WithTitle sets the title for this schema, allows for chaining

func (*Schema) WithXMLName Uses

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

WithXMLName sets the xml name for the object

func (*Schema) WithXMLNamespace Uses

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

WithXMLNamespace sets the xml namespace for the object

func (*Schema) WithXMLPrefix Uses

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

WithXMLPrefix sets the xml prefix for the object

type SchemaOrArray Uses

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

SchemaOrArray represents a value that can either be a Schema or an array of Schema. Mainly here for serialization purposes

func (*SchemaOrArray) ContainsType Uses

func (s *SchemaOrArray) ContainsType(name string) bool

ContainsType returns true when one of the schemas is of the specified type

func (SchemaOrArray) JSONLookup Uses

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

JSONLookup implements an interface to customize json pointer lookup

func (SchemaOrArray) Len Uses

func (s SchemaOrArray) Len() int

Len returns the number of schemas in this property

func (SchemaOrArray) MarshalJSON Uses

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

MarshalJSON converts this schema object or array into JSON structure

func (*SchemaOrArray) UnmarshalJSON Uses

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

UnmarshalJSON converts this schema object or array from a JSON structure

type SchemaOrBool Uses

type SchemaOrBool struct {
    Allows bool
    Schema *Schema
}

SchemaOrBool represents a schema or boolean value, is biased towards true for the boolean property

func (SchemaOrBool) JSONLookup Uses

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

JSONLookup implements an interface to customize json pointer lookup

func (SchemaOrBool) MarshalJSON Uses

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

MarshalJSON convert this object to JSON

func (*SchemaOrBool) UnmarshalJSON Uses

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

UnmarshalJSON converts this bool or schema object from a JSON structure

type SchemaOrStringArray Uses

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

SchemaOrStringArray represents a schema or a string array

func (SchemaOrStringArray) JSONLookup Uses

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

JSONLookup implements an interface to customize json pointer lookup

func (SchemaOrStringArray) MarshalJSON Uses

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

MarshalJSON converts this schema object or array into JSON structure

func (*SchemaOrStringArray) UnmarshalJSON Uses

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

UnmarshalJSON converts this schema object or array from a JSON structure

type SchemaProps Uses

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           map[string]Schema `json:"properties,omitempty"`
    AdditionalProperties *SchemaOrBool     `json:"additionalProperties,omitempty"`
    PatternProperties    map[string]Schema `json:"patternProperties,omitempty"`
    Dependencies         Dependencies      `json:"dependencies,omitempty"`
    AdditionalItems      *SchemaOrBool     `json:"additionalItems,omitempty"`
    Definitions          Definitions       `json:"definitions,omitempty"`
}

SchemaProps describes a JSON schema (draft 4)

type SchemaURL Uses

type SchemaURL string

SchemaURL represents a schema url

func (SchemaURL) MarshalJSON Uses

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

MarshalJSON marshal this to JSON

func (*SchemaURL) UnmarshalJSON Uses

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

UnmarshalJSON unmarshal this from JSON

type SecurityDefinitions Uses

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 Uses

type SecurityScheme struct {
    VendorExtensible
    SecuritySchemeProps
}

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

func APIKeyAuth Uses

func APIKeyAuth(fieldName, valueSource string) *SecurityScheme

APIKeyAuth creates an api key auth security scheme

func BasicAuth Uses

func BasicAuth() *SecurityScheme

BasicAuth creates a basic auth security scheme

func OAuth2AccessToken Uses

func OAuth2AccessToken(authorizationURL, tokenURL string) *SecurityScheme

OAuth2AccessToken creates an access token flow oauth2 security scheme

func OAuth2Application Uses

func OAuth2Application(tokenURL string) *SecurityScheme

OAuth2Application creates an application flow oauth2 security scheme

func OAuth2Implicit Uses

func OAuth2Implicit(authorizationURL string) *SecurityScheme

OAuth2Implicit creates an implicit flow oauth2 security scheme

func OAuth2Password Uses

func OAuth2Password(tokenURL string) *SecurityScheme

OAuth2Password creates a password flow oauth2 security scheme

func (SecurityScheme) JSONLookup Uses

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

JSONLookup implements an interface to customize json pointer lookup

func (SecurityScheme) MarshalJSON Uses

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

MarshalJSON marshal this to JSON

func (*SecurityScheme) UnmarshalJSON Uses

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

UnmarshalJSON marshal this from JSON

type SecuritySchemeProps Uses

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,omitempty"` // oauth2
    TokenURL         string            `json:"tokenUrl,omitempty"`         // oauth2
    Scopes           map[string]string `json:"scopes,omitempty"`           // oauth2
}

SecuritySchemeProps describes a swagger security scheme in the securityDefinitions section

func (*SecuritySchemeProps) AddScope Uses

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

AddScope adds a scope to this security scheme

type SimpleSchema Uses

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

SimpleSchema describe swagger simple schemas for parameters and headers

func (*SimpleSchema) ItemsTypeName Uses

func (s *SimpleSchema) ItemsTypeName() string

ItemsTypeName yields the type of items in a simple schema array

func (*SimpleSchema) TypeName Uses

func (s *SimpleSchema) TypeName() string

TypeName return the type (or format) of a simple schema

type StringOrArray Uses

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 Uses

func (s StringOrArray) Contains(value string) bool

Contains returns true when the value is contained in the slice

func (StringOrArray) MarshalJSON Uses

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

MarshalJSON converts this string or array to a JSON array or JSON string

func (*StringOrArray) UnmarshalJSON Uses

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

UnmarshalJSON unmarshals this string or array object from a JSON array or JSON string

type Swagger Uses

type Swagger struct {
    VendorExtensible
    SwaggerProps
}

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-

func (*Swagger) GobDecode Uses

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

GobDecode provides a safe gob decoder for Swagger, including extensions

func (Swagger) GobEncode Uses

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

GobEncode provides a safe gob encoder for Swagger, including extensions

func (Swagger) JSONLookup Uses

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

JSONLookup look up a value by the json property name

func (Swagger) MarshalJSON Uses

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

MarshalJSON marshals this swagger structure to json

func (*Swagger) UnmarshalJSON Uses

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

UnmarshalJSON unmarshals a swagger spec from json

type SwaggerProps Uses

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

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

func (*SwaggerProps) GobDecode Uses

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

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

func (SwaggerProps) GobEncode Uses

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

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

type SwaggerSchemaProps Uses

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

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

type Tag Uses

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 Uses

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

NewTag creates a new tag

func (Tag) JSONLookup Uses

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

JSONLookup implements an interface to customize json pointer lookup

func (Tag) MarshalJSON Uses

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

MarshalJSON marshal this to JSON

func (*Tag) UnmarshalJSON Uses

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

UnmarshalJSON marshal this from JSON

type TagProps Uses

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 Uses

type VendorExtensible struct {
    Extensions Extensions
}

VendorExtensible composition block.

func (*VendorExtensible) AddExtension Uses

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

AddExtension adds an extension to this extensible object

func (VendorExtensible) MarshalJSON Uses

func (v VendorExtensible) MarshalJSON() ([]byte, error)

MarshalJSON marshals the extensions to json

func (*VendorExtensible) UnmarshalJSON Uses

func (v *VendorExtensible) UnmarshalJSON(data []byte) error

UnmarshalJSON for this extensible object

type XMLObject Uses

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 Uses

func (x *XMLObject) AsAttribute() *XMLObject

AsAttribute flags this object as xml attribute

func (*XMLObject) AsElement Uses

func (x *XMLObject) AsElement() *XMLObject

AsElement flags this object as an xml node

func (*XMLObject) AsUnwrapped Uses

func (x *XMLObject) AsUnwrapped() *XMLObject

AsUnwrapped flags this object as an xml node

func (*XMLObject) AsWrapped Uses

func (x *XMLObject) AsWrapped() *XMLObject

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

func (*XMLObject) WithName Uses

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

WithName sets the xml name for the object

func (*XMLObject) WithNamespace Uses

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

WithNamespace sets the xml namespace for the object

func (*XMLObject) WithPrefix Uses

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

WithPrefix sets the xml prefix for the object

Package spec imports 24 packages (graph) and is imported by 555 packages. Updated 2019-09-18. Refresh now. Tools for package owners.