Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: allow multi format schemas #370

Merged
merged 17 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions definitions/3.0.0/anySchema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"allOf": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is allOf needed here? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Removed!

{
"description": "If the property 'schema' is present, use the multi-format schema. Use the default AsyncAPI Schema otherwise.",
"if": {
"required": [
"schema"
]
},
"then": {
"$ref": "http://asyncapi.com/definitions/3.0.0/multiFormatSchema.json"
},
"else": {
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
}
}
],
"description": "An object representing either a schema or a multiFormatSchema based on the existence of the 'schema' property.",
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://asyncapi.com/definitions/3.0.0/anySchema.json"
}
2 changes: 1 addition & 1 deletion definitions/3.0.0/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
"$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json"
}
]
}
Expand Down
156 changes: 8 additions & 148 deletions definitions/3.0.0/messageObject.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,18 @@
}
},
"properties": {
"schemaFormat": {
"type": "string"
},
"contentType": {
"type": "string"
},
"headers": {
"allOf": [
{
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
},
{
"properties": {
"type": {
"const": "object"
}
}
}
]
"$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json"
},
"messageId": {
"type": "string"
},
"payload": {},
"payload": {
"$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json"
},
"correlationId": {
"oneOf": [
{
Expand Down Expand Up @@ -112,9 +100,11 @@
"description": "A brief summary of the message example."
},
"headers": {
"type": "object"
"$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json"
},
"payload": {}
"payload": {
"$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json"
}
}
}
},
Expand Down Expand Up @@ -154,136 +144,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"
}
16 changes: 1 addition & 15 deletions definitions/3.0.0/messageTrait.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,11 @@
}
},
"properties": {
"schemaFormat": {
"type": "string"
},
"contentType": {
"type": "string"
},
"headers": {
"allOf": [
{
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
},
{
"properties": {
"type": {
"const": "object"
}
}
}
]
"$ref": "http://asyncapi.com/definitions/3.0.0/anySchema.json"
},
"messageId": {
"type": "string"
Expand Down
Loading
Loading