Skip to content

Commit

Permalink
fix: allow Reference objects in MultiFormat schema fields (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
smoya authored Jul 21, 2023
1 parent 5176b29 commit 18c49f7
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 15 deletions.
45 changes: 40 additions & 5 deletions definitions/3.0.0/multiFormatSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@
"then": {
"properties": {
"schema": {
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
"oneOf": [
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
}
]
}
}
}
Expand Down Expand Up @@ -77,7 +84,14 @@
"then": {
"properties": {
"schema": {
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
"oneOf": [
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
}
]
}
}
}
Expand All @@ -99,7 +113,14 @@
"then": {
"properties": {
"schema": {
"$ref": "http://json-schema.org/draft-07/schema"
"oneOf": [
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
},
{
"$ref": "http://json-schema.org/draft-07/schema"
}
]
}
}
}
Expand All @@ -122,7 +143,14 @@
"then": {
"properties": {
"schema": {
"$ref": "http://asyncapi.com/definitions/3.0.0/openapiSchema_3_0.json"
"oneOf": [
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/openapiSchema_3_0.json"
}
]
}
}
}
Expand All @@ -145,7 +173,14 @@
"then": {
"properties": {
"schema": {
"$ref": "http://asyncapi.com/definitions/3.0.0/avroSchema_v1.json"
"oneOf": [
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/avroSchema_v1.json"
}
]
}
}
}
Expand Down
45 changes: 40 additions & 5 deletions schemas/3.0.0-without-$id.json
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,14 @@
"then": {
"properties": {
"schema": {
"$ref": "#/definitions/schema"
"oneOf": [
{
"$ref": "#/definitions/Reference"
},
{
"$ref": "#/definitions/schema"
}
]
}
}
}
Expand Down Expand Up @@ -2221,7 +2228,14 @@
"then": {
"properties": {
"schema": {
"$ref": "#/definitions/schema"
"oneOf": [
{
"$ref": "#/definitions/Reference"
},
{
"$ref": "#/definitions/schema"
}
]
}
}
}
Expand All @@ -2243,7 +2257,14 @@
"then": {
"properties": {
"schema": {
"$ref": "#/definitions/json-schema-draft-07-schema"
"oneOf": [
{
"$ref": "#/definitions/Reference"
},
{
"$ref": "#/definitions/json-schema-draft-07-schema"
}
]
}
}
}
Expand All @@ -2266,7 +2287,14 @@
"then": {
"properties": {
"schema": {
"$ref": "#/definitions/openapiSchema_3_0"
"oneOf": [
{
"$ref": "#/definitions/Reference"
},
{
"$ref": "#/definitions/openapiSchema_3_0"
}
]
}
}
}
Expand All @@ -2289,7 +2317,14 @@
"then": {
"properties": {
"schema": {
"$ref": "#/definitions/avroSchema_v1"
"oneOf": [
{
"$ref": "#/definitions/Reference"
},
{
"$ref": "#/definitions/avroSchema_v1"
}
]
}
}
}
Expand Down
45 changes: 40 additions & 5 deletions schemas/3.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -2226,7 +2226,14 @@
"then": {
"properties": {
"schema": {
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
"oneOf": [
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
}
]
}
}
}
Expand Down Expand Up @@ -2270,7 +2277,14 @@
"then": {
"properties": {
"schema": {
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
"oneOf": [
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/schema.json"
}
]
}
}
}
Expand All @@ -2292,7 +2306,14 @@
"then": {
"properties": {
"schema": {
"$ref": "http://json-schema.org/draft-07/schema"
"oneOf": [
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
},
{
"$ref": "http://json-schema.org/draft-07/schema"
}
]
}
}
}
Expand All @@ -2315,7 +2336,14 @@
"then": {
"properties": {
"schema": {
"$ref": "http://asyncapi.com/definitions/3.0.0/openapiSchema_3_0.json"
"oneOf": [
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/openapiSchema_3_0.json"
}
]
}
}
}
Expand All @@ -2338,7 +2366,14 @@
"then": {
"properties": {
"schema": {
"$ref": "http://asyncapi.com/definitions/3.0.0/avroSchema_v1.json"
"oneOf": [
{
"$ref": "http://asyncapi.com/definitions/3.0.0/Reference.json"
},
{
"$ref": "http://asyncapi.com/definitions/3.0.0/avroSchema_v1.json"
}
]
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions test/docs/3.0.0/streetlights-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
}
}
}
},
"UserSignedUpV2": {
"payload": {
"$ref": "external-schema.json"
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions test/docs/3.0.0/streetlights-avro.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
"namespace": "com.example.avro",
"type": "record"
}
},
"ReferencedSchema" : {
"schemaFormat": "application/vnd.apache.avro;version=1.9.0",
"schema": {
"$ref": "reference-to-some-avro-file.avsc"
}
}
},
"messages": {
Expand Down
8 changes: 8 additions & 0 deletions test/docs/3.0.0/streetlights-openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@
}
},
"components": {
"schemas": {
"ReferencedSchema" : {
"schemaFormat": "application/vnd.oai.openapi;version=3.0.0",
"schema": {
"$ref": "reference-to-some-openapi-file.json"
}
}
},
"messages": {
"UserSignedUp": {
"payload": {
Expand Down

0 comments on commit 18c49f7

Please sign in to comment.