Skip to content

Commit 1f38dd3

Browse files
committed
Reorder type definitions to match spec and make diff easier
1 parent cce9b36 commit 1f38dd3

File tree

1 file changed

+68
-72
lines changed

1 file changed

+68
-72
lines changed

openapi-3-2/index.d.ts

Lines changed: 68 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,33 @@ type License = {
123123
url?: string;
124124
};
125125

126+
type Server = {
127+
url: string;
128+
description?: string;
129+
name?: string;
130+
variables?: Record<string, ServerVariable>;
131+
};
132+
126133
type ServerVariable = {
127134
enum?: string[];
128135
default: string;
129136
description?: string;
130137
};
131138

139+
type Components = {
140+
schemas?: Record<string, OasSchema32>;
141+
responses?: Record<string, Response | Reference>;
142+
parameters?: Record<string, Parameter | Reference>;
143+
examples?: Record<string, Example | Reference>;
144+
requestBodies?: Record<string, RequestBody | Reference>;
145+
headers?: Record<string, Header | Reference>;
146+
securitySchemes?: Record<string, SecurityScheme | Reference>;
147+
links?: Record<string, Link | Reference>;
148+
callbacks?: Record<string, Callbacks | Reference>;
149+
pathItems?: Record<string, PathItem>;
150+
mediaTypes?: Record<string, MediaType | Reference>;
151+
};
152+
132153
type PathItem = {
133154
$ref?: string;
134155
summary?: string;
@@ -162,7 +183,6 @@ type Operation = {
162183
servers?: Server[];
163184
};
164185

165-
// TODO: Needs improvement
166186
type Parameter = {
167187
name: string;
168188
in: "query" | "querystring" | "header" | "path" | "cookie";
@@ -178,27 +198,6 @@ type Parameter = {
178198
content: Record<string, MediaType | Reference>;
179199
});
180200

181-
// TODO: Needs improvement
182-
type Example = {
183-
summary?: string;
184-
description?: string;
185-
dataValue?: Json;
186-
serializedValue?: string;
187-
externalValue?: string;
188-
value?: Json;
189-
};
190-
191-
type Examples = {
192-
example?: Json;
193-
examples?: Record<string, Example | Reference>;
194-
};
195-
196-
type Reference = {
197-
$ref: string;
198-
summary?: string;
199-
description?: string;
200-
};
201-
202201
type RequestBody = {
203202
description?: string;
204203
content: Record<string, MediaType | Reference>;
@@ -213,7 +212,6 @@ type MediaType = {
213212
itemEncoding?: Encoding;
214213
} & Examples;
215214

216-
// TODO: Needs improvement
217215
type Encoding = {
218216
contentType?: string;
219217
headers?: Record<string, Header | Reference>;
@@ -225,18 +223,6 @@ type Encoding = {
225223
allowReserved?: boolean;
226224
};
227225

228-
type Header = {
229-
description?: string;
230-
required?: boolean;
231-
deprecated?: boolean;
232-
} & Examples & ({
233-
style?: "simple";
234-
explode?: boolean;
235-
schema: OasSchema32;
236-
} | {
237-
content: Record<string, MediaType | Reference>;
238-
});
239-
240226
type Responses = {
241227
default?: Response | Reference;
242228
} & Record<string, Response | Reference>;
@@ -251,44 +237,70 @@ type Response = {
251237

252238
type Callbacks = Record<string, PathItem | Reference>;
253239

254-
type SecurityRequirement = Record<string, string[]>;
240+
type Examples = {
241+
example?: Json;
242+
examples?: Record<string, Example | Reference>;
243+
};
255244

256-
type Server = {
257-
url: string;
245+
type Example = {
246+
summary?: string;
258247
description?: string;
259-
name?: string;
260-
variables?: Record<string, ServerVariable>;
248+
dataValue?: Json;
249+
serializedValue?: string;
250+
externalValue?: string;
251+
value?: Json;
261252
};
262253

263-
type Components = {
264-
schemas?: Record<string, OasSchema32>;
265-
responses?: Record<string, Response | Reference>;
266-
parameters?: Record<string, Parameter | Reference>;
267-
examples?: Record<string, Example | Reference>;
268-
requestBodies?: Record<string, RequestBody | Reference>;
269-
headers?: Record<string, Header | Reference>;
270-
securitySchemes?: Record<string, SecurityScheme | Reference>;
271-
links?: Record<string, Link | Reference>;
272-
callbacks?: Record<string, Callbacks | Reference>;
273-
pathItems?: Record<string, PathItem>;
274-
mediaTypes?: Record<string, MediaType | Reference>;
254+
type Link = {
255+
operationRef?: string;
256+
operationId?: string;
257+
parameters?: Record<string, string>;
258+
requestBody?: Json;
259+
description?: string;
260+
server?: Server;
261+
};
262+
263+
type Header = {
264+
description?: string;
265+
required?: boolean;
266+
deprecated?: boolean;
267+
} & Examples & ({
268+
style?: "simple";
269+
explode?: boolean;
270+
schema: OasSchema32;
271+
} | {
272+
content: Record<string, MediaType | Reference>;
273+
});
274+
275+
type Tag = {
276+
name: string;
277+
summary?: string;
278+
description?: string;
279+
externalDocs?: ExternalDocs;
280+
parent?: string;
281+
kind?: string;
282+
};
283+
284+
type Reference = {
285+
$ref: string;
286+
summary?: string;
287+
description?: string;
275288
};
276289

277-
// TODO: Needs improvement
278290
type SecurityScheme = {
279291
type: "apiKey" | "http" | "mutualTLS" | "oauth2" | "openIdConnect";
280292
description?: string;
281293
name?: string;
282294
in?: "query" | "header" | "cookie";
283295
scheme?: string;
284296
bearerFormat?: string;
285-
flows?: OAuthFlows;
297+
flows?: OauthFlows;
286298
openIdConnectUrl?: string;
287299
oauth2MetadataUrl?: string;
288300
deprecated?: boolean;
289301
};
290302

291-
type OAuthFlows = {
303+
type OauthFlows = {
292304
implicit?: Implicit;
293305
password?: Password;
294306
clientCredentials?: ClientCredentials;
@@ -328,22 +340,6 @@ type DeviceAuthorization = {
328340
scopes: Record<string, string>;
329341
};
330342

331-
type Link = {
332-
operationRef?: string;
333-
operationId?: string;
334-
parameters?: Record<string, string>;
335-
requestBody?: Json;
336-
description?: string;
337-
server?: Server;
338-
};
339-
340-
type Tag = {
341-
name: string;
342-
summary?: string;
343-
description?: string;
344-
externalDocs?: ExternalDocs;
345-
parent?: string;
346-
kind?: string;
347-
};
343+
type SecurityRequirement = Record<string, string[]>;
348344

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

0 commit comments

Comments
 (0)