spec

package
v0.0.0-...-d88c8b5 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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

func MustCreateRef(refURI string) Ref

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

func NewRef

func NewRef(refURI string) (Ref, error)

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

func (*Ref) Inherits

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

Inherits creates a new reference from a parent and a child If the child cannot inherit from the parent, an error is returned

func (*Ref) IsValidURI

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

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

func (Ref) MarshalJSON

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

MarshalJSON marshals this ref into a JSON object

func (*Ref) RemoteURI

func (r *Ref) RemoteURI() string

RemoteURI gets the remote uri part of the ref

func (*Ref) UnmarshalJSON

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

UnmarshalJSON unmarshals this ref from a JSON object

type Refable

type Refable struct {
	Ref Ref
}

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

func (Refable) MarshalJSON

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

MarshalJSON marshals the ref to json

func (*Refable) UnmarshalJSON

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

UnmarshalJSON unmarshalss the ref from json

type 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

func ArrayProperty(items *Schema) *Schema

ArrayProperty creates an array property

func BoolProperty

func BoolProperty() *Schema

BoolProperty creates a boolean property

func BooleanProperty

func BooleanProperty() *Schema

BooleanProperty creates a boolean property

func CharProperty

func CharProperty() *Schema

CharProperty creates a string property

func ComposedSchema

func ComposedSchema(schemas ...Schema) *Schema

ComposedSchema creates a schema with allOf

func DateProperty

func DateProperty() *Schema

DateProperty creates a date property

func DateTimeProperty

func DateTimeProperty() *Schema

DateTimeProperty creates a date time property

func Float32Property

func Float32Property() *Schema

Float32Property creates a float32/float property

func Float64Property

func Float64Property() *Schema

Float64Property creates a float64/double property

func Int16Property

func Int16Property() *Schema

Int16Property creates an int16 property

func Int32Property

func Int32Property() *Schema

Int32Property creates an int32 property

func Int64Property

func Int64Property() *Schema

Int64Property creates an int64 property

func Int8Property

func Int8Property() *Schema

Int8Property creates an int8 property

func MapProperty

func MapProperty(property *Schema) *Schema

MapProperty creates a map property

func RefProperty

func RefProperty(name string) *Schema

RefProperty creates a ref property

func RefSchema

func RefSchema(name string) *Schema

RefSchema creates a ref property

func 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 (*Schema) AddRequired

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

AddRequired adds field names to the required properties array

func (*Schema) AddToAllOf

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

AddToAllOf adds a schema to the allOf property

func (*Schema) AddType

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

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

func (*Schema) AllowDuplicates

func (s *Schema) AllowDuplicates() *Schema

AllowDuplicates this array can have duplicates

func (*Schema) AsNullable

func (s *Schema) AsNullable() *Schema

AsNullable flags this schema as nullable.

func (*Schema) AsReadOnly

func (s *Schema) AsReadOnly() *Schema

AsReadOnly flags this schema as readonly

func (*Schema) AsWritable

func (s *Schema) AsWritable() *Schema

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

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

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

WithDescription sets the description for this schema, allows for chaining

func (*Schema) WithDiscriminator

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

WithDiscriminator sets the name of the discriminator field

func (*Schema) WithEnum

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

WithEnum sets a the enum values (replace)

func (*Schema) WithExample

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

WithExample sets the example for this schema

func (*Schema) WithExternalDocs

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

WithExternalDocs sets/removes the external docs for/from this schema. When you pass empty strings as params the external documents will be removed. When you pass non-empty string as one value then those values will be used on the external docs object. So when you pass a non-empty description, you should also pass the url and vice versa.

func (*Schema) WithID

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

WithID sets the id for this schema, allows for chaining

func (*Schema) WithMaxItems

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

WithMaxItems sets the max items

func (*Schema) WithMaxLength

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

WithMaxLength sets a max length value

func (*Schema) WithMaxProperties

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

WithMaxProperties sets the max number of properties an object can have

func (*Schema) WithMaximum

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

WithMaximum sets a maximum number value

func (*Schema) WithMinItems

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

WithMinItems sets the min items

func (*Schema) WithMinLength

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

WithMinLength sets a min length value

func (*Schema) WithMinProperties

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

WithMinProperties sets the min number of properties an object must have

func (*Schema) WithMinimum

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

WithMinimum sets a minimum number value

func (*Schema) WithMultipleOf

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

WithMultipleOf sets a multiple of value

func (*Schema) WithPattern

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

WithPattern sets a pattern value

func (*Schema) WithProperties

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

WithProperties sets the properties for this schema

func (*Schema) WithRequired

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

WithRequired flags this parameter as required

func (*Schema) WithTitle

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

WithTitle sets the title for this schema, allows for chaining

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

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

Jump to

Keyboard shortcuts

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