Skip to content

Commit c01bfd8

Browse files
mdrafi28jdesrosiers
authored andcommitted
updated openapi 3.2 according to schema
1 parent 75e0a15 commit c01bfd8

File tree

1 file changed

+207
-34
lines changed

1 file changed

+207
-34
lines changed

openapi-3-2/index.d.ts

Lines changed: 207 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export type OasSchema32 = boolean | {
6969
type Discriminator = {
7070
propertyName: string;
7171
mappings?: Record<string, string>;
72+
defaultMapping?: string;
7273
};
7374

7475
type ExternalDocs = {
@@ -77,6 +78,7 @@ type ExternalDocs = {
7778
};
7879

7980
type Xml = {
81+
nodeType?: string;
8082
name?: string;
8183
namespace?: string;
8284
prefix?: string;
@@ -85,22 +87,10 @@ type Xml = {
8587
};
8688

8789
export type OpenApi = {
88-
openapi: "3.2.0";
89-
info: {
90-
title: string;
91-
version: string;
92-
description?: string;
93-
termsOfService?: string;
94-
contact?: {
95-
name?: string;
96-
url?: string;
97-
email?: string;
98-
};
99-
license?: {
100-
name: string;
101-
url?: string;
102-
};
103-
};
90+
openapi: string;
91+
$self?: string;
92+
info: Info;
93+
jsonSchemaDialect?: string;
10494
servers?: Server[];
10595
paths?: Record<string, PathItem>;
10696
webhooks?: Record<string, PathItem>;
@@ -110,7 +100,35 @@ export type OpenApi = {
110100
externalDocs?: ExternalDocs;
111101
};
112102

113-
export type PathItem = {
103+
type Info = {
104+
title: string;
105+
summary?: string;
106+
description?: string;
107+
termsOfService?: string;
108+
contact?: Contact;
109+
license?: License;
110+
version: string;
111+
}
112+
113+
type Contact = {
114+
name?: string;
115+
url?: string;
116+
email?: string;
117+
}
118+
119+
type License = {
120+
name: string;
121+
identifier?: string;
122+
url?: string;
123+
};
124+
125+
type ServerVariable = {
126+
enum?: string[];
127+
default: string;
128+
description?: string;
129+
}
130+
131+
type PathItem = {
114132
summary?: string;
115133
description?: string;
116134
get?: Operation;
@@ -121,40 +139,195 @@ export type PathItem = {
121139
head?: Operation;
122140
patch?: Operation;
123141
trace?: Operation;
142+
query?: Operation;
143+
additionOperations?: Record<string, Operation>;
124144
servers?: Server[];
125-
parameters?: Parameter[];
145+
parameters?: (Parameter | Reference)[];
126146
};
127147

128-
export type Operation = {
148+
type Operation = {
129149
tags?: string[];
130150
summary?: string;
131151
description?: string;
132152
externalDocs?: ExternalDocs;
133153
operationId?: string;
134-
parameters?: Parameter[];
135-
requestBody?: RequestBody;
136-
responses: Record<string, Response>;
137-
callbacks?: Record<string, Callback>;
154+
parameters?: (Parameter | Reference)[];
155+
requestBody?: RequestBody | Reference;
156+
responses: Responses;
157+
callbacks?: Record<string, Callbacks | Reference>;
138158
deprecated?: boolean;
139159
security?: SecurityRequirement[];
140160
servers?: Server[];
141161
};
142162

143-
export type Components = {
163+
type Parameter = {
164+
name: string;
165+
in: "query" | "querystring" | "header" | "path" | "cookie";
166+
description?: string;
167+
required?: boolean;
168+
deprecated?: boolean;
169+
allowEmptyValue?: boolean;
170+
example?: Json;
171+
examples?: Record<string, Example | Reference>;
172+
style?: string;
173+
explode?: boolean;
174+
allowReserved?: boolean;
175+
schema?: OasSchema32;
176+
content?: Record<string, MediaType | Reference>;
177+
}
178+
179+
type Example = {
180+
summary?: string;
181+
description?: string;
182+
dataValue?: Json;
183+
serializedValue?: string;
184+
externalValue?: string;
185+
value?: Json;
186+
}
187+
188+
type Reference = {
189+
$ref: string;
190+
summary?: string;
191+
description?: string;
192+
}
193+
194+
type RequestBody = {
195+
description?: string;
196+
content: Record<string, MediaType | Reference>;
197+
required?: boolean;
198+
}
199+
200+
type MediaType = {
201+
schema?: OasSchema32;
202+
itemSchema?: OasSchema32;
203+
example?: Json;
204+
examples?: Record<string, Example | Reference>;
205+
encoding?: Record<string, Encoding>;
206+
prefixEncoding?: Encoding[];
207+
itemEncoding?: Encoding;
208+
}
209+
210+
type Encoding = {
211+
contentType?: string;
212+
headers?: Record<string, Header | Reference>;
213+
encoding?: Record<string, Encoding>;
214+
prefixEncoding?: Encoding[];
215+
itemEncoding?: Encoding;
216+
style?: string;
217+
explode?: boolean;
218+
allowReserved?: boolean;
219+
}
220+
221+
type Header = {
222+
description?: string;
223+
required?: boolean;
224+
deprecated?: boolean;
225+
example?: Json;
226+
examples?: Record<string, Example | Reference>;
227+
style?: string;
228+
explode?: boolean;
229+
schema?: OasSchema32;
230+
content?: Record<string, MediaType | Reference>;
231+
}
232+
233+
type Responses = {
234+
default?: Response | Reference;
235+
} & Record<string, Response | Reference>;
236+
237+
type Callbacks = Record<string, PathItem | Reference>;
238+
239+
type SecurityRequirement = Record<string, string[]>;
240+
241+
type Server = {
242+
url: string;
243+
description?: string;
244+
name: string;
245+
variables?: Record<string, ServerVariable>;
246+
}
247+
248+
type Components = {
144249
schemas?: Record<string, OasSchema32>;
145-
responses?: Record<string, Response>;
146-
parameters?: Record<string, Parameter>;
147-
examples?: Record<string, Example>;
148-
requestBodies?: Record<string, RequestBody>;
149-
headers?: Record<string, Header>;
150-
securitySchemes?: Record<string, SecurityScheme>;
151-
links?: Record<string, Link>;
152-
callbacks?: Record<string, Callback>;
250+
responses?: Record<string, Response | Reference>;
251+
parameters?: Record<string, Parameter | Reference>;
252+
examples?: Record<string, Example | Reference>;
253+
requestBodies?: Record<string, RequestBody | Reference>;
254+
headers?: Record<string, Header | Reference>;
255+
securitySchemes?: Record<string, SecurityScheme | Reference>;
256+
links?: Record<string, Link | Reference>;
257+
callbacks?: Record<string, Callbacks | Reference>;
258+
pathItems?: Record<string, PathItem>;
259+
mediaTypes?: Record<string, MediaType | Reference>;
153260
};
154261

155-
export type ExternalDocs = {
262+
type SecurityScheme = {
263+
type: "apiKey" | "http" | "mutualTLS" | "oauth2" | "openIdConnect";
156264
description?: string;
157-
url: string;
265+
name?: string;
266+
in?: "query" | "header" | "cookie";
267+
scheme?: string;
268+
bearerFormat?: string;
269+
flows?: OAuthFlows;
270+
openIdConnectUrl?: string;
271+
oauth2MetadataUrl?: string;
272+
deprecated?: boolean;
273+
};
274+
275+
type OAuthFlows = {
276+
implicit?: Implicit;
277+
password?: Password;
278+
clientCredentials?: ClientCredentials;
279+
authorizationCode?: AuthorizationCode;
280+
deviceAuthorization?: DeviceAuthorization;
158281
};
159282

283+
type Implicit = {
284+
authorizationUrl: string;
285+
refreshUrl?: string;
286+
scopes: Record<string, string>;
287+
}
288+
289+
type Password = {
290+
tokenUrl: string;
291+
refreshUrl?: string;
292+
scopes: Record<string, string>;
293+
}
294+
295+
type ClientCredentials = {
296+
tokenUrl: string;
297+
refreshUrl?: string;
298+
scopes: Record<string, string>;
299+
}
300+
301+
type AuthorizationCode = {
302+
authorizationUrl: string;
303+
tokenUrl: string;
304+
refreshUrl?: string;
305+
scopes: Record<string, string>;
306+
}
307+
308+
type DeviceAuthorization = {
309+
deviceAuthorizationUrl: string;
310+
tokenUrl: string;
311+
refreshUrl?: string;
312+
scopes: Record<string, string>;
313+
}
314+
315+
type Link = {
316+
operationRef?: string;
317+
operationId?: string;
318+
parameters?: Record<string, string>;
319+
requestBody?: Json;
320+
description?: string;
321+
server?: Server;
322+
}
323+
324+
type Tag = {
325+
name: string;
326+
summary?: string;
327+
description?: string;
328+
externalDocs?: ExternalDocs;
329+
parent?: string;
330+
kind?: string;
331+
}
332+
160333
export * from "../lib/index.js";

0 commit comments

Comments
 (0)