Skip to content

Commit

Permalink
feat!: allow defining message schemaFormat at message level
Browse files Browse the repository at this point in the history
  • Loading branch information
smoya committed Mar 31, 2023
1 parent d3ea9c3 commit 148d087
Show file tree
Hide file tree
Showing 4 changed files with 1,473 additions and 1,436 deletions.
141 changes: 6 additions & 135 deletions definitions/3.0.0/messageObject.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
}
},
"properties": {
"schemaFormat": {
"type": "string"
},
"contentType": {
"type": "string"
},
Expand All @@ -30,7 +27,9 @@
"messageId": {
"type": "string"
},
"payload": {},
"payload": {
"$ref": "http://asyncapi.com/definitions/3.0.0/messagePayloadObject.json"
},
"correlationId": {
"oneOf": [
{
Expand Down Expand Up @@ -114,7 +113,9 @@
"headers": {
"type": "object"
},
"payload": {}
"payload": {
"$ref": "http://asyncapi.com/definitions/3.0.0/messagePayloadObject.json"
}
}
}
},
Expand Down Expand Up @@ -154,136 +155,6 @@
}
}
},
"allOf": [
{
"if": {
"not": {
"required": [
"schemaFormat"
]
}
},
"then": {
"properties": {
"payload": {
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
}
}
}
},
{
"if": {
"required": [
"schemaFormat"
],
"properties": {
"schemaFormat": {
"enum": [
"application/vnd.aai.asyncapi;version=2.0.0",
"application/vnd.aai.asyncapi+json;version=2.0.0",
"application/vnd.aai.asyncapi+yaml;version=2.0.0",
"application/vnd.aai.asyncapi;version=2.1.0",
"application/vnd.aai.asyncapi+json;version=2.1.0",
"application/vnd.aai.asyncapi+yaml;version=2.1.0",
"application/vnd.aai.asyncapi;version=2.2.0",
"application/vnd.aai.asyncapi+json;version=2.2.0",
"application/vnd.aai.asyncapi+yaml;version=2.2.0",
"application/vnd.aai.asyncapi;version=2.3.0",
"application/vnd.aai.asyncapi+json;version=2.3.0",
"application/vnd.aai.asyncapi+yaml;version=2.3.0",
"application/vnd.aai.asyncapi;version=2.4.0",
"application/vnd.aai.asyncapi+json;version=2.4.0",
"application/vnd.aai.asyncapi+yaml;version=2.4.0",
"application/vnd.aai.asyncapi;version=2.5.0",
"application/vnd.aai.asyncapi+json;version=2.5.0",
"application/vnd.aai.asyncapi+yaml;version=2.5.0",
"application/vnd.aai.asyncapi;version=2.6.0",
"application/vnd.aai.asyncapi+json;version=2.6.0",
"application/vnd.aai.asyncapi+yaml;version=2.6.0",
"application/vnd.aai.asyncapi;version=3.0.0",
"application/vnd.aai.asyncapi+json;version=3.0.0",
"application/vnd.aai.asyncapi+yaml;version=3.0.0"
]
}
}
},
"then": {
"properties": {
"payload": {
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
}
}
}
},
{
"if": {
"required": [
"schemaFormat"
],
"properties": {
"schemaFormat": {
"enum": [
"application/schema+json;version=draft-07",
"application/schema+yaml;version=draft-07"
]
}
}
},
"then": {
"properties": {
"payload": {
"$ref": "http://json-schema.org/draft-07/schema"
}
}
}
},
{
"if": {
"required": [
"schemaFormat"
],
"properties": {
"schemaFormat": {
"enum": [
"application/vnd.oai.openapi;version=3.0.0",
"application/vnd.oai.openapi+json;version=3.0.0",
"application/vnd.oai.openapi+yaml;version=3.0.0"
]
}
}
},
"then": {
"properties": {
"payload": {
"$ref": "http://asyncapi.com/definitions/3.0.0/openapiSchema_3_0.json"
}
}
}
},
{
"if": {
"required": [
"schemaFormat"
],
"properties": {
"schemaFormat": {
"enum": [
"application/vnd.apache.avro;version=1.9.0",
"application/vnd.apache.avro+json;version=1.9.0",
"application/vnd.apache.avro+yaml;version=1.9.0"
]
}
}
},
"then": {
"properties": {
"payload": {
"$ref": "http://asyncapi.com/definitions/3.0.0/avroSchema_v1.json"
}
}
}
}
],
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://asyncapi.com/definitions/3.0.0/messageObject.json"
}
147 changes: 147 additions & 0 deletions definitions/3.0.0/messagePayloadObject.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
{
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^x-[\\w\\d\\.\\x2d_]+$": {
"$ref": "http://asyncapi.com/definitions/3.0.0/specificationExtension.json"
}
},
"properties": {
"schemaFormat": {
"type": "string"
},
"schema": {}
},
"allOf": [
{
"if": {
"not": {
"required": [
"schemaFormat"
]
}
},
"then": {
"properties": {
"schema": {
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
}
}
}
},
{
"if": {
"required": [
"schemaFormat"
],
"properties": {
"schemaFormat": {
"enum": [
"application/vnd.aai.asyncapi;version=2.0.0",
"application/vnd.aai.asyncapi+json;version=2.0.0",
"application/vnd.aai.asyncapi+yaml;version=2.0.0",
"application/vnd.aai.asyncapi;version=2.1.0",
"application/vnd.aai.asyncapi+json;version=2.1.0",
"application/vnd.aai.asyncapi+yaml;version=2.1.0",
"application/vnd.aai.asyncapi;version=2.2.0",
"application/vnd.aai.asyncapi+json;version=2.2.0",
"application/vnd.aai.asyncapi+yaml;version=2.2.0",
"application/vnd.aai.asyncapi;version=2.3.0",
"application/vnd.aai.asyncapi+json;version=2.3.0",
"application/vnd.aai.asyncapi+yaml;version=2.3.0",
"application/vnd.aai.asyncapi;version=2.4.0",
"application/vnd.aai.asyncapi+json;version=2.4.0",
"application/vnd.aai.asyncapi+yaml;version=2.4.0",
"application/vnd.aai.asyncapi;version=2.5.0",
"application/vnd.aai.asyncapi+json;version=2.5.0",
"application/vnd.aai.asyncapi+yaml;version=2.5.0",
"application/vnd.aai.asyncapi;version=2.6.0",
"application/vnd.aai.asyncapi+json;version=2.6.0",
"application/vnd.aai.asyncapi+yaml;version=2.6.0",
"application/vnd.aai.asyncapi;version=3.0.0",
"application/vnd.aai.asyncapi+json;version=3.0.0",
"application/vnd.aai.asyncapi+yaml;version=3.0.0"
]
}
}
},
"then": {
"properties": {
"schema": {
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
}
}
}
},
{
"if": {
"required": [
"schemaFormat"
],
"properties": {
"schemaFormat": {
"enum": [
"application/schema+json;version=draft-07",
"application/schema+yaml;version=draft-07"
]
}
}
},
"then": {
"properties": {
"schema": {
"$ref": "http://json-schema.org/draft-07/schema"
}
}
}
},
{
"if": {
"required": [
"schemaFormat"
],
"properties": {
"schemaFormat": {
"enum": [
"application/vnd.oai.openapi;version=3.0.0",
"application/vnd.oai.openapi+json;version=3.0.0",
"application/vnd.oai.openapi+yaml;version=3.0.0"
]
}
}
},
"then": {
"properties": {
"schema": {
"$ref": "http://asyncapi.com/definitions/3.0.0/openapiSchema_3_0.json"
}
}
}
},
{
"if": {
"required": [
"schemaFormat"
],
"properties": {
"schemaFormat": {
"enum": [
"application/vnd.apache.avro;version=1.9.0",
"application/vnd.apache.avro+json;version=1.9.0",
"application/vnd.apache.avro+yaml;version=1.9.0"
]
}
}
},
"then": {
"properties": {
"schema": {
"$ref": "http://asyncapi.com/definitions/3.0.0/avroSchema_v1.json"
}
}
}
}
],
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://asyncapi.com/definitions/3.0.0/messagePayloadObject.json"
}
Loading

0 comments on commit 148d087

Please sign in to comment.