From 9e00dfacda2999b1d58cd06ec8b0717a31492874 Mon Sep 17 00:00:00 2001 From: Matatjahu Date: Wed, 2 Jun 2021 16:09:56 +0200 Subject: [PATCH] fix: support true/false JSON Schemas in Schema Object --- spec/asyncapi.md | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/spec/asyncapi.md b/spec/asyncapi.md index f61827c21..81ec49ecb 100644 --- a/spec/asyncapi.md +++ b/spec/asyncapi.md @@ -839,7 +839,7 @@ Describes a parameter included in a channel name. Field Name | Type | Description ---|:---:|--- description | `string` | A verbose explanation of the parameter. [CommonMark syntax](http://spec.commonmark.org/) can be used for rich text representation. -schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject) | Definition of the parameter. +schema | [Schema Object](#schemaObject) | [Reference Object](#referenceObject) | `boolean` | Definition of the parameter. location | `string` | A [runtime expression](#runtimeExpression) that specifies the location of the parameter value. Even when a definition for the target field exists, it MUST NOT be used to validate this parameter but, instead, the `schema` property MUST be used. This object can be extended with [Specification Extensions](#specificationExtensions). @@ -1001,7 +1001,7 @@ Describes a message received on a given channel and operation. Field Name | Type | Description ---|:---:|--- -headers | [Schema Object](#schemaObject) | [Reference Object](#referenceObject) | Schema definition of the application headers. Schema MUST be of type "object". It **MUST NOT** define the protocol headers. +headers | [Schema Object](#schemaObject) | [Reference Object](#referenceObject) | `boolean` | Schema definition of the application headers. Schema MUST be of type "object". It **MUST NOT** define the protocol headers. payload | `any` | Definition of the message payload. It can be of any type but defaults to [Schema object](#schemaObject). correlationId | [Correlation ID Object](#correlationIdObject) | [Reference Object](#referenceObject) | Definition of the correlation ID used for message tracing or matching. schemaFormat | `string` | A string containing the name of the schema format used to define the message payload. If omitted, implementations should parse the payload as a [Schema object](#schemaObject). Check out the [supported schema formats table](#messageObjectSchemaFormatTable) for more information. Custom values are allowed but their implementation is OPTIONAL. A custom value MUST NOT refer to one of the schema formats listed in the [table](#messageObjectSchemaFormatTable). @@ -1192,7 +1192,7 @@ If you're looking to apply traits to an operation, see the [Operation Trait Obje Field Name | Type | Description ---|:---:|--- -headers | [Schema Object](#schemaObject) | [Reference Object](#referenceObject) | Schema definition of the application headers. Schema MUST be of type "object". It **MUST NOT** define the protocol headers. +headers | [Schema Object](#schemaObject) | [Reference Object](#referenceObject) | `boolean` | Schema definition of the application headers. Schema MUST be of type "object". It **MUST NOT** define the protocol headers. correlationId | [Correlation ID Object](#correlationIdObject) | [Reference Object](#referenceObject) | Definition of the correlation ID used for message tracing or matching. schemaFormat | `string` | A string containing the name of the schema format/language used to define the message payload. If omitted, implementations should parse the payload as a [Schema object](#schemaObject). contentType | `string` | The content type to use when encoding/decoding a message's payload. The value MUST be a specific media type (e.g. `application/json`). When omitted, the value MUST be the one specified on the [defaultContentType](#defaultContentTypeString) field. @@ -1322,7 +1322,7 @@ All objects defined within the components object will have no effect on the API Field Name | Type | Description ---|:---|--- - schemas | Map[`string`, [Schema Object](#schemaObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Schema Objects](#schemaObject). + schemas | Map[`string`, [Schema Object](#schemaObject) | [Reference Object](#referenceObject)] | `boolean` | An object to hold reusable [Schema Objects](#schemaObject). messages | Map[`string`, [Message Object](#messageObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Message Objects](#messageObject). securitySchemes| Map[`string`, [Security Scheme Object](#securitySchemeObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Security Scheme Objects](#securitySchemeObject). parameters | Map[`string`, [Parameter Object](#parameterObject) \| [Reference Object](#referenceObject)] | An object to hold reusable [Parameter Objects](#parameterObject). @@ -1509,7 +1509,7 @@ components: #### Schema Object The Schema Object allows the definition of input and output data types. -These types can be objects, but also primitives and arrays. +These types can be objects, but also primitives and arrays or be defined as boolean values. `True` means that the type can be anything, while `false` means that the given schema cannot be defined. This object is a superset of the [JSON Schema Specification Draft 07](http://json-schema.org/). Further information about the properties can be found in [JSON Schema Core](https://tools.ietf.org/html/draft-handrews-json-schema-01) and [JSON Schema Validation](https://tools.ietf.org/html/draft-handrews-json-schema-validation-01). @@ -1718,6 +1718,30 @@ example: id: 1 ``` +###### Model with true/false schemas + +```json +{ + "type": "object", + "required": [ + "anySchema" + ], + "properties": { + "anySchema": true, + "neverBeDefined.": false + } +} +``` + +```yaml +type: object +required: +- anySchema +properties: + anySchema: true + neverBeDefined: false +``` + ###### Models with Composition ```json