diff --git a/bindings/http/0.3.0/message.json b/bindings/http/0.3.0/message.json new file mode 100644 index 00000000..3d8b7f54 --- /dev/null +++ b/bindings/http/0.3.0/message.json @@ -0,0 +1,46 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://asyncapi.com/bindings/http/0.3.0/message.json", + "title": "HTTP message bindings object", + "description": "This object contains information about the message representation in HTTP.", + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" + } + }, + "properties": { + "headers": { + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json", + "description": "\tA Schema object containing the definitions for HTTP-specific headers. This schema MUST be of type 'object' and have a 'properties' key." + }, + "statusCode": { + "type": "number", + "description": "The HTTP response status code according to [RFC 9110](https://httpwg.org/specs/rfc9110.html#overview.of.status.codes). `statusCode` is only relevant for messages referenced by the [Operation Reply Object](https://www.asyncapi.com/docs/reference/specification/v3.0.0#operationReplyObject), as it defines the status code for the response. In all other cases, this value can be safely ignored." + }, + "bindingVersion": { + "type": "string", + "enum": [ + "0.3.0" + ], + "description": "The version of this binding. If omitted, \"latest\" MUST be assumed." + } + }, + "examples": [ + { + "headers": { + "type": "object", + "properties": { + "Content-Type": { + "type": "string", + "enum": [ + "application/json" + ] + } + } + }, + "bindingVersion": "0.3.0" + } + ] +} diff --git a/bindings/http/0.3.0/operation.json b/bindings/http/0.3.0/operation.json new file mode 100644 index 00000000..e53ef0c5 --- /dev/null +++ b/bindings/http/0.3.0/operation.json @@ -0,0 +1,82 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://asyncapi.com/bindings/http/0.3.0/operation.json", + "title": "HTTP operation bindings object", + "description": "This object contains information about the operation representation in HTTP.", + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" + } + }, + "properties": { + "method": { + "type": "string", + "enum": [ + "GET", + "PUT", + "POST", + "PATCH", + "DELETE", + "HEAD", + "OPTIONS", + "CONNECT", + "TRACE" + ], + "description": "When 'type' is 'request', this is the HTTP method, otherwise it MUST be ignored. Its value MUST be one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS', 'CONNECT', and 'TRACE'." + }, + "query": { + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json", + "description": "A Schema object containing the definitions for each query parameter. This schema MUST be of type 'object' and have a properties key." + }, + "bindingVersion": { + "type": "string", + "enum": [ + "0.3.0" + ], + "description": "The version of this binding. If omitted, 'latest' MUST be assumed." + } + }, + "examples": [ + { + "query": { + "type": "object", + "required": [ + "companyId" + ], + "properties": { + "companyId": { + "type": "number", + "minimum": 1, + "description": "The Id of the company." + } + }, + "additionalProperties": false + }, + "bindingVersion": "0.3.0" + }, + { + "method": "GET", + "query": { + "type": "object", + "required": [ + "companyId" + ], + "properties": { + "companyId": { + "type": "number", + "minimum": 1, + "description": "The Id of the company." + } + }, + "additionalProperties": false + }, + "bindingVersion": "0.3.0" + } + ] +} + + + + diff --git a/definitions/3.0.0/messageBindingsObject.json b/definitions/3.0.0/messageBindingsObject.json index 44266860..142fcd98 100644 --- a/definitions/3.0.0/messageBindingsObject.json +++ b/definitions/3.0.0/messageBindingsObject.json @@ -11,7 +11,7 @@ "http": { "properties": { "bindingVersion": { - "enum": ["0.2.0"] + "enum": ["0.2.0", "0.3.0"] } }, "allOf": [ @@ -40,6 +40,19 @@ "then": { "$ref": "http://asyncapi.com/bindings/http/0.2.0/message.json" } + }, + { + "if": { + "required": [ "bindingVersion" ], + "properties": { + "bindingVersion": { + "const": "0.3.0" + } + } + }, + "then": { + "$ref": "http://asyncapi.com/bindings/http/0.3.0/message.json" + } } ] }, diff --git a/definitions/3.0.0/operationBindingsObject.json b/definitions/3.0.0/operationBindingsObject.json index af9e550b..6a43fa62 100644 --- a/definitions/3.0.0/operationBindingsObject.json +++ b/definitions/3.0.0/operationBindingsObject.json @@ -11,7 +11,7 @@ "http": { "properties": { "bindingVersion": { - "enum": ["0.2.0"] + "enum": ["0.2.0", "0.3.0"] } }, "allOf": [ @@ -40,6 +40,19 @@ "then": { "$ref": "http://asyncapi.com/bindings/http/0.2.0/operation.json" } + }, + { + "if": { + "required": [ "bindingVersion" ], + "properties": { + "bindingVersion": { + "const": "0.3.0" + } + } + }, + "then": { + "$ref": "http://asyncapi.com/bindings/http/0.3.0/operation.json" + } } ] }, diff --git a/package-lock.json b/package-lock.json index 66dc4611..20519624 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@asyncapi/specs", - "version": "6.2.0", + "version": "6.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@asyncapi/specs", - "version": "6.2.0", + "version": "6.3.0", "license": "Apache-2.0", "dependencies": { "@types/json-schema": "^7.0.11" diff --git a/package.json b/package.json index c49b9da7..082bb1b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@asyncapi/specs", - "version": "6.2.0", + "version": "6.3.0", "description": "AsyncAPI schema versions", "main": "index.js", "types": "index.d.ts", diff --git a/schemas/3.0.0-without-$id.json b/schemas/3.0.0-without-$id.json index 7bbbbfdf..2eb4fc28 100644 --- a/schemas/3.0.0-without-$id.json +++ b/schemas/3.0.0-without-$id.json @@ -3464,7 +3464,8 @@ "properties": { "bindingVersion": { "enum": [ - "0.2.0" + "0.2.0", + "0.3.0" ] } }, @@ -3496,6 +3497,21 @@ "then": { "$ref": "#/definitions/bindings-http-0.2.0-message" } + }, + { + "if": { + "required": [ + "bindingVersion" + ], + "properties": { + "bindingVersion": { + "const": "0.3.0" + } + } + }, + "then": { + "$ref": "#/definitions/bindings-http-0.3.0-message" + } } ] }, @@ -3838,6 +3854,50 @@ } ] }, + "bindings-http-0.3.0-message": { + "title": "HTTP message bindings object", + "description": "This object contains information about the message representation in HTTP.", + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "#/definitions/specificationExtension" + } + }, + "properties": { + "headers": { + "$ref": "#/definitions/schema", + "description": "\tA Schema object containing the definitions for HTTP-specific headers. This schema MUST be of type 'object' and have a 'properties' key." + }, + "statusCode": { + "type": "number", + "description": "The HTTP response status code according to [RFC 9110](https://httpwg.org/specs/rfc9110.html#overview.of.status.codes). `statusCode` is only relevant for messages referenced by the [Operation Reply Object](https://www.asyncapi.com/docs/reference/specification/v3.0.0#operationReplyObject), as it defines the status code for the response. In all other cases, this value can be safely ignored." + }, + "bindingVersion": { + "type": "string", + "enum": [ + "0.3.0" + ], + "description": "The version of this binding. If omitted, \"latest\" MUST be assumed." + } + }, + "examples": [ + { + "headers": { + "type": "object", + "properties": { + "Content-Type": { + "type": "string", + "enum": [ + "application/json" + ] + } + } + }, + "bindingVersion": "0.3.0" + } + ] + }, "bindings-amqp-0.3.0-message": { "title": "AMQP message bindings object", "description": "This object contains information about the message representation in AMQP.", @@ -6409,7 +6469,8 @@ "properties": { "bindingVersion": { "enum": [ - "0.2.0" + "0.2.0", + "0.3.0" ] } }, @@ -6441,6 +6502,21 @@ "then": { "$ref": "#/definitions/bindings-http-0.2.0-operation" } + }, + { + "if": { + "required": [ + "bindingVersion" + ], + "properties": { + "bindingVersion": { + "const": "0.3.0" + } + } + }, + "then": { + "$ref": "#/definitions/bindings-http-0.3.0-operation" + } } ] }, @@ -6835,6 +6911,82 @@ } ] }, + "bindings-http-0.3.0-operation": { + "title": "HTTP operation bindings object", + "description": "This object contains information about the operation representation in HTTP.", + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "#/definitions/specificationExtension" + } + }, + "properties": { + "method": { + "type": "string", + "enum": [ + "GET", + "PUT", + "POST", + "PATCH", + "DELETE", + "HEAD", + "OPTIONS", + "CONNECT", + "TRACE" + ], + "description": "When 'type' is 'request', this is the HTTP method, otherwise it MUST be ignored. Its value MUST be one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS', 'CONNECT', and 'TRACE'." + }, + "query": { + "$ref": "#/definitions/schema", + "description": "A Schema object containing the definitions for each query parameter. This schema MUST be of type 'object' and have a properties key." + }, + "bindingVersion": { + "type": "string", + "enum": [ + "0.3.0" + ], + "description": "The version of this binding. If omitted, 'latest' MUST be assumed." + } + }, + "examples": [ + { + "query": { + "type": "object", + "required": [ + "companyId" + ], + "properties": { + "companyId": { + "type": "number", + "minimum": 1, + "description": "The Id of the company." + } + }, + "additionalProperties": false + }, + "bindingVersion": "0.3.0" + }, + { + "method": "GET", + "query": { + "type": "object", + "required": [ + "companyId" + ], + "properties": { + "companyId": { + "type": "number", + "minimum": 1, + "description": "The Id of the company." + } + }, + "additionalProperties": false + }, + "bindingVersion": "0.3.0" + } + ] + }, "bindings-amqp-0.3.0-operation": { "title": "AMQP operation bindings object", "description": "This object contains information about the operation representation in AMQP.", diff --git a/schemas/3.0.0.json b/schemas/3.0.0.json index 27ca6e78..a08d1408 100644 --- a/schemas/3.0.0.json +++ b/schemas/3.0.0.json @@ -3517,7 +3517,8 @@ "properties": { "bindingVersion": { "enum": [ - "0.2.0" + "0.2.0", + "0.3.0" ] } }, @@ -3549,6 +3550,21 @@ "then": { "$ref": "http://asyncapi.com/bindings/http/0.2.0/message.json" } + }, + { + "if": { + "required": [ + "bindingVersion" + ], + "properties": { + "bindingVersion": { + "const": "0.3.0" + } + } + }, + "then": { + "$ref": "http://asyncapi.com/bindings/http/0.3.0/message.json" + } } ] }, @@ -3892,6 +3908,51 @@ } ] }, + "http://asyncapi.com/bindings/http/0.3.0/message.json": { + "$id": "http://asyncapi.com/bindings/http/0.3.0/message.json", + "title": "HTTP message bindings object", + "description": "This object contains information about the message representation in HTTP.", + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" + } + }, + "properties": { + "headers": { + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json", + "description": "\tA Schema object containing the definitions for HTTP-specific headers. This schema MUST be of type 'object' and have a 'properties' key." + }, + "statusCode": { + "type": "number", + "description": "The HTTP response status code according to [RFC 9110](https://httpwg.org/specs/rfc9110.html#overview.of.status.codes). `statusCode` is only relevant for messages referenced by the [Operation Reply Object](https://www.asyncapi.com/docs/reference/specification/v3.0.0#operationReplyObject), as it defines the status code for the response. In all other cases, this value can be safely ignored." + }, + "bindingVersion": { + "type": "string", + "enum": [ + "0.3.0" + ], + "description": "The version of this binding. If omitted, \"latest\" MUST be assumed." + } + }, + "examples": [ + { + "headers": { + "type": "object", + "properties": { + "Content-Type": { + "type": "string", + "enum": [ + "application/json" + ] + } + } + }, + "bindingVersion": "0.3.0" + } + ] + }, "http://asyncapi.com/bindings/amqp/0.3.0/message.json": { "$id": "http://asyncapi.com/bindings/amqp/0.3.0/message.json", "title": "AMQP message bindings object", @@ -6492,7 +6553,8 @@ "properties": { "bindingVersion": { "enum": [ - "0.2.0" + "0.2.0", + "0.3.0" ] } }, @@ -6524,6 +6586,21 @@ "then": { "$ref": "http://asyncapi.com/bindings/http/0.2.0/operation.json" } + }, + { + "if": { + "required": [ + "bindingVersion" + ], + "properties": { + "bindingVersion": { + "const": "0.3.0" + } + } + }, + "then": { + "$ref": "http://asyncapi.com/bindings/http/0.3.0/operation.json" + } } ] }, @@ -6919,6 +6996,83 @@ } ] }, + "http://asyncapi.com/bindings/http/0.3.0/operation.json": { + "$id": "http://asyncapi.com/bindings/http/0.3.0/operation.json", + "title": "HTTP operation bindings object", + "description": "This object contains information about the operation representation in HTTP.", + "type": "object", + "additionalProperties": false, + "patternProperties": { + "^x-[\\w\\d\\.\\x2d_]+$": { + "$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json" + } + }, + "properties": { + "method": { + "type": "string", + "enum": [ + "GET", + "PUT", + "POST", + "PATCH", + "DELETE", + "HEAD", + "OPTIONS", + "CONNECT", + "TRACE" + ], + "description": "When 'type' is 'request', this is the HTTP method, otherwise it MUST be ignored. Its value MUST be one of 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS', 'CONNECT', and 'TRACE'." + }, + "query": { + "$ref": "http://asyncapi.com/definitions/3.0.0/schema.json", + "description": "A Schema object containing the definitions for each query parameter. This schema MUST be of type 'object' and have a properties key." + }, + "bindingVersion": { + "type": "string", + "enum": [ + "0.3.0" + ], + "description": "The version of this binding. If omitted, 'latest' MUST be assumed." + } + }, + "examples": [ + { + "query": { + "type": "object", + "required": [ + "companyId" + ], + "properties": { + "companyId": { + "type": "number", + "minimum": 1, + "description": "The Id of the company." + } + }, + "additionalProperties": false + }, + "bindingVersion": "0.3.0" + }, + { + "method": "GET", + "query": { + "type": "object", + "required": [ + "companyId" + ], + "properties": { + "companyId": { + "type": "number", + "minimum": 1, + "description": "The Id of the company." + } + }, + "additionalProperties": false + }, + "bindingVersion": "0.3.0" + } + ] + }, "http://asyncapi.com/bindings/amqp/0.3.0/operation.json": { "$id": "http://asyncapi.com/bindings/amqp/0.3.0/operation.json", "title": "AMQP operation bindings object", diff --git a/scripts/validate-schemas.js b/scripts/validate-schemas.js index 37dafbfd..729805eb 100644 --- a/scripts/validate-schemas.js +++ b/scripts/validate-schemas.js @@ -9,9 +9,10 @@ function validateSchema(filePath, fileContent, schemaValidator) { try { const obj = JSON.parse(fileContent); const validate = schemaValidator(obj); + const errors = validate ? [] : (obj.$schema === 'http://json-schema.org/draft-04/schema' && ajvDraft04.errors) || ajv.errors; - - return { filePath, validate, errors }; + + return { filePath, validate, errors } } catch (error) { return { filePath,