spec

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2015 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
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

This section is empty.

Functions

func Asset

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 AssetDir

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 AssetDir("") will return []string{"data"}.

func AssetInfo

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

func AssetNames() []string

AssetNames returns the names of the assets.

func ExpandSchema

func ExpandSchema(schema *Schema, root interface{}, cache ResolutionCache) error

ExpandSchema expands the refs in the schema object

func MustAsset

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 RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type ContactInfo

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

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

type Dependencies map[string]SchemaOrStringArray

Dependencies represent a dependencies property

type DocLoader

type DocLoader func(string) (json.RawMessage, error)

DocLoader represents a doc loader type

type Document

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

Document represents a swagger spec document

func JSONSpec

func JSONSpec(path string) (*Document, error)

JSONSpec loads a spec from a json document

func Load

func Load(path string) (*Document, error)

Load loads a new spec document

func New

func New(data json.RawMessage, version string) (*Document, error)

New creates a new shema document

func YAMLSpec

func YAMLSpec(path string) (*Document, error)

YAMLSpec loads a swagger spec document

func (*Document) AllDefinitions

func (s *Document) AllDefinitions() (result []SchemaRef)

func (*Document) AllPaths

func (s *Document) AllPaths() map[string]PathItem

AllPaths returns all the paths in the swagger spec

func (*Document) BasePath

func (d *Document) BasePath() string

BasePath the base path for this spec

func (*Document) ConsumesFor

func (s *Document) ConsumesFor(operation *Operation) []string

ConsumesFor gets the mediatypes for the operation

func (*Document) Expanded

func (d *Document) Expanded() (*Document, error)

Expanded expands the ref fields in the spec document and returns a new spec document

func (*Document) Host

func (d *Document) Host() string

Host returns the host for the API

func (*Document) OperationFor

func (s *Document) OperationFor(method, path string) (*Operation, bool)

func (*Document) OperationForName

func (s *Document) OperationForName(operationID string) (string, string, *Operation, bool)

func (*Document) OperationIDs

func (s *Document) OperationIDs() []string

func (*Document) Operations

func (s *Document) Operations() map[string]map[string]*Operation

func (*Document) ParametersFor

func (s *Document) ParametersFor(operationID string) []Parameter

func (*Document) ParamsFor

func (s *Document) ParamsFor(method, path string) map[string]Parameter

func (*Document) ProducesFor

func (s *Document) ProducesFor(operation *Operation) []string

ProducesFor gets the mediatypes for the operation

func (*Document) Raw

func (d *Document) Raw() json.RawMessage

Raw returns the raw swagger spec as json bytes

func (*Document) Reload

func (d *Document) Reload() *Document

Reload reanalyzes the spec

func (*Document) RequiredConsumes

func (s *Document) RequiredConsumes() []string

func (*Document) RequiredProduces

func (s *Document) RequiredProduces() []string

func (*Document) RequiredSecuritySchemes

func (s *Document) RequiredSecuritySchemes() []string

func (*Document) Schema

func (d *Document) Schema() *Schema

Schema returns the swagger 2.0 schema

func (*Document) SchemasWithAllOf

func (s *Document) SchemasWithAllOf() (result []SchemaRef)

func (*Document) SecurityDefinitionsFor

func (s *Document) SecurityDefinitionsFor(operation *Operation) map[string]SecurityScheme

SecurityDefinitionsFor gets the matching security definitions for a set of requirements

func (*Document) SecurityRequirementsFor

func (s *Document) SecurityRequirementsFor(operation *Operation) []SecurityRequirement

SecurityRequirementsFor gets the security requirements for the operation

func (*Document) Spec

func (d *Document) Spec() *Swagger

Spec returns the swagger spec object model

func (*Document) Version

func (d *Document) Version() string

Version returns the version of this spec

type Extensions

type Extensions map[string]interface{}

Extensions vendor specific extensions

func (Extensions) Add

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

Add adds a value to these extensions

func (Extensions) GetString

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

GetString gets a string value from the extensions

type ExternalDocumentation

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

ExternalDocumentation allows referencing an external resource for extended documentation.

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

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

Header describes a header for a response of the API

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

func (*Header) CollectionOf

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

CollectionOf a fluent builder method for an array item

func (*Header) ItemsTypeName

func (s *Header) ItemsTypeName() string

func (Header) MarshalJSON

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

MarshalJSON marshal this to JSON

func (*Header) TypeName

func (s *Header) TypeName() string

func (*Header) Typed

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

Typed a fluent builder method for the type of parameter

func (*Header) UnmarshalJSON

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

UnmarshalJSON marshal this from JSON

type Info

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

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

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

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 Items

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

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

func NewItems() *Items

NewItems creates a new instance of items

func (*Items) AllowDuplicates

func (i *Items) AllowDuplicates() *Items

AllowDuplicates this array can have duplicates

func (*Items) CollectionOf

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

CollectionOf a fluent builder method for an array item

func (*Items) ItemsTypeName

func (s *Items) ItemsTypeName() string

func (Items) MarshalJSON

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

MarshalJSON converts this items object to JSON

func (*Items) TypeName

func (s *Items) TypeName() string

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

type License

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

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

Operation describes a single API operation on a path.

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

func (*Operation) AddExtension

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

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

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

SuccessResponse gets a success response model

func (*Operation) UnmarshalJSON

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

UnmarshalJSON hydrates this items instance with the data from JSON

type Parameter

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

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

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

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

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

func (*Parameter) AddExtension

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

func (*Parameter) AllowDuplicates

func (p *Parameter) AllowDuplicates() *Parameter

AllowDuplicates this array can have duplicates

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

func (s *Parameter) ItemsTypeName() string

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

func (s *Parameter) TypeName() string

func (*Parameter) Typed

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

Typed a fluent builder method for the type of parameter

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

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

WithEnum sets a the enum values (replace)

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

type PathItem

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

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 (*PathItem) AddExtension

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

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 Paths

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

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

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

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

type Ref struct {
	jsonreference.Ref
}

Ref represents a json reference that is potentially resolved

func MustCreateRef

func MustCreateRef(refURI string) Ref

MustCreateRef creates a ref object but

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

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

MarshalJSON marshals this ref into a JSON object

func (*Ref) UnmarshalJSON

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

UnmarshalJSON unmarshals this ref from a JSON object

type ResolutionCache

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

ResolutionCache a cache for resolving urls

type Response

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

Response describes a single response from an API Operation.

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

func (Response) MarshalJSON

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

MarshalJSON converts this items object to JSON

func (*Response) UnmarshalJSON

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

UnmarshalJSON hydrates this items instance with the data from JSON

type Responses

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

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

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

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 Schema

type Schema struct {
	ExtraProps map[string]interface{} `json:"-"`
	// contains filtered or unexported fields
}

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

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

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

ResolveRef resolves a reference against a context root

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

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

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

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

WithEnum sets a the enum values (replace)

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

type SchemaOrArray

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

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

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

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

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

SchemaOrStringArray represents a schema or a string array

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 SchemaRef

type SchemaRef struct {
	Name   string
	Ref    Ref
	Schema *Schema
}

SchemaRef is a reference to a schema

type SchemaURL

type SchemaURL string

SchemaURL represents a schema url

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 SecurityDefinitions

type SecurityDefinitions map[string]*SecurityScheme

SecurityDefinitions a declaration of the security schemes available to be used in the specification. This does not enforce the security schemes on the operations and only serves to provide the relevant details for each scheme.

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

type SecurityRequirement

type SecurityRequirement struct {
	Name   string
	Scopes []string
}

SecurityRequirement is a representation of a security requirement for an operation

type SecurityScheme

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

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

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

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

func (*SecurityScheme) AddScope

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

AddScope adds a scope to this 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 StringOrArray

type StringOrArray []string

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

func (StringOrArray) Contains

func (s StringOrArray) Contains(value string) bool

Contains returns true when the value is contained in the slice

func (StringOrArray) MarshalJSON

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

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

func (*StringOrArray) UnmarshalJSON

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

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

type Swagger

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

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

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

Tag allows adding meta data to a single tag that is used by the [Operation Object](http://goo.gl/8us55a#operationObject). It is not mandatory to have a Tag Object per tag used there.

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

func NewTag

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

NewTag creates a new tag

func (*Tag) AddExtension

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

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 XMLObject

type XMLObject struct {
	Name      string `json:"name,omitempty"`
	Namespace string `json:"namespace,omitempty"`
	Prefix    string `json:"prefix,omitempty"`
	Attribute bool   `json:"attribute,omitempty"`
	Wrapped   bool   `json:"wrapped,omitempty"`
}

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

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

Jump to

Keyboard shortcuts

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