Skip to content

Commit ac236d1

Browse files
author
Phil Sturgeon
committed
Update Schema Object to proper JSON Schema
1 parent 192aafe commit ac236d1

File tree

1 file changed

+36
-30
lines changed

1 file changed

+36
-30
lines changed

versions/3.1.0.md

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,23 +2269,23 @@ $ref: definitions.yaml#/Pet
22692269

22702270
#### <a name="schemaObject"></a>Schema Object
22712271

2272-
The Schema Object allows the definition of input and output data types.
2273-
These types can be objects, but also primitives and arrays.
2274-
This object is an extended subset of the [JSON Schema Specification Wright Draft 00](https://json-schema.org/).
2272+
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 a superset of the [JSON Schema Draft 2019-09](http://json-schema.org/) specification.
2273+
2274+
For more information about the properties, see [JSON Schema Core](https://json-schema.org/draft/2019-09/json-schema-core.html) and [JSON Schema Validation](https://json-schema.org/draft/2019-09/json-schema-validation.html).
22752275

2276-
For more information about the properties, see [JSON Schema Core](https://tools.ietf.org/html/draft-wright-json-schema-00) and [JSON Schema Validation](https://tools.ietf.org/html/draft-wright-json-schema-validation-00).
22772276
Unless stated otherwise, the property definitions follow the JSON Schema.
22782277

2279-
##### Properties
2278+
##### Properties
22802279

2281-
The following properties are taken directly from the JSON Schema definition and follow the same specifications:
2280+
The OpenAPI Schema Object is a JSON Schema vocabulary which extends JSON Schema Core and Validation vocabularies. As such any keyword available for those vocabularies is by definition available in OpenAPI, and will work the exact same way, including but not limited to:
22822281

2282+
- $schema
2283+
- $id
22832284
- title
2285+
- required
22842286
- multipleOf
22852287
- maximum
2286-
- exclusiveMaximum
22872288
- minimum
2288-
- exclusiveMinimum
22892289
- maxLength
22902290
- minLength
22912291
- pattern (This string SHOULD be a valid regular expression, according to the [ECMA 262 regular expression](https://www.ecma-international.org/ecma-262/5.1/#sec-7.8.5) dialect)
@@ -2294,46 +2294,52 @@ The following properties are taken directly from the JSON Schema definition and
22942294
- uniqueItems
22952295
- maxProperties
22962296
- minProperties
2297-
- required
22982297
- enum
2299-
2300-
The following properties are taken from the JSON Schema definition but their definitions were adjusted to the OpenAPI Specification.
2301-
- type - Value MUST be a string. Multiple types via an array are not supported.
2302-
- allOf - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema.
2303-
- oneOf - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema.
2304-
- anyOf - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema.
2305-
- not - Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema.
2306-
- items - Value MUST be an object and not an array. Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. `items` MUST be present if the `type` is `array`.
2307-
- properties - Property definitions MUST be a [Schema Object](#schemaObject) and not a standard JSON Schema (inline or referenced).
2308-
- additionalProperties - Value can be boolean or object. Inline or referenced schema MUST be of a [Schema Object](#schemaObject) and not a standard JSON Schema. Consistent with JSON Schema, `additionalProperties` defaults to `true`.
2309-
- description - [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
2298+
- propertyNames
2299+
- contains
2300+
- const
2301+
- examples
2302+
- if / then / else
2303+
- dependentRequired / dependentSchemas
2304+
- deprecated
2305+
- additionalItems
2306+
- additionalProperties
2307+
- unevaluatedItems
2308+
- unevaluatedProperties
2309+
- maxContains
2310+
- minContains
2311+
- readOnly
2312+
- writeOnly
2313+
2314+
The following properties are taken from the JSON Schema definition but their definitions were adjusted to the OpenAPI Specification.
2315+
2316+
- type - Used to restrict the allowed types as specified in JSON Schema, but may be modified by the [`nullable`](#schemaNullable) keyword.
2317+
- exclusiveMinimum - Value can be a numeric value just like JSON Schema, or for backwards compatibility with older drafts it can accept a boolean to act as a modifier to the `minimum` keyword. The numeric value usage is recommended.
2318+
- exclusiveMaximum - Value can be a numeric value just like JSON Schema, or for backwards compatibility with older drafts it can accept a boolean to act as a modifier to the `minimum` keyword. The numeric value usage is recommended.
2319+
- description - [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation.
23102320
- format - See [Data Type Formats](#dataTypeFormat) for further details. While relying on JSON Schema's defined formats, the OAS offers a few additional predefined formats.
23112321
- default - The default value represents what would be assumed by the consumer of the input as the value of the schema if one is not provided. Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level. For example, if `type` is `string`, then `default` can be `"foo"` but cannot be `1`.
23122322

23132323
Alternatively, any time a Schema Object can be used, a [Reference Object](#referenceObject) can be used in its place. This allows referencing definitions instead of defining them inline.
23142324

2315-
Additional properties defined by the JSON Schema specification that are not mentioned here are strictly unsupported.
2316-
2317-
Other than the JSON Schema subset fields, the following fields MAY be used for further schema documentation:
2325+
In addition to the JSON Schema fields, the following OpenAPI vocabulary properties MAY be used for further schema documentation:
23182326

23192327
##### Fixed Fields
2328+
23202329
Field Name | Type | Description
23212330
---|:---:|---
2322-
<a name="schemaNullable"></a>nullable | `boolean` | Allows sending a `null` value for the defined schema. Default value is `false`.
2331+
<a name="schemaNullable"></a>nullable | `boolean` | Allows sending a `null` value for the defined schema. Default value is `false`.<br><br>A `nullable` value of `true` allows `null` in addition to other specified `type` values only if `nullable` and `type` are both specified within the same schema object. The effect of `"nullable" : true` is limited to its expansion of the set of allowed types, within the scope of its containing schema. An `enum`, `const`, `allOf`, or other keyword can independently prohibit `null` values, effectively overriding `"nullable" : true`.<br><br>A `nullable` value of `false` leaves the specified or default `type` unmodified. It has no effect on the schema object.<br><br>**Deprecated:** The `type` property now allows "null" as a type, alone or within a type array. This is the standard way to allow null values in JSON Schema. Use of `nullable` is discouraged, and later versions of this specification may remove it.
23232332
<a name="schemaDiscriminator"></a>discriminator | [Discriminator Object](#discriminatorObject) | Adds support for polymorphism. The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description. See [Composition and Inheritance](#schemaComposition) for more details.
2324-
<a name="schemaReadOnly"></a>readOnly | `boolean` | Relevant only for Schema `"properties"` definitions. Declares the property as "read only". This means that it MAY be sent as part of a response but SHOULD NOT be sent as part of the request. If the property is marked as `readOnly` being `true` and is in the `required` list, the `required` will take effect on the response only. A property MUST NOT be marked as both `readOnly` and `writeOnly` being `true`. Default value is `false`.
2325-
<a name="schemaWriteOnly"></a>writeOnly | `boolean` | Relevant only for Schema `"properties"` definitions. Declares the property as "write only". Therefore, it MAY be sent as part of a request but SHOULD NOT be sent as part of the response. If the property is marked as `writeOnly` being `true` and is in the `required` list, the `required` will take effect on the request only. A property MUST NOT be marked as both `readOnly` and `writeOnly` being `true`. Default value is `false`.
23262333
<a name="schemaXml"></a>xml | [XML Object](#xmlObject) | This MAY be used only on properties schemas. It has no effect on root schemas. Adds additional metadata to describe the XML representation of this property.
2327-
<a name="schemaExternalDocs"></a>externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this schema.
2328-
<a name="schemaExample"></a>example | Any | A free-form property to include an example of an instance for this schema. To represent examples that cannot be naturally represented in JSON or YAML, a string value can be used to contain the example with escaping where necessary.
2329-
<a name="schemaDeprecated"></a> deprecated | `boolean` | Specifies that a schema is deprecated and SHOULD be transitioned out of usage. Default value is `false`.
2334+
<a name="schemaExternalDocs"></a>externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this schema.
2335+
<a name="schemaExample"></a>example | Any | A free-form property to include an example of an instance for this schema. To represent examples that cannot be naturally represented in JSON or YAML, a string value can be used to contain the example with escaping where necessary.<br><br>**Deprecated:** The `example` property has been deprecated in favor of the JSON Schema `examples` keyword. Use of `example` is discouraged, and later versions of this specification may remove it.
23302336

23312337
This object MAY be extended with [Specification Extensions](#specificationExtensions).
23322338

23332339
###### <a name="schemaComposition"></a>Composition and Inheritance (Polymorphism)
23342340

23352341
The OpenAPI Specification allows combining and extending model definitions using the `allOf` property of JSON Schema, in effect offering model composition.
2336-
`allOf` takes an array of object definitions that are validated *independently* but together compose a single object.
2342+
`allOf` takes an array of object definitions that are validated *independently* but together compose a single object.
23372343

23382344
While composition offers model extensibility, it does not imply a hierarchy between the models.
23392345
To support polymorphism, the OpenAPI Specification adds the `discriminator` field.

0 commit comments

Comments
 (0)