@backstage/backend-openapi-utils 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +6 -0
- package/dist/index.d.ts +79 -41
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @backstage/backend-openapi-utils
|
|
2
2
|
|
|
3
|
+
## 0.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7c83975531: Adds new public utility types for common OpenAPI values, like request and response shapes and parameters available on an endpoint.
|
|
8
|
+
|
|
9
|
+
**deprecated** `internal` namespace
|
|
10
|
+
The internal namespace will continue to be exported but now uses OpenAPI format for path parameters. You should use the new utility types.
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- @backstage/errors@1.2.3
|
|
14
|
+
|
|
15
|
+
## 0.0.5-next.0
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 7c83975531: Adds new public utility types for common OpenAPI values, like request and response shapes and parameters available on an endpoint.
|
|
20
|
+
|
|
21
|
+
**deprecated** `internal` namespace
|
|
22
|
+
The internal namespace will continue to be exported but now uses OpenAPI format for path parameters. You should use the new utility types.
|
|
23
|
+
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
- @backstage/errors@1.2.3-next.0
|
|
26
|
+
|
|
3
27
|
## 0.0.4
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -61,6 +61,12 @@ export function createRouter() {
|
|
|
61
61
|
}
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
## FAQs
|
|
65
|
+
|
|
66
|
+
### Why am I getting `unknown` as the type for a response?
|
|
67
|
+
|
|
68
|
+
This can happen when you have a `charset` defined in your `response.content` section. Something like `response.content[ 'application/json; charset=utf-8:']` will cause this issue.
|
|
69
|
+
|
|
64
70
|
## INTERNAL
|
|
65
71
|
|
|
66
72
|
### Limitations
|
package/dist/index.d.ts
CHANGED
|
@@ -114,6 +114,12 @@ type PathDoc = Pick<ImmutableOpenAPIObject, 'paths'>;
|
|
|
114
114
|
* @public
|
|
115
115
|
*/
|
|
116
116
|
type ValueOf<T> = T[keyof T];
|
|
117
|
+
/**
|
|
118
|
+
* All paths for a given doc,
|
|
119
|
+
* @example `/pet/{petId}` | `/pet`
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
type DocPath<Doc extends PathDoc> = Extract<keyof Doc['paths'], string>;
|
|
117
123
|
/**
|
|
118
124
|
* Validate a string against OpenAPI path template, {@link https://spec.openapis.org/oas/v3.1.0#path-templating-matching}.
|
|
119
125
|
*
|
|
@@ -142,27 +148,31 @@ type PathTemplate<Path extends string> = Path extends `${infer Prefix}{${infer P
|
|
|
142
148
|
*
|
|
143
149
|
* @public
|
|
144
150
|
*/
|
|
145
|
-
type
|
|
146
|
-
[Template in
|
|
151
|
+
type TemplateToDocPath<Doc extends PathDoc, Path extends DocPathTemplate<Doc>> = ValueOf<{
|
|
152
|
+
[Template in DocPath<Doc>]: Path extends PathTemplate<Template> ? Template : never;
|
|
147
153
|
}>;
|
|
148
154
|
/**
|
|
149
155
|
* @public
|
|
150
156
|
*/
|
|
151
|
-
type DocPathTemplate<Doc extends PathDoc> = PathTemplate<
|
|
157
|
+
type DocPathTemplate<Doc extends PathDoc> = PathTemplate<DocPath<Doc>>;
|
|
152
158
|
/**
|
|
153
159
|
* @public
|
|
154
160
|
*/
|
|
155
|
-
type DocPathMethod<Doc extends Pick<RequiredDoc, 'paths'>, Path extends
|
|
161
|
+
type DocPathMethod<Doc extends Pick<RequiredDoc, 'paths'>, Path extends DocPath<Doc>> = keyof Doc['paths'][Path];
|
|
156
162
|
/**
|
|
157
163
|
* @public
|
|
158
164
|
*/
|
|
159
|
-
type
|
|
160
|
-
|
|
165
|
+
type DocPathTemplateMethod<Doc extends Pick<RequiredDoc, 'paths'>, Path extends DocPathTemplate<Doc>> = keyof Doc['paths'][TemplateToDocPath<Doc, Path>];
|
|
166
|
+
/**
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
type MethodAwareDocPath<Doc extends PathDoc, Path extends DocPathTemplate<Doc>, Method extends DocPathTemplateMethod<Doc, Path>> = ValueOf<{
|
|
170
|
+
[Template in DocPath<Doc>]: Path extends PathTemplate<Template> ? Method extends DocPathTemplateMethod<Doc, Path> ? PathTemplate<Template> : never : never;
|
|
161
171
|
}>;
|
|
162
172
|
/**
|
|
163
173
|
* @public
|
|
164
174
|
*/
|
|
165
|
-
type DocOperation<Doc extends RequiredDoc, Path extends
|
|
175
|
+
type DocOperation<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends keyof Doc['paths'][Path]> = Doc['paths'][Path][Method];
|
|
166
176
|
/**
|
|
167
177
|
* @public
|
|
168
178
|
*/
|
|
@@ -278,7 +288,7 @@ type Filter<T, U> = T extends U ? T : never;
|
|
|
278
288
|
/**
|
|
279
289
|
* @public
|
|
280
290
|
*/
|
|
281
|
-
type DocParameter<Doc extends RequiredDoc, Path extends
|
|
291
|
+
type DocParameter<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>, Parameter extends keyof DocOperation<Doc, Path, Method>['parameters']> = DocOperation<Doc, Path, Method>['parameters'][Parameter] extends ImmutableReferenceObject ? 'parameters' extends ComponentTypes<Doc> ? ComponentRef<Doc, 'parameters', DocOperation<Doc, Path, Method>['parameters'][Parameter]> : never : DocOperation<Doc, Path, Method>['parameters'][Parameter];
|
|
282
292
|
/**
|
|
283
293
|
* Helper to convert from string to number, used to index arrays and pull out just the indices in the array.
|
|
284
294
|
* @public
|
|
@@ -307,19 +317,19 @@ type ParametersSchema<Doc extends RequiredDoc, Path extends Extract<keyof Doc['p
|
|
|
307
317
|
/**
|
|
308
318
|
* @public
|
|
309
319
|
*/
|
|
310
|
-
type HeaderSchema<Doc extends RequiredDoc, Path extends
|
|
320
|
+
type HeaderSchema<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = ParametersSchema<Doc, Path, Method, ImmutableHeaderObject>;
|
|
311
321
|
/**
|
|
312
322
|
* @public
|
|
313
323
|
*/
|
|
314
|
-
type CookieSchema<Doc extends RequiredDoc, Path extends
|
|
324
|
+
type CookieSchema<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = ParametersSchema<Doc, Path, Method, ImmutableCookieObject>;
|
|
315
325
|
/**
|
|
316
326
|
* @public
|
|
317
327
|
*/
|
|
318
|
-
type PathSchema<Doc extends RequiredDoc, Path extends
|
|
328
|
+
type PathSchema<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = ParametersSchema<Doc, Path, Method, ImmutablePathObject>;
|
|
319
329
|
/**
|
|
320
330
|
* @public
|
|
321
331
|
*/
|
|
322
|
-
type QuerySchema<Doc extends RequiredDoc, Path extends
|
|
332
|
+
type QuerySchema<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = ParametersSchema<Doc, Path, Method, ImmutableQueryObject>;
|
|
323
333
|
|
|
324
334
|
/**
|
|
325
335
|
* Pulled from https://github.com/varanauskas/oatx.
|
|
@@ -332,12 +342,12 @@ type RequestBody<Doc extends RequiredDoc, Path extends Extract<keyof Doc['paths'
|
|
|
332
342
|
/**
|
|
333
343
|
* @public
|
|
334
344
|
*/
|
|
335
|
-
type RequestBodySchema<Doc extends RequiredDoc, Path extends
|
|
345
|
+
type RequestBodySchema<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = RequestBody<Doc, Path, Method> extends ImmutableRequestBodyObject ? ObjectWithContentSchema<Doc, RequestBody<Doc, Path, Method>> : never;
|
|
336
346
|
/**
|
|
337
347
|
* Transform the OpenAPI request body schema to a typesafe JSON schema.
|
|
338
348
|
* @public
|
|
339
349
|
*/
|
|
340
|
-
type RequestBodyToJsonSchema<Doc extends RequiredDoc, Path extends
|
|
350
|
+
type RequestBodyToJsonSchema<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = ToTypeSafe<RequestBodySchema<Doc, Path, Method>>;
|
|
341
351
|
|
|
342
352
|
/**
|
|
343
353
|
* Pulled from https://github.com/varanauskas/oatx.
|
|
@@ -346,47 +356,49 @@ type RequestBodyToJsonSchema<Doc extends RequiredDoc, Path extends PathTemplate<
|
|
|
346
356
|
/**
|
|
347
357
|
* @public
|
|
348
358
|
*/
|
|
349
|
-
type Response<Doc extends RequiredDoc, Path extends
|
|
359
|
+
type Response$1<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>, StatusCode extends keyof DocOperation<Doc, Path, Method>['responses']> = DocOperation<Doc, Path, Method>['responses'][StatusCode] extends ImmutableReferenceObject ? 'responses' extends ComponentTypes<Doc> ? ComponentRef<Doc, 'responses', DocOperation<Doc, Path, Method>['responses'][StatusCode]> : never : DocOperation<Doc, Path, Method>['responses'][StatusCode];
|
|
350
360
|
/**
|
|
351
361
|
* @public
|
|
352
362
|
*/
|
|
353
|
-
type ResponseSchemas<Doc extends RequiredDoc, Path extends
|
|
354
|
-
[StatusCode in keyof DocOperation<Doc, Path, Method>['responses']]: Response<Doc, Path, Method, StatusCode> extends ImmutableResponseObject ? ObjectWithContentSchema<Doc, Response<Doc, Path, Method, StatusCode>> : never;
|
|
363
|
+
type ResponseSchemas<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = {
|
|
364
|
+
[StatusCode in keyof DocOperation<Doc, Path, Method>['responses']]: Response$1<Doc, Path, Method, StatusCode> extends ImmutableResponseObject ? ObjectWithContentSchema<Doc, Response$1<Doc, Path, Method, StatusCode>> : never;
|
|
355
365
|
};
|
|
356
366
|
/**
|
|
357
367
|
* Transform the OpenAPI request body schema to a typesafe JSON schema.
|
|
358
368
|
* @public
|
|
359
369
|
*/
|
|
360
|
-
type ResponseBodyToJsonSchema<Doc extends RequiredDoc, Path extends
|
|
370
|
+
type ResponseBodyToJsonSchema<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = ToTypeSafe<ValueOf<ResponseSchemas<Doc, Path, Method>>>;
|
|
361
371
|
|
|
362
372
|
/**
|
|
363
373
|
* Typed express request handler.
|
|
364
374
|
* @public
|
|
365
375
|
*/
|
|
366
|
-
type DocRequestHandler<Doc extends RequiredDoc, Path extends
|
|
376
|
+
type DocRequestHandler<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = core.RequestHandler<PathSchema<Doc, Path, Method>, ResponseBodyToJsonSchema<Doc, Path, Method>, RequestBodyToJsonSchema<Doc, Path, Method>, QuerySchema<Doc, Path, Method>, Record<string, string>>;
|
|
367
377
|
/**
|
|
368
378
|
* Typed express error handler / request handler union type.
|
|
369
379
|
* @public
|
|
370
380
|
*/
|
|
371
|
-
type DocRequestHandlerParams<Doc extends RequiredDoc, Path extends
|
|
381
|
+
type DocRequestHandlerParams<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = core.RequestHandlerParams<PathSchema<Doc, Path, Method>, ResponseBodyToJsonSchema<Doc, Path, Method>, RequestBodyToJsonSchema<Doc, Path, Method>, QuerySchema<Doc, Path, Method>, Record<string, string>>;
|
|
372
382
|
/**
|
|
373
383
|
* Superset of the express router path matcher that enforces typed request and response bodies.
|
|
374
384
|
* @public
|
|
375
385
|
*/
|
|
376
386
|
interface DocRequestMatcher<Doc extends RequiredDoc, T, Method extends 'all' | 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head'> {
|
|
377
|
-
<Path extends MethodAwareDocPath<Doc,
|
|
378
|
-
<Path extends MethodAwareDocPath<Doc,
|
|
387
|
+
<Path extends MethodAwareDocPath<Doc, PathTemplate<Extract<keyof Doc['paths'], string>>, Method>>(path: Path, ...handlers: Array<DocRequestHandler<Doc, TemplateToDocPath<Doc, Path>, Method>>): T;
|
|
388
|
+
<Path extends MethodAwareDocPath<Doc, PathTemplate<Extract<keyof Doc['paths'], string>>, Method>>(path: Path, ...handlers: Array<DocRequestHandlerParams<Doc, TemplateToDocPath<Doc, Path>, Method>>): T;
|
|
379
389
|
}
|
|
380
390
|
|
|
381
391
|
type index_d_RequiredDoc = RequiredDoc;
|
|
382
392
|
type index_d_PathDoc = PathDoc;
|
|
383
393
|
type index_d_ValueOf<T> = ValueOf<T>;
|
|
394
|
+
type index_d_DocPath<Doc extends PathDoc> = DocPath<Doc>;
|
|
384
395
|
type index_d_PathTemplate<Path extends string> = PathTemplate<Path>;
|
|
385
|
-
type
|
|
396
|
+
type index_d_TemplateToDocPath<Doc extends PathDoc, Path extends DocPathTemplate<Doc>> = TemplateToDocPath<Doc, Path>;
|
|
386
397
|
type index_d_DocPathTemplate<Doc extends PathDoc> = DocPathTemplate<Doc>;
|
|
387
|
-
type index_d_DocPathMethod<Doc extends Pick<RequiredDoc, 'paths'>, Path extends
|
|
388
|
-
type
|
|
389
|
-
type
|
|
398
|
+
type index_d_DocPathMethod<Doc extends Pick<RequiredDoc, 'paths'>, Path extends DocPath<Doc>> = DocPathMethod<Doc, Path>;
|
|
399
|
+
type index_d_DocPathTemplateMethod<Doc extends Pick<RequiredDoc, 'paths'>, Path extends DocPathTemplate<Doc>> = DocPathTemplateMethod<Doc, Path>;
|
|
400
|
+
type index_d_MethodAwareDocPath<Doc extends PathDoc, Path extends DocPathTemplate<Doc>, Method extends DocPathTemplateMethod<Doc, Path>> = MethodAwareDocPath<Doc, Path, Method>;
|
|
401
|
+
type index_d_DocOperation<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends keyof Doc['paths'][Path]> = DocOperation<Doc, Path, Method>;
|
|
390
402
|
type index_d_ComponentTypes<Doc extends RequiredDoc> = ComponentTypes<Doc>;
|
|
391
403
|
type index_d_ComponentRef<Doc extends RequiredDoc, Type extends ComponentTypes<Doc>, Ref extends ImmutableReferenceObject> = ComponentRef<Doc, Type, Ref>;
|
|
392
404
|
type index_d_SchemaRef<Doc extends RequiredDoc, Schema> = SchemaRef<Doc, Schema>;
|
|
@@ -418,8 +430,8 @@ type index_d_FullMap<T extends {
|
|
|
418
430
|
[key: string]: any;
|
|
419
431
|
}> = FullMap<T>;
|
|
420
432
|
type index_d_Filter<T, U> = Filter<T, U>;
|
|
421
|
-
type index_d_DocRequestHandler<Doc extends RequiredDoc, Path extends
|
|
422
|
-
type index_d_DocRequestHandlerParams<Doc extends RequiredDoc, Path extends
|
|
433
|
+
type index_d_DocRequestHandler<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = DocRequestHandler<Doc, Path, Method>;
|
|
434
|
+
type index_d_DocRequestHandlerParams<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = DocRequestHandlerParams<Doc, Path, Method>;
|
|
423
435
|
type index_d_DocRequestMatcher<Doc extends RequiredDoc, T, Method extends 'all' | 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options' | 'head'> = DocRequestMatcher<Doc, T, Method>;
|
|
424
436
|
type index_d_Immutable<T> = Immutable<T>;
|
|
425
437
|
type index_d_ImmutableObject<T> = ImmutableObject<T>;
|
|
@@ -438,31 +450,32 @@ type index_d_ImmutableQueryObject = ImmutableQueryObject;
|
|
|
438
450
|
type index_d_PathObject = PathObject;
|
|
439
451
|
type index_d_ImmutablePathObject = ImmutablePathObject;
|
|
440
452
|
type index_d_ImmutableSchemaObject = ImmutableSchemaObject;
|
|
441
|
-
type index_d_DocParameter<Doc extends RequiredDoc, Path extends
|
|
453
|
+
type index_d_DocParameter<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>, Parameter extends keyof DocOperation<Doc, Path, Method>['parameters']> = DocParameter<Doc, Path, Method, Parameter>;
|
|
442
454
|
type index_d_FromNumberStringToNumber<NumberString extends string | number | symbol> = FromNumberStringToNumber<NumberString>;
|
|
443
455
|
type index_d_DocParameters<Doc extends RequiredDoc, Path extends Extract<keyof Doc['paths'], string>, Method extends keyof Doc['paths'][Path]> = DocParameters<Doc, Path, Method>;
|
|
444
456
|
type index_d_ParameterSchema<Doc extends RequiredDoc, Schema extends ImmutableParameterObject['schema']> = ParameterSchema<Doc, Schema>;
|
|
445
457
|
type index_d_MapToSchema<Doc extends RequiredDoc, T extends Record<string, ImmutableParameterObject>> = MapToSchema<Doc, T>;
|
|
446
458
|
type index_d_ParametersSchema<Doc extends RequiredDoc, Path extends Extract<keyof Doc['paths'], string>, Method extends keyof Doc['paths'][Path], FilterType extends ImmutableParameterObject> = ParametersSchema<Doc, Path, Method, FilterType>;
|
|
447
|
-
type index_d_HeaderSchema<Doc extends RequiredDoc, Path extends
|
|
448
|
-
type index_d_CookieSchema<Doc extends RequiredDoc, Path extends
|
|
449
|
-
type index_d_PathSchema<Doc extends RequiredDoc, Path extends
|
|
450
|
-
type index_d_QuerySchema<Doc extends RequiredDoc, Path extends
|
|
459
|
+
type index_d_HeaderSchema<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = HeaderSchema<Doc, Path, Method>;
|
|
460
|
+
type index_d_CookieSchema<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = CookieSchema<Doc, Path, Method>;
|
|
461
|
+
type index_d_PathSchema<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = PathSchema<Doc, Path, Method>;
|
|
462
|
+
type index_d_QuerySchema<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = QuerySchema<Doc, Path, Method>;
|
|
451
463
|
type index_d_RequestBody<Doc extends RequiredDoc, Path extends Extract<keyof Doc['paths'], string>, Method extends keyof Doc['paths'][Path]> = RequestBody<Doc, Path, Method>;
|
|
452
|
-
type index_d_RequestBodySchema<Doc extends RequiredDoc, Path extends
|
|
453
|
-
type index_d_RequestBodyToJsonSchema<Doc extends RequiredDoc, Path extends
|
|
454
|
-
type
|
|
455
|
-
type
|
|
456
|
-
type index_d_ResponseBodyToJsonSchema<Doc extends RequiredDoc, Path extends PathTemplate<Extract<keyof Doc['paths'], string>>, Method extends DocPathMethod<Doc, Path>> = ResponseBodyToJsonSchema<Doc, Path, Method>;
|
|
464
|
+
type index_d_RequestBodySchema<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = RequestBodySchema<Doc, Path, Method>;
|
|
465
|
+
type index_d_RequestBodyToJsonSchema<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = RequestBodyToJsonSchema<Doc, Path, Method>;
|
|
466
|
+
type index_d_ResponseSchemas<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = ResponseSchemas<Doc, Path, Method>;
|
|
467
|
+
type index_d_ResponseBodyToJsonSchema<Doc extends RequiredDoc, Path extends DocPath<Doc>, Method extends DocPathMethod<Doc, Path>> = ResponseBodyToJsonSchema<Doc, Path, Method>;
|
|
457
468
|
declare namespace index_d {
|
|
458
469
|
export {
|
|
459
470
|
index_d_RequiredDoc as RequiredDoc,
|
|
460
471
|
index_d_PathDoc as PathDoc,
|
|
461
472
|
index_d_ValueOf as ValueOf,
|
|
462
|
-
index_d_PathTemplate as PathTemplate,
|
|
463
473
|
index_d_DocPath as DocPath,
|
|
474
|
+
index_d_PathTemplate as PathTemplate,
|
|
475
|
+
index_d_TemplateToDocPath as TemplateToDocPath,
|
|
464
476
|
index_d_DocPathTemplate as DocPathTemplate,
|
|
465
477
|
index_d_DocPathMethod as DocPathMethod,
|
|
478
|
+
index_d_DocPathTemplateMethod as DocPathTemplateMethod,
|
|
466
479
|
index_d_MethodAwareDocPath as MethodAwareDocPath,
|
|
467
480
|
index_d_DocOperation as DocOperation,
|
|
468
481
|
index_d_ComponentTypes as ComponentTypes,
|
|
@@ -517,12 +530,37 @@ declare namespace index_d {
|
|
|
517
530
|
index_d_RequestBody as RequestBody,
|
|
518
531
|
index_d_RequestBodySchema as RequestBodySchema,
|
|
519
532
|
index_d_RequestBodyToJsonSchema as RequestBodyToJsonSchema,
|
|
520
|
-
|
|
533
|
+
Response$1 as Response,
|
|
521
534
|
index_d_ResponseSchemas as ResponseSchemas,
|
|
522
535
|
index_d_ResponseBodyToJsonSchema as ResponseBodyToJsonSchema,
|
|
523
536
|
};
|
|
524
537
|
}
|
|
525
538
|
|
|
539
|
+
/**
|
|
540
|
+
* @public
|
|
541
|
+
*/
|
|
542
|
+
type Response<Doc extends RequiredDoc, Path extends PathTemplate<Extract<keyof Doc['paths'], string>>, Method extends DocPathTemplateMethod<Doc, Path>> = ResponseBodyToJsonSchema<Doc, TemplateToDocPath<Doc, Path>, Method>;
|
|
543
|
+
/**
|
|
544
|
+
* @public
|
|
545
|
+
*/
|
|
546
|
+
type Request<Doc extends RequiredDoc, Path extends PathTemplate<Extract<keyof Doc['paths'], string>>, Method extends DocPathTemplateMethod<Doc, Path>> = RequestBodyToJsonSchema<Doc, TemplateToDocPath<Doc, Path>, Method>;
|
|
547
|
+
/**
|
|
548
|
+
* @public
|
|
549
|
+
*/
|
|
550
|
+
type HeaderParameters<Doc extends RequiredDoc, Path extends PathTemplate<Extract<keyof Doc['paths'], string>>, Method extends DocPathTemplateMethod<Doc, Path>> = HeaderSchema<Doc, TemplateToDocPath<Doc, Path>, Method>;
|
|
551
|
+
/**
|
|
552
|
+
* @public
|
|
553
|
+
*/
|
|
554
|
+
type CookieParameters<Doc extends RequiredDoc, Path extends PathTemplate<Extract<keyof Doc['paths'], string>>, Method extends DocPathTemplateMethod<Doc, Path>> = CookieSchema<Doc, TemplateToDocPath<Doc, Path>, Method>;
|
|
555
|
+
/**
|
|
556
|
+
* @public
|
|
557
|
+
*/
|
|
558
|
+
type PathParameters<Doc extends RequiredDoc, Path extends PathTemplate<Extract<keyof Doc['paths'], string>>, Method extends DocPathTemplateMethod<Doc, Path>> = PathSchema<Doc, TemplateToDocPath<Doc, Path>, Method>;
|
|
559
|
+
/**
|
|
560
|
+
* @public
|
|
561
|
+
*/
|
|
562
|
+
type QueryParameters<Doc extends RequiredDoc, Path extends PathTemplate<Extract<keyof Doc['paths'], string>>, Method extends DocPathTemplateMethod<Doc, Path>> = QuerySchema<Doc, TemplateToDocPath<Doc, Path>, Method>;
|
|
563
|
+
|
|
526
564
|
/**
|
|
527
565
|
* Typed Express router based on an OpenAPI 3.1 spec.
|
|
528
566
|
* @public
|
|
@@ -550,4 +588,4 @@ declare function createValidatedOpenApiRouter<T extends RequiredDoc>(spec: T, op
|
|
|
550
588
|
middleware?: RequestHandler[];
|
|
551
589
|
}): ApiRouter<T>;
|
|
552
590
|
|
|
553
|
-
export { ApiRouter, createValidatedOpenApiRouter, index_d as internal };
|
|
591
|
+
export { ApiRouter, CookieParameters, HeaderParameters, PathParameters, QueryParameters, Request, Response, createValidatedOpenApiRouter, index_d as internal };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/backend-openapi-utils",
|
|
3
3
|
"description": "OpenAPI typescript support.",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"postpack": "backstage-cli package postpack"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@backstage/cli": "^0.
|
|
33
|
+
"@backstage/cli": "^0.23.0",
|
|
34
34
|
"supertest": "^6.1.3"
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@backstage/errors": "^1.2.
|
|
40
|
+
"@backstage/errors": "^1.2.3",
|
|
41
41
|
"@types/express": "^4.17.6",
|
|
42
42
|
"@types/express-serve-static-core": "^4.17.5",
|
|
43
43
|
"express": "^4.17.1",
|