Documentation ¶
Index ¶
- type Definitions
- type Dependencies
- type Extensions
- type ExternalDocumentation
- type Ref
- type Refable
- type Schema
- func ArrayProperty(items *Schema) *Schema
- func BoolProperty() *Schema
- func BooleanProperty() *Schema
- func CharProperty() *Schema
- func ComposedSchema(schemas ...Schema) *Schema
- func DateProperty() *Schema
- func DateTimeProperty() *Schema
- func Float32Property() *Schema
- func Float64Property() *Schema
- func Int16Property() *Schema
- func Int32Property() *Schema
- func Int64Property() *Schema
- func Int8Property() *Schema
- func MapProperty(property *Schema) *Schema
- func RefProperty(name string) *Schema
- func RefSchema(name string) *Schema
- func StrFmtProperty(format string) *Schema
- func StringProperty() *Schema
- func (s *Schema) AddRequired(items ...string) *Schema
- func (s *Schema) AddToAllOf(schemas ...Schema) *Schema
- func (s *Schema) AddType(tpe, format string) *Schema
- func (s *Schema) AllowDuplicates() *Schema
- func (s *Schema) AsNullable() *Schema
- func (s *Schema) AsReadOnly() *Schema
- func (s *Schema) AsWritable() *Schema
- func (s *Schema) CollectionOf(items Schema) *Schema
- func (s Schema) JSONLookup(token string) (interface{}, error)
- func (s Schema) MarshalJSON() ([]byte, error)
- func (s *Schema) SetProperty(name string, schema Schema) *Schema
- func (s *Schema) Typed(tpe, format string) *Schema
- func (s *Schema) UniqueValues() *Schema
- func (s *Schema) UnmarshalJSON(data []byte) error
- func (s *Schema) WithAllOf(schemas ...Schema) *Schema
- func (s *Schema) WithDefault(defaultValue interface{}) *Schema
- func (s *Schema) WithDescription(description string) *Schema
- func (s *Schema) WithDiscriminator(discriminator string) *Schema
- func (s *Schema) WithEnum(values ...interface{}) *Schema
- func (s *Schema) WithExample(example interface{}) *Schema
- func (s *Schema) WithExternalDocs(description, url string) *Schema
- func (s *Schema) WithID(id string) *Schema
- func (s *Schema) WithMaxItems(size int64) *Schema
- func (s *Schema) WithMaxLength(max int64) *Schema
- func (s *Schema) WithMaxProperties(max int64) *Schema
- func (s *Schema) WithMaximum(max float64, exclusive bool) *Schema
- func (s *Schema) WithMinItems(size int64) *Schema
- func (s *Schema) WithMinLength(min int64) *Schema
- func (s *Schema) WithMinProperties(min int64) *Schema
- func (s *Schema) WithMinimum(min float64, exclusive bool) *Schema
- func (s *Schema) WithMultipleOf(number float64) *Schema
- func (s *Schema) WithPattern(pattern string) *Schema
- func (s *Schema) WithProperties(schemas map[string]Schema) *Schema
- func (s *Schema) WithRequired(items ...string) *Schema
- func (s *Schema) WithTitle(title string) *Schema
- type SchemaOrArray
- type SchemaOrBool
- type SchemaOrStringArray
- type SchemaProps
- type SchemaURL
- type StringOrArray
- type SwaggerSchemaProps
- type VendorExtensible
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Definitions ¶
Definitions contains the models explicitly defined in this spec An object to hold data types that can be consumed and produced by operations. These data types can be primitives, arrays or models.
For more information: http://goo.gl/8us55a#definitionsObject
type Dependencies ¶
type Dependencies map[string]SchemaOrStringArray
Dependencies represent a dependencies property
type 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) GetBool ¶
func (e Extensions) GetBool(key string) (bool, bool)
GetBool gets a string value from the extensions
func (Extensions) GetString ¶
func (e Extensions) GetString(key string) (string, bool)
GetString gets a string value from the extensions
func (Extensions) GetStringSlice ¶
func (e Extensions) GetStringSlice(key string) ([]string, bool)
GetStringSlice gets a string value from the extensions
type ExternalDocumentation ¶
type ExternalDocumentation struct { Description string `json:"description,omitempty"` URL string `json:"url,omitempty"` }
ExternalDocumentation allows referencing an external resource for extended documentation.
For more information: http://goo.gl/8us55a#externalDocumentationObject
type Ref ¶
type Ref struct {
jsonreference.Ref
}
Ref represents a json reference that is potentially resolved
func MustCreateRef ¶
MustCreateRef creates a ref object but panics when refURI is invalid. Use the NewRef method for a version that returns an error.
func NewRef ¶
NewRef creates a new instance of a ref object returns an error when the reference uri is an invalid uri
func (*Ref) Inherits ¶
Inherits creates a new reference from a parent and a child If the child cannot inherit from the parent, an error is returned
func (*Ref) IsValidURI ¶
IsValidURI returns true when the url the ref points to can be found
func (Ref) MarshalJSON ¶
MarshalJSON marshals this ref into a JSON object
func (*Ref) RemoteURI ¶
RemoteURI gets the remote uri part of the ref
type Refable ¶
type Refable struct {
Ref Ref
}
Refable is a struct for things that accept a $ref property
func (Refable) MarshalJSON ¶
MarshalJSON marshals the ref to json
type Schema ¶
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 ¶
ArrayProperty creates an array property
func ComposedSchema ¶
ComposedSchema creates a schema with allOf
func DateTimeProperty ¶
func DateTimeProperty() *Schema
DateTimeProperty creates a date time property
func Float32Property ¶
func Float32Property() *Schema
Float32Property creates a float32/float property
func Float64Property ¶
func Float64Property() *Schema
Float64Property creates a float64/double property
func StrFmtProperty ¶
StrFmtProperty creates a property for the named string format
func (*Schema) AddRequired ¶
AddRequired adds field names to the required properties array
func (*Schema) AddToAllOf ¶
AddToAllOf adds a schema to the allOf property
func (*Schema) AddType ¶
AddType adds a type with potential format to the types for this schema
func (*Schema) AllowDuplicates ¶
AllowDuplicates this array can have duplicates
func (*Schema) AsNullable ¶
AsNullable flags this schema as nullable.
func (*Schema) AsReadOnly ¶
AsReadOnly flags this schema as readonly
func (*Schema) AsWritable ¶
AsWritable flags this schema as writeable (not read-only)
func (*Schema) CollectionOf ¶
CollectionOf a fluent builder method for an array parameter
func (Schema) JSONLookup ¶
JSONLookup implements an interface to customize json pointer lookup
func (Schema) MarshalJSON ¶
MarshalJSON marshal this to JSON
func (*Schema) SetProperty ¶
SetProperty sets a property on this schema
func (*Schema) Typed ¶
Typed sets the type of this schema for a single value item
func (*Schema) UniqueValues ¶
UniqueValues dictates that this array can only have unique items
func (*Schema) UnmarshalJSON ¶
UnmarshalJSON marshal this from JSON
func (*Schema) WithAllOf ¶
WithAllOf sets the all of property
func (*Schema) WithDefault ¶
WithDefault sets the default value on this parameter
func (*Schema) WithDescription ¶
WithDescription sets the description for this schema, allows for chaining
func (*Schema) WithDiscriminator ¶
WithDiscriminator sets the name of the discriminator field
func (*Schema) WithEnum ¶
WithEnum sets a the enum values (replace)
func (*Schema) WithExample ¶
WithExample sets the example for this schema
func (*Schema) WithExternalDocs ¶
WithExternalDocs sets/removes the external docs for/from this schema. When you pass empty strings as params the external documents will be removed. When you pass non-empty string as one value then those values will be used on the external docs object. So when you pass a non-empty description, you should also pass the url and vice versa.
func (*Schema) WithID ¶
WithID sets the id for this schema, allows for chaining
func (*Schema) WithMaxItems ¶
WithMaxItems sets the max items
func (*Schema) WithMaxLength ¶
WithMaxLength sets a max length value
func (*Schema) WithMaxProperties ¶
WithMaxProperties sets the max number of properties an object can have
func (*Schema) WithMaximum ¶
WithMaximum sets a maximum number value
func (*Schema) WithMinItems ¶
WithMinItems sets the min items
func (*Schema) WithMinLength ¶
WithMinLength sets a min length value
func (*Schema) WithMinProperties ¶
WithMinProperties sets the min number of properties an object must have
func (*Schema) WithMinimum ¶
WithMinimum sets a minimum number value
func (*Schema) WithMultipleOf ¶
WithMultipleOf sets a multiple of value
func (*Schema) WithPattern ¶
WithPattern sets a pattern value
func (*Schema) WithProperties ¶
WithProperties sets the properties for this schema
func (*Schema) WithRequired ¶
WithRequired flags this parameter as required
type SchemaOrArray ¶
SchemaOrArray represents a value that can either be a Schema or an array of Schema. Mainly here for serialization purposes
func (*SchemaOrArray) ContainsType ¶
func (s *SchemaOrArray) ContainsType(name string) bool
ContainsType returns true when one of the schemas is of the specified type
func (SchemaOrArray) JSONLookup ¶
func (s SchemaOrArray) JSONLookup(token string) (interface{}, error)
JSONLookup implements an interface to customize json pointer lookup
func (SchemaOrArray) Len ¶
func (s SchemaOrArray) Len() int
Len returns the number of schemas in this property
func (SchemaOrArray) MarshalJSON ¶
func (s SchemaOrArray) MarshalJSON() ([]byte, error)
MarshalJSON converts this schema object or array into JSON structure
func (*SchemaOrArray) UnmarshalJSON ¶
func (s *SchemaOrArray) UnmarshalJSON(data []byte) error
UnmarshalJSON converts this schema object or array from a JSON structure
type SchemaOrBool ¶
SchemaOrBool represents a schema or boolean value, is biased towards true for the boolean property
func (SchemaOrBool) JSONLookup ¶
func (s SchemaOrBool) JSONLookup(token string) (interface{}, error)
JSONLookup implements an interface to customize json pointer lookup
func (SchemaOrBool) MarshalJSON ¶
func (s SchemaOrBool) MarshalJSON() ([]byte, error)
MarshalJSON convert this object to JSON
func (*SchemaOrBool) UnmarshalJSON ¶
func (s *SchemaOrBool) UnmarshalJSON(data []byte) error
UnmarshalJSON converts this bool or schema object from a JSON structure
type SchemaOrStringArray ¶
SchemaOrStringArray represents a schema or a string array
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 SchemaProps ¶
type SchemaProps struct { ID string `json:"id,omitempty"` Ref Ref `json:"-"` Schema SchemaURL `json:"-"` Description string `json:"description,omitempty"` Type StringOrArray `json:"type,omitempty"` Nullable bool `json:"nullable,omitempty"` Format string `json:"format,omitempty"` Title string `json:"title,omitempty"` Default 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 ¶
type SchemaURL string
SchemaURL represents a schema url
func (SchemaURL) MarshalJSON ¶
MarshalJSON marshal this to 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 SwaggerSchemaProps ¶
type SwaggerSchemaProps struct { Discriminator string `json:"discriminator,omitempty"` ReadOnly bool `json:"readOnly,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 VendorExtensible ¶
type VendorExtensible struct {
Extensions Extensions
}
VendorExtensible composition block.
func (*VendorExtensible) AddExtension ¶
func (v *VendorExtensible) AddExtension(key string, value interface{})
AddExtension adds an extension to this extensible object
func (VendorExtensible) MarshalJSON ¶
func (v VendorExtensible) MarshalJSON() ([]byte, error)
MarshalJSON marshals the extensions to json
func (*VendorExtensible) UnmarshalJSON ¶
func (v *VendorExtensible) UnmarshalJSON(data []byte) error
UnmarshalJSON for this extensible object