Skip to content

Commit dd328b7

Browse files
author
Phil Sturgeon
committed
Update Schema Object to proper JSON Schema
1 parent eba36b2 commit dd328b7

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

versions/3.1.0.md

+32-23
Original file line numberDiff line numberDiff line change
@@ -2276,11 +2276,16 @@ This object is an extended subset of the [JSON Schema Specification Wright Draft
22762276
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).
22772277
Unless stated otherwise, the property definitions follow the JSON Schema.
22782278

2279-
##### Properties
2279+
##### Properties
22802280

2281-
The following properties are taken directly from the JSON Schema definition and follow the same specifications:
2281+
OpenAPI v3.1 is a JSON Schema vocabulary which eetends 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:
22822282

22832283
- title
2284+
- type
2285+
- required
2286+
- allOf
2287+
- oneOf
2288+
- andOf
22842289
- multipleOf
22852290
- maximum
22862291
- exclusiveMaximum
@@ -2294,46 +2299,50 @@ The following properties are taken directly from the JSON Schema definition and
22942299
- uniqueItems
22952300
- maxProperties
22962301
- minProperties
2297-
- required
22982302
- 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`.
2303+
- propertyNames
2304+
- contains
2305+
- const
2306+
- examples
2307+
- if / then / else
2308+
- dependentRequired / dependentSchemas
2309+
- deprecated
2310+
- additionalItems
2311+
- additionalProperties
2312+
- unevaluatedItems
2313+
- unevaluatedProperties
2314+
- maxContains
2315+
- minContains
2316+
- readOnly
2317+
- writeOnly
2318+
2319+
The following properties are taken from the JSON Schema definition but their definitions were adjusted to the OpenAPI Specification.
2320+
2321+
- 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.
2322+
- 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.
23092323
- description - [CommonMark syntax](http://spec.commonmark.org/) MAY be used for rich text representation.
23102324
- 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.
2311-
- 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`.
2325+
- default - 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`. This differs from JSON Schema which only RECOMMENDS the default conforms to the schema.
23122326

23132327
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.
23142328

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:
2329+
In addition to the JSON Schema fields, the following OpenAPI vocabulary fields MAY be used for further schema documentation:
23182330

23192331
##### Fixed Fields
23202332
Field Name | Type | Description
23212333
---|:---:|---
2322-
<a name="schemaNullable"></a>nullable | `boolean` | Allows sending a `null` value for the defined schema. Default value is `false`.
2334+
<a name="schemaNullable"></a>nullable | `boolean` | Allows sending a `null` value for the defined schema. Default value is `false`. Deprecated. Move towards using `"type": "null"` & type arrays , e.g: `"type": ["string", "null"]`.
23232335
<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`.
23262336
<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.
2337+
<a name="schemaExternalDocs"></a>externalDocs | [External Documentation Object](#externalDocumentationObject) | Additional external documentation for this schema.
23282338
<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`.
23302339

23312340
This object MAY be extended with [Specification Extensions](#specificationExtensions).
23322341

23332342
###### <a name="schemaComposition"></a>Composition and Inheritance (Polymorphism)
23342343

23352344
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.
2345+
`allOf` takes an array of object definitions that are validated *independently* but together compose a single object.
23372346

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

0 commit comments

Comments
 (0)