All Classes Namespaces Functions Variables Groups Pages
Swagger::SchemaObject Class Reference

defines an object in a schema More...

Inheritance diagram for Swagger::SchemaObject:
[legend]

## Public Member Functions

list< SchemaObject > | allOf ()
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.3. More...
| check (bool serialize, bool request, string path, string method, string name, reference value)
| validates the value against the schema definition
string | getQoreExample (reference< hash< RestQoreExampleCodeInfo >> rv, string name, bool decl)
| returns example Qore code for the object
Public Member Functions inherited from Swagger::ObjectBase
| constructor ()
| Constructor.
| constructor (hash oh)
| Constructor. More...
| constructor (ObjectBase other)
| copy constructor
| initialize (hash oh)
| Initialize. More...
Public Member Functions inherited from Swagger::SchemaBase
| constructor (string objType, hash oh)
| Constructor. More...
| constructor (SchemaBase other)
| Copy constructor.

## Static Public Member Functions

static SchemaObject | newSchemaObject (string name, hash oh, SwaggerSchema swagger)
| returns a SchemaObject for the schema definition; resolves references More...
static SchemaObject | newSchemaObject (string name, auto error, SwaggerSchema swagger)
| throws an `"INVALID-FIELD-TYPE"` exception More...

## Public Attributes

auto | additionalProperties
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.4.4. More...
auto | defaultVal
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-6.2.
*string | desc
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-6.1.
*string | discriminator
| Adds support for polymorphism. More...
auto | example
| A free-form property to include an example of an instance for this schema.
*ExternalDocumentationObject | externalDocs
| Additional external documentation for this schema.
*string | format
| The extending format for the previously mentioned `type`. See Data Type Formats for further details.
*SchemaObject | items
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.3.1.
*int | maxProperties
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.4.1.
*int | minProperties
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.4.2.
string | name
| the name of this object for documentation and example purposes
hash< string, SchemaObject > | properties
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.4.4. More...
bool | readOnly = False
| Relevant only for Schema `"properties"` definitions. Declares the property as "read only". More...
const | ReferenceTypes
| valid reference types
hash< string, bool > | required
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.4.3. More...
const | ScalarTypes
| valid scalar types
*string | title
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-6.1.
string | type
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.2. More...
*XmlObject | xml
| This MAY be used only on properties schemas. It has no effect on root schemas. More...
Public Attributes inherited from Swagger::ObjectBase
hash | vendorExtensions
| Allows extensions to the Swagger Schema. More...
Public Attributes inherited from Swagger::SchemaBase
hash< string, bool > | enum
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1. More...
*bool | exclusiveMax
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.1.2.
*bool | exclusiveMin
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.1.3.
*float | maximum
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.1.2.
*int | maxItems
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.3.2.
*int | maxLength
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.1.
*float | minimum
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.1.3.
*int | minItems
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.3.3.
*int | minLength
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.2.
*float | multipleOf
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.1.1.
*string | pattern
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.2.3.
*bool | uniqueItems
| See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.3.4.

## Private Member Functions

| checkIntern (bool serialize, bool request, string type, *string format, string path, string method, string name, hash v, reference< hash > value)
| validates a schema object against a value
| constructor (string name, hash oh, SwaggerSchema swagger)
| private constructor; use newSchemaObject() instead More...

## Static Private Member Functions

static | checkValueType (auto value, string type, *SchemaObject items, *string loc)
| validates default values

## Detailed Description

defines an object in a schema

## Member Function Documentation

list<SchemaObject> Swagger::SchemaObject::allOf | ( |  | ) |

See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.3.

List of SchemaObjects; MUST have at least one element.

Swagger allows combining and extending model definitions using the `allOf` property of JSON Schema, in effect offering model composition. `allOf` takes in an array of object definitions that are validated independently but together compose a single object.

Swagger::SchemaObject::constructor | ( | string | name,
|  | hash | oh,
|  | SwaggerSchema | swagger
| ) |  |

private

private constructor; use newSchemaObject() instead

Parameters

  name | the name of the object
  oh | deserialized hash from the source schema description describing an object in the schema
  swagger | the REST schema for resolving references

Exceptions

  INVALID-FIELD-FORMAT | field has invalid format
  INVALID-FIELD-TYPE | field has invalid type
  INVALID-FIELD-VALUE | field has invalid value
  INVALID-REFERENCE | cannot resolve reference; unknown attributes in description
  REQUIRED-FIELD-MISSING | required field is missing

static SchemaObject Swagger::SchemaObject::newSchemaObject | ( | string | name,
|  | hash | oh,
|  | SwaggerSchema | swagger
| ) |  |

static

returns a SchemaObject for the schema definition; resolves references

Parameters

  name | the name of the object
  oh | deserialized hash from the source schema description describing an object in the schema
  swagger | the REST schema for resolving references

Exceptions

  INVALID-FIELD-FORMAT | field has invalid format
  INVALID-FIELD-TYPE | field has invalid type
  INVALID-FIELD-VALUE | field has invalid value
  INVALID-REFERENCE | cannot resolve reference; unknown attributes in description
  REQUIRED-FIELD-MISSING | required field is missing

static SchemaObject Swagger::SchemaObject::newSchemaObject | ( | string | name,
|  | auto | error,
|  | SwaggerSchema | swagger
| ) |  |

static

throws an `"INVALID-FIELD-TYPE"` exception

Exceptions

  INVALID-FIELD-TYPE | due to a type error in the call

## Member Data Documentation

auto Swagger::SchemaObject::additionalProperties

See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.4.4.

MUST be a bool or an object. If it is an object, it MUST also be a valid JSON Schema (SchemaObject).

*string Swagger::SchemaObject::discriminator

Adds support for polymorphism.

The discriminator is the schema property name that is used to differentiate between other schemas that inherit this schema. The property name used MUST be defined at this schema and it MUST be in the required property list. When used, the value MUST be the name of this schema or any schema that inherits it.

While composition offers model extensibility, it does not imply a hierarchy between the models. To support polymorphism, Swagger adds the support of the `discriminator` field. When used, the `discriminator` will be the name of the property used to decide which schema definition is used to validate the structure of the model. As such, the `discriminator` field MUST be a required field. The value of the chosen property has to be the friendly name given to the model under the `definitions` property. As such, inline schema definitions, which do not have a given id, cannot be used in polymorphism.

hash<string, SchemaObject> Swagger::SchemaObject::properties

See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.4.4.

MUST be an object. Each value of this object MUST be an object, and each object MUST be a valid JSON Schema (SchemaObject).

bool Swagger::SchemaObject::readOnly = False

Relevant only for Schema `"properties"` definitions. Declares the property as "read only".

Declares the property as "read only". This means that it MAY be sent as part of a response but MUST NOT be sent as part of the request. Properties marked as `readOnly` being `true` SHOULD NOT be in the required list of the defined schema. Default value is `false`.

hash<string, bool> Swagger::SchemaObject::required

See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.4.3.

Set of strings. Must have at least one element.

string Swagger::SchemaObject::type

See https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.2.

MUST be either a string or an array (list). If it's an array, it's elements MUST be strings and MUST be unique.

*XmlObject Swagger::SchemaObject::xml

This MAY be used only on properties schemas. It has no effect on root schemas.

Adds Additional metadata to describe the XML representation format of this property.

The `xml` property allows extra definitions when translating the JSON definition to XML. The XmlObject contains additional information about the available options.