Skip to content

Commit cce9b36

Browse files
committed
Some additional cleanup
1 parent 40edee7 commit cce9b36

File tree

12 files changed

+83
-46
lines changed

12 files changed

+83
-46
lines changed

openapi-3-2/dialect/base.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ export default {
1313
"$dynamicAnchor": "meta",
1414

1515
"title": "OpenAPI 3.2 Schema Object Dialect",
16-
"description": "A JSON Schema dialect describing schemas found in OpenAPI v3.2 Descriptions",
16+
"description": "A JSON Schema dialect describing schemas found in OpenAPI v3.2.x Descriptions",
1717

1818
"allOf": [
1919
{ "$ref": "https://json-schema.org/draft/2020-12/schema" },
20-
{ "$ref": "https://spec.openapis.org/oas/3.2/meta/base" }
20+
{ "$ref": "https://spec.openapis.org/oas/3.2/meta" }
2121
]
2222
};

openapi-3-2/index.d.ts

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ type ExternalDocs = {
7979
};
8080

8181
type Xml = {
82-
nodeType?: string;
82+
nodeType?: "element" | "attribute" | "text" | "cdata" | "none";
8383
name?: string;
8484
namespace?: string;
8585
prefix?: string;
@@ -130,6 +130,7 @@ type ServerVariable = {
130130
};
131131

132132
type PathItem = {
133+
$ref?: string;
133134
summary?: string;
134135
description?: string;
135136
get?: Operation;
@@ -154,29 +155,30 @@ type Operation = {
154155
operationId?: string;
155156
parameters?: (Parameter | Reference)[];
156157
requestBody?: RequestBody | Reference;
157-
responses: Responses;
158+
responses?: Responses;
158159
callbacks?: Record<string, Callbacks | Reference>;
159160
deprecated?: boolean;
160161
security?: SecurityRequirement[];
161162
servers?: Server[];
162163
};
163164

165+
// TODO: Needs improvement
164166
type Parameter = {
165167
name: string;
166168
in: "query" | "querystring" | "header" | "path" | "cookie";
167169
description?: string;
168170
required?: boolean;
169171
deprecated?: boolean;
170172
allowEmptyValue?: boolean;
171-
example?: Json;
172-
examples?: Record<string, Example | Reference>;
173-
style?: string;
173+
} & Examples & ({
174+
style?: "matrix" | "label" | "form" | "simple" | "spaceDelimited" | "pipeDelimited" | "deepObject";
174175
explode?: boolean;
175-
allowReserved?: boolean;
176-
schema?: OasSchema32;
177-
content?: Record<string, MediaType | Reference>;
178-
};
176+
schema: OasSchema32;
177+
} | {
178+
content: Record<string, MediaType | Reference>;
179+
});
179180

181+
// TODO: Needs improvement
180182
type Example = {
181183
summary?: string;
182184
description?: string;
@@ -186,6 +188,11 @@ type Example = {
186188
value?: Json;
187189
};
188190

191+
type Examples = {
192+
example?: Json;
193+
examples?: Record<string, Example | Reference>;
194+
};
195+
189196
type Reference = {
190197
$ref: string;
191198
summary?: string;
@@ -201,20 +208,19 @@ type RequestBody = {
201208
type MediaType = {
202209
schema?: OasSchema32;
203210
itemSchema?: OasSchema32;
204-
example?: Json;
205-
examples?: Record<string, Example | Reference>;
206211
encoding?: Record<string, Encoding>;
207212
prefixEncoding?: Encoding[];
208213
itemEncoding?: Encoding;
209-
};
214+
} & Examples;
210215

216+
// TODO: Needs improvement
211217
type Encoding = {
212218
contentType?: string;
213219
headers?: Record<string, Header | Reference>;
214220
encoding?: Record<string, Encoding>;
215221
prefixEncoding?: Encoding[];
216222
itemEncoding?: Encoding;
217-
style?: string;
223+
style?: "form" | "spaceDelimited" | "pipeDelimited" | "deepObject";
218224
explode?: boolean;
219225
allowReserved?: boolean;
220226
};
@@ -223,26 +229,34 @@ type Header = {
223229
description?: string;
224230
required?: boolean;
225231
deprecated?: boolean;
226-
example?: Json;
227-
examples?: Record<string, Example | Reference>;
228-
style?: string;
232+
} & Examples & ({
233+
style?: "simple";
229234
explode?: boolean;
230-
schema?: OasSchema32;
231-
content?: Record<string, MediaType | Reference>;
232-
};
235+
schema: OasSchema32;
236+
} | {
237+
content: Record<string, MediaType | Reference>;
238+
});
233239

234240
type Responses = {
235241
default?: Response | Reference;
236242
} & Record<string, Response | Reference>;
237243

244+
type Response = {
245+
summary?: string;
246+
description?: string;
247+
headers?: Record<string, Header | Reference>;
248+
content?: Record<string, MediaType | Reference>;
249+
links?: Record<string, Link | Reference>;
250+
};
251+
238252
type Callbacks = Record<string, PathItem | Reference>;
239253

240254
type SecurityRequirement = Record<string, string[]>;
241255

242256
type Server = {
243257
url: string;
244258
description?: string;
245-
name: string;
259+
name?: string;
246260
variables?: Record<string, ServerVariable>;
247261
};
248262

@@ -260,6 +274,7 @@ type Components = {
260274
mediaTypes?: Record<string, MediaType | Reference>;
261275
};
262276

277+
// TODO: Needs improvement
263278
type SecurityScheme = {
264279
type: "apiKey" | "http" | "mutualTLS" | "oauth2" | "openIdConnect";
265280
description?: string;

openapi-3-2/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ defineVocabulary("https://spec.openapis.org/oas/3.2/vocab/base", {
3232
"xml": "https://spec.openapis.org/oas/3.0/keyword/xml"
3333
});
3434

35-
registerSchema(vocabularySchema, "https://spec.openapis.org/oas/3.2/meta/base");
36-
registerSchema(dialectSchema, "https://spec.openapis.org/oas/3.2/dialect/base");
35+
registerSchema(vocabularySchema, "https://spec.openapis.org/oas/3.2/meta");
36+
registerSchema(dialectSchema, "https://spec.openapis.org/oas/3.2/dialect");
3737

3838
// Current Schemas
3939
registerSchema(schema, "https://spec.openapis.org/oas/3.2/schema");
40-
registerSchema(schema, "https://spec.openapis.org/oas/3.2/schema/latest");
4140
registerSchema(schemaBase, "https://spec.openapis.org/oas/3.2/schema-base");
42-
registerSchema(schemaBase, "https://spec.openapis.org/oas/3.2/schema-base/latest");
4341

4442
// Alternative dialect schemas
4543
registerSchema(schemaDraft2020, "https://spec.openapis.org/oas/3.2/schema-draft-2020-12");

openapi-3-2/json-schema-test-suite.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@ const runTestSuite = (draft: string, dialectId: string) => {
111111
});
112112
};
113113

114-
runTestSuite("draft2020-12", "https://spec.openapis.org/oas/3.2/dialect/base");
114+
runTestSuite("draft2020-12", "https://spec.openapis.org/oas/3.2/dialect");

openapi-3-2/meta/base.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,23 @@ export default {
33
"$dynamicAnchor": "meta",
44

55
"title": "OAS Base Vocabulary",
6-
"description": "A JSON Schema Vocabulary used in the OpenAPI Schema Dialect",
6+
"description": "A JSON Schema Vocabulary used in the OpenAPI JSON Schema Dialect",
77

88
"type": ["object", "boolean"],
99
"properties": {
10-
"example": true,
1110
"discriminator": { "$ref": "#/$defs/discriminator" },
11+
"example": { "deprecated": true },
1212
"externalDocs": { "$ref": "#/$defs/external-docs" },
1313
"xml": { "$ref": "#/$defs/xml" }
1414
},
15+
1516
"$defs": {
1617
"extensible": {
1718
"patternProperties": {
1819
"^x-": true
1920
}
2021
},
22+
2123
"discriminator": {
2224
"$ref": "#/$defs/extensible",
2325
"type": "object",
@@ -30,6 +32,9 @@ export default {
3032
"additionalProperties": {
3133
"type": "string"
3234
}
35+
},
36+
"defaultMapping": {
37+
"type": "string"
3338
}
3439
},
3540
"required": ["propertyName"],
@@ -54,21 +59,41 @@ export default {
5459
"$ref": "#/$defs/extensible",
5560
"type": "object",
5661
"properties": {
62+
"nodeType": {
63+
"type": "string",
64+
"enum": [
65+
"element",
66+
"attribute",
67+
"text",
68+
"cdata",
69+
"none"
70+
]
71+
},
5772
"name": {
5873
"type": "string"
5974
},
6075
"namespace": {
6176
"type": "string",
62-
"format": "uri"
77+
"format": "iri"
6378
},
6479
"prefix": {
6580
"type": "string"
6681
},
6782
"attribute": {
68-
"type": "boolean"
83+
"type": "boolean",
84+
"deprecated": true
6985
},
7086
"wrapped": {
71-
"type": "boolean"
87+
"type": "boolean",
88+
"deprecated": true
89+
}
90+
},
91+
"dependentSchemas": {
92+
"nodeType": {
93+
"properties": {
94+
"attribute": false,
95+
"wrapped": false
96+
}
7297
}
7398
},
7499
"unevaluatedProperties": false

openapi-3-2/schema-base.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ export default {
2020
},
2121

2222
"$defs": {
23-
"dialect": { "const": "https://spec.openapis.org/oas/3.2/dialect/base" },
24-
23+
"dialect": { "const": "https://spec.openapis.org/oas/3.2/dialect" },
2524
"schema": {
2625
"$dynamicAnchor": "meta",
27-
"$ref": "https://spec.openapis.org/oas/3.2/dialect/base",
26+
"$ref": "https://spec.openapis.org/oas/3.2/dialect",
2827
"properties": {
2928
"$schema": { "$ref": "#/$defs/dialect" }
3029
}

openapi-3-2/schema-draft-04.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
"https://spec.openapis.org/oas/3.2/vocab/base": false
1313
},
1414

15-
"description": "OpenAPI v3.2.x documents using draft-04 JSON Schemas",
15+
"description": "The description of OpenAPI v3.2.x Documents using the draft-04 JSON Schema dialect",
1616

1717
"$ref": "https://spec.openapis.org/oas/3.2/schema",
1818
"properties": {
@@ -24,7 +24,7 @@ export default {
2424

2525
"schema": {
2626
"$dynamicAnchor": "meta",
27-
"$ref": "https://spec.openapis.org/oas/3.2/dialect/base",
27+
"$ref": "https://spec.openapis.org/oas/3.2/dialect",
2828
"properties": {
2929
"$schema": { "$ref": "#/$defs/dialect" }
3030
}

openapi-3-2/schema-draft-06.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
"https://spec.openapis.org/oas/3.2/vocab/base": false
1313
},
1414

15-
"description": "OpenAPI v3.2.x documents using draft-06 JSON Schemas",
15+
"description": "The description of OpenAPI v3.2.x Documents using the draft-06 JSON Schema dialect",
1616

1717
"$ref": "https://spec.openapis.org/oas/3.2/schema",
1818
"properties": {
@@ -24,7 +24,7 @@ export default {
2424

2525
"schema": {
2626
"$dynamicAnchor": "meta",
27-
"$ref": "https://spec.openapis.org/oas/3.2/dialect/base",
27+
"$ref": "https://spec.openapis.org/oas/3.2/dialect",
2828
"properties": {
2929
"$schema": { "$ref": "#/$defs/dialect" }
3030
}

openapi-3-2/schema-draft-07.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
"https://spec.openapis.org/oas/3.2/vocab/base": false
1313
},
1414

15-
"description": "OpenAPI v3.2.x documents using draft-07 JSON Schemas",
15+
"description": "The description of OpenAPI v3.2.x Documents using the draft-07 JSON Schema dialect",
1616

1717
"$ref": "https://spec.openapis.org/oas/3.2/schema",
1818
"properties": {
@@ -24,7 +24,7 @@ export default {
2424

2525
"schema": {
2626
"$dynamicAnchor": "meta",
27-
"$ref": "https://spec.openapis.org/oas/3.2/dialect/base",
27+
"$ref": "https://spec.openapis.org/oas/3.2/dialect",
2828
"properties": {
2929
"$schema": { "$ref": "#/$defs/dialect" }
3030
}

openapi-3-2/schema-draft-2019-09.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
"https://spec.openapis.org/oas/3.2/vocab/base": false
1313
},
1414

15-
"description": "openapi v3.2.x documents using 2019-09 json schemas",
15+
"description": "The description of OpenAPI v3.2.x Documents using the 2019-09 JSON Schema dialect",
1616

1717
"$ref": "https://spec.openapis.org/oas/3.2/schema",
1818
"properties": {
@@ -24,7 +24,7 @@ export default {
2424

2525
"schema": {
2626
"$dynamicAnchor": "meta",
27-
"$ref": "https://spec.openapis.org/oas/3.2/dialect/base",
27+
"$ref": "https://spec.openapis.org/oas/3.2/dialect",
2828
"properties": {
2929
"$schema": { "$ref": "#/$defs/dialect" }
3030
}

0 commit comments

Comments
 (0)