Skip to content

Commit e236f70

Browse files
mdrafi28jdesrosiers
authored andcommitted
changed schema.js and openapi type index.d.ts accordring to the requirements for the openApi issue
1 parent 98c6669 commit e236f70

16 files changed

+1752
-34
lines changed

README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,6 @@ YAML support isn't built in, but you can add it by writing a
156156
use the one at `lib/openapi.js` as an example and replace the JSON parts with
157157
YAML.
158158

159-
<!-- ## `package.json` Exports -->
160-
<!-- ```json
161-
"exports": {
162-
"./openapi-3-0": "./openapi-3-0/index.js",
163-
"./openapi-3-1": "./openapi-3-1/index.js",
164-
"./openapi-3-2": "./openapi-3-2/index.js"
165-
} -->
166-
167-
**`package.json` exports** — add:
168-
169-
```json
170-
"./openapi-3-2": "./openapi-3-2/index.js"
171-
172159
**Media types**
173160

174161
This library uses media types to determine how to parse a retrieved document. It

openapi-3-1/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ type Tag = {
259259
type Reference = {
260260
$ref: string;
261261
summary?: string;
262-
descriptions?: string;
262+
description?: string;
263263
};
264264

265265
type SecurityScheme = {
@@ -275,7 +275,7 @@ type SecurityScheme = {
275275

276276
type OauthFlows = {
277277
implicit: Implicit;
278-
Password: Password;
278+
password: Password;
279279
clientCredentials: ClientCredentials;
280280
authorizationCode: AuthorizationCode;
281281
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const runTestSuite = (draft: string, dialectId: string) => {
100100
} else {
101101
it(test.description, () => {
102102
const output = _validate(test.data);
103-
expect(output.valid).to.equal(test.valid);
103+
expect(output.valid).toBe(test.valid);
104104
});
105105
}
106106
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default {
2323
"dialect": { "const": "https://json-schema.org/draft/2019-09/schema" },
2424

2525
"schema": {
26-
"$dynamicanchor": "meta",
26+
"$dynamicAnchor": "meta",
2727
"$ref": "https://spec.openapis.org/oas/3.1/dialect/base",
2828
"properties": {
2929
"$schema": { "$ref": "#/$defs/dialect" }

openapi-3-1/schema-draft-2020-12.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default {
2323
"dialect": { "const": "https://json-schema.org/draft/2020-12/schema" },
2424

2525
"schema": {
26-
"$dynamicanchor": "meta",
26+
"$dynamicAnchor": "meta",
2727
"$ref": "https://spec.openapis.org/oas/3.1/dialect/base",
2828
"properties": {
2929
"$schema": { "$ref": "#/$defs/dialect" }

openapi-3-2/index.d.ts

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,77 @@ type Xml = {
8686
};
8787

8888
// TODO: Fill in this type when 3.2 is published
89-
export type OpenApi32 = unknown;
89+
export type OpenApi32 = {
90+
openapi: "3.2.0";
91+
info: {
92+
title: string;
93+
version: string;
94+
description?: string;
95+
termsOfService?: string;
96+
contact?: {
97+
name?: string;
98+
url?: string;
99+
email?: string;
100+
};
101+
license?: {
102+
name: string;
103+
url?: string;
104+
};
105+
};
106+
servers?: Array<{ url: string; description?: string }>;
107+
paths?: Record<string, PathItem32>;
108+
webhooks?: Record<string, PathItem32>; // <-- NEW in 3.2
109+
components?: Components32;
110+
security?: SecurityRequirement32[];
111+
tags?: Tag32[];
112+
externalDocs?: ExternalDocs32;
113+
};
114+
115+
export type PathItem32 = {
116+
summary?: string;
117+
description?: string;
118+
get?: Operation32;
119+
put?: Operation32;
120+
post?: Operation32;
121+
delete?: Operation32;
122+
options?: Operation32;
123+
head?: Operation32;
124+
patch?: Operation32;
125+
trace?: Operation32;
126+
servers?: Array<{ url: string; description?: string }>;
127+
parameters?: Parameter32[];
128+
};
129+
130+
export type Operation32 = {
131+
tags?: string[];
132+
summary?: string;
133+
description?: string;
134+
externalDocs?: ExternalDocs32;
135+
operationId?: string;
136+
parameters?: Parameter32[];
137+
requestBody?: RequestBody32;
138+
responses: Record<string, Response32>;
139+
callbacks?: Record<string, Callback32>;
140+
deprecated?: boolean;
141+
security?: SecurityRequirement32[];
142+
servers?: Array<{ url: string; description?: string }>;
143+
};
144+
145+
export type Components32 = {
146+
schemas?: Record<string, OasSchema32>;
147+
responses?: Record<string, Response32>;
148+
parameters?: Record<string, Parameter32>;
149+
examples?: Record<string, Example32>;
150+
requestBodies?: Record<string, RequestBody32>;
151+
headers?: Record<string, Header32>;
152+
securitySchemes?: Record<string, SecurityScheme32>;
153+
links?: Record<string, Link32>;
154+
callbacks?: Record<string, Callback32>;
155+
};
156+
157+
export type ExternalDocs32 = {
158+
description?: string;
159+
url: string;
160+
};
90161

91162
export * from "../lib/index.js";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const runTestSuite = (draft: string, dialectId: string) => {
100100
} else {
101101
it(test.description, () => {
102102
const output = _validate(test.data);
103-
expect(output.valid).to.equal(test.valid);
103+
expect(output.valid).toBe(test.valid);
104104
});
105105
}
106106
});

openapi-3-2/meta/base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default {
2525
"propertyName": {
2626
"type": "string"
2727
},
28-
"mapping": {
28+
"mappings": {
2929
"type": "object",
3030
"additionalProperties": {
3131
"type": "string"

openapi-3-2/schema-base.js

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

15-
"description": "The description of OpenAPI v3.2.x Documents using the OpenAPI JSON Schema dialect",
15+
"description": "The description of OpenAPI v3.2.x Documents using the OpenAPI JSON Schema Draft 2020-12 dialect",
1616

1717
"$ref": "https://spec.openapis.org/oas/3.2/schema",
1818
"properties": {
1919
"jsonSchemaDialect": { "$ref": "#/$defs/dialect" }
2020
},
2121

2222
"$defs": {
23-
"dialect": { "const": "https://spec.openapis.org/oas/3.2/dialect/base" },
23+
"dialect": { "const": "https://json-schema.org/draft/2020-12/schema" },
2424

2525
"schema": {
2626
"$dynamicAnchor": "meta",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ 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": "OpenAPI v3.2.x documents using draft-2020-12 JSON Schemas",
1616

1717
"$ref": "https://spec.openapis.org/oas/3.2/schema",
1818
"properties": {
1919
"jsonSchemaDialect": { "$ref": "#/$defs/dialect" }
2020
},
2121

2222
"$defs": {
23-
"dialect": { "const": "http://json-schema.org/draft-04/schema#" },
23+
"dialect": { "const": "http://json-schema.org/draft-2020-12/schema#" },
2424

2525
"schema": {
2626
"$dynamicAnchor": "meta",

0 commit comments

Comments
 (0)