Skip to content

Commit ecc6ef3

Browse files
authored
v3.1 Schema bugfix: Update URI fields to use uri-reference or uri where appropriate (#2586)
* Fix typo in v3.1 schema tests * Remove v3.1 schema test for server variable JSON Schema can't express this constraint * v3.1 Schema fix. $ref should be a uri-reference
1 parent cc45c37 commit ecc6ef3

File tree

7 files changed

+39
-43
lines changed

7 files changed

+39
-43
lines changed

schemas/v3.1/schema-base.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"$id": "https://spec.openapis.org/oas/3.1/schema-base/2021-04-15",
2+
"$id": "https://spec.openapis.org/oas/3.1/schema-base/2021-05-20",
33
"$schema": "https://json-schema.org/draft/2020-12/schema",
4-
"$ref": "https://spec.openapis.org/oas/3.1/schema/2021-04-15",
4+
"$ref": "https://spec.openapis.org/oas/3.1/schema/2021-05-20",
55
"properties": {
66
"jsonSchemaDialect": {
77
"$ref": "#/$defs/dialect"

schemas/v3.1/schema-base.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
$id: 'https://spec.openapis.org/oas/3.1/schema-base/2021-04-15'
1+
$id: 'https://spec.openapis.org/oas/3.1/schema-base/2021-05-20'
22
$schema: 'https://json-schema.org/draft/2020-12/schema'
33

4-
$ref: 'https://spec.openapis.org/oas/3.1/schema/2021-04-15'
4+
$ref: 'https://spec.openapis.org/oas/3.1/schema/2021-05-20'
55
properties:
66
jsonSchemaDialect:
77
$ref: '#/$defs/dialect'

schemas/v3.1/schema.json

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$id": "https://spec.openapis.org/oas/3.1/schema/2021-04-15",
2+
"$id": "https://spec.openapis.org/oas/3.1/schema/2021-05-20",
33
"$schema": "https://json-schema.org/draft/2020-12/schema",
44
"type": "object",
55
"properties": {
@@ -11,7 +11,8 @@
1111
"$ref": "#/$defs/info"
1212
},
1313
"jsonSchemaDialect": {
14-
"$ref": "#/$defs/uri",
14+
"type": "string",
15+
"format": "uri",
1516
"default": "https://spec.openapis.org/oas/3.1/dialect/base"
1617
},
1718
"servers": {
@@ -130,7 +131,8 @@
130131
"type": "string"
131132
},
132133
"url": {
133-
"$ref": "#/$defs/uri"
134+
"type": "string",
135+
"format": "uri"
134136
}
135137
},
136138
"required": [
@@ -155,7 +157,8 @@
155157
"type": "object",
156158
"properties": {
157159
"url": {
158-
"$ref": "#/$defs/uri"
160+
"type": "string",
161+
"format": "uri-reference"
159162
},
160163
"description": {
161164
"type": "string"
@@ -390,7 +393,8 @@
390393
"type": "string"
391394
},
392395
"url": {
393-
"$ref": "#/$defs/uri"
396+
"type": "string",
397+
"format": "uri"
394398
}
395399
},
396400
"required": [
@@ -849,7 +853,8 @@
849853
},
850854
"value": true,
851855
"externalValue": {
852-
"$ref": "#/$defs/uri"
856+
"type": "string",
857+
"format": "uri"
853858
}
854859
},
855860
"$ref": "#/$defs/specification-extensions",
@@ -872,7 +877,8 @@
872877
"type": "object",
873878
"properties": {
874879
"operationRef": {
875-
"$ref": "#/$defs/uri"
880+
"type": "string",
881+
"format": "uri-reference"
876882
},
877883
"operationId": true,
878884
"parameters": {
@@ -1003,7 +1009,8 @@
10031009
"type": "object",
10041010
"properties": {
10051011
"$ref": {
1006-
"$ref": "#/$defs/uri"
1012+
"type": "string",
1013+
"format": "uri-reference"
10071014
},
10081015
"summary": {
10091016
"type": "string"
@@ -1176,7 +1183,8 @@
11761183
"then": {
11771184
"properties": {
11781185
"openIdConnectUrl": {
1179-
"$ref": "#/$defs/uri"
1186+
"type": "string",
1187+
"format": "uri"
11801188
}
11811189
},
11821190
"required": [
@@ -1329,10 +1337,6 @@
13291337
}
13301338
}
13311339
},
1332-
"uri": {
1333-
"type": "string",
1334-
"format": "uri"
1335-
},
13361340
"map-of-strings": {
13371341
"type": "object",
13381342
"additionalProperties": {

schemas/v3.1/schema.yaml

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$id: 'https://spec.openapis.org/oas/3.1/schema/2021-04-15'
1+
$id: 'https://spec.openapis.org/oas/3.1/schema/2021-05-20'
22
$schema: 'https://json-schema.org/draft/2020-12/schema'
33

44
type: object
@@ -9,7 +9,8 @@ properties:
99
info:
1010
$ref: '#/$defs/info'
1111
jsonSchemaDialect:
12-
$ref: '#/$defs/uri'
12+
type: string
13+
format: uri
1314
default: 'https://spec.openapis.org/oas/3.1/dialect/base'
1415
servers:
1516
type: array
@@ -90,7 +91,8 @@ $defs:
9091
identifier:
9192
type: string
9293
url:
93-
$ref: '#/$defs/uri'
94+
type: string
95+
format: uri
9496
required:
9597
- name
9698
oneOf:
@@ -105,7 +107,8 @@ $defs:
105107
type: object
106108
properties:
107109
url:
108-
$ref: '#/$defs/uri'
110+
type: string
111+
format: uri-reference
109112
description:
110113
type: string
111114
variables:
@@ -270,7 +273,8 @@ $defs:
270273
description:
271274
type: string
272275
url:
273-
$ref: '#/$defs/uri'
276+
type: string
277+
format: uri
274278
required:
275279
- url
276280
$ref: '#/$defs/specification-extensions'
@@ -574,7 +578,8 @@ $defs:
574578
type: string
575579
value: true
576580
externalValue:
577-
$ref: '#/$defs/uri'
581+
type: string
582+
format: uri
578583
$ref: '#/$defs/specification-extensions'
579584
unevaluatedProperties: false
580585

@@ -591,7 +596,8 @@ $defs:
591596
type: object
592597
properties:
593598
operationRef:
594-
$ref: '#/$defs/uri'
599+
type: string
600+
format: uri-reference
595601
operationId: true
596602
parameters:
597603
$ref: '#/$defs/map-of-strings'
@@ -681,7 +687,8 @@ $defs:
681687
type: object
682688
properties:
683689
$ref:
684-
$ref: '#/$defs/uri'
690+
type: string
691+
format: uri-reference
685692
summary:
686693
type: string
687694
description:
@@ -793,7 +800,8 @@ $defs:
793800
then:
794801
properties:
795802
openIdConnectUrl:
796-
$ref: '#/$defs/uri'
803+
type: string
804+
format: uri
797805
required:
798806
- openIdConnectUrl
799807

@@ -903,10 +911,6 @@ $defs:
903911
additionalProperties:
904912
$ref: '#/$defs/example-or-reference'
905913

906-
uri:
907-
type: string
908-
format: uri
909-
910914
map-of-strings:
911915
type: object
912916
additionalProperties:

tests/v3.1/fail/sever_enum_unknown.yaml

-12
This file was deleted.

tests/v3.1/test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ before(async () => {
1414
JsonSchema.add(dialect);
1515
JsonSchema.add(vocabulary);
1616
JsonSchema.add(yaml.parse(fs.readFileSync(`${__dirname}/../../schemas/v3.1/schema.yaml`, "utf8"), { prettyErrors: true }));
17-
metaSchema = await JsonSchema.get("https://spec.openapis.org/oas/3.1/schema/2021-03-02");
17+
metaSchema = await JsonSchema.get("https://spec.openapis.org/oas/3.1/schema/2021-05-20");
1818
});
1919

2020
describe("Pass", () => {

0 commit comments

Comments
 (0)