zod-openapi 5.0.0-beta.17 → 5.0.0-beta.18
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/README.md +87 -5
- package/dist/api.d.mts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +1 -1
- package/dist/api.mjs +1 -1
- package/dist/{components-Ds_qyBU9.d.ts → components-BLmIpmmY.d.ts} +44 -3
- package/dist/{components-D4JjPRqN.js → components-BqmhtKMD.js} +130 -12
- package/dist/{components-CncTLZvX.mjs → components-Cblv9pY1.mjs} +130 -12
- package/dist/{components-uNe8arnt.d.mts → components-DkESnIB9.d.mts} +44 -3
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -263,7 +263,7 @@ const { schema, components } = createSchema(job);
|
|
|
263
263
|
|
|
264
264
|
`createSchema` takes an optional `CreateSchemaOptions` parameter which includes all options from [CreateDocumentOptions](#createdocumentoptions) plus the following:
|
|
265
265
|
|
|
266
|
-
|
|
266
|
+
```typescript
|
|
267
267
|
const { schema, components } = createSchema(job, {
|
|
268
268
|
// Input/Output context - controls how schemas are generated
|
|
269
269
|
io: 'input', // 'input' for request bodies/params, 'output' for responses
|
|
@@ -272,6 +272,7 @@ const { schema, components } = createSchema(job, {
|
|
|
272
272
|
schemaComponents: { jobId: z.string() }, // Pre-defined components to use
|
|
273
273
|
schemaComponentRefPath: '#/definitions/', // Custom path prefix for component references
|
|
274
274
|
});
|
|
275
|
+
```
|
|
275
276
|
|
|
276
277
|
### Request Parameters
|
|
277
278
|
|
|
@@ -292,7 +293,7 @@ createDocument({
|
|
|
292
293
|
},
|
|
293
294
|
},
|
|
294
295
|
});
|
|
295
|
-
|
|
296
|
+
```
|
|
296
297
|
|
|
297
298
|
If you would like to declare parameters in a more traditional way you may also declare them using the [parameters](https://swagger.io/docs/specification/describing-parameters/) key. The definitions will then all be combined.
|
|
298
299
|
|
|
@@ -636,7 +637,7 @@ createDocument({
|
|
|
636
637
|
|
|
637
638
|
Path Items can also be registered
|
|
638
639
|
|
|
639
|
-
|
|
640
|
+
```typescript
|
|
640
641
|
const pathItem: ZodOpenApiPathItemObject = {
|
|
641
642
|
id: 'some-path-item',
|
|
642
643
|
get: {
|
|
@@ -664,7 +665,88 @@ createDocument({
|
|
|
664
665
|
});
|
|
665
666
|
```
|
|
666
667
|
|
|
668
|
+
#### Security Schemes
|
|
669
|
+
|
|
670
|
+
Security Schemes can be registered for authentication methods:
|
|
671
|
+
|
|
672
|
+
```typescript
|
|
673
|
+
createDocument({
|
|
674
|
+
components: {
|
|
675
|
+
securitySchemes: {
|
|
676
|
+
bearerAuth: {
|
|
677
|
+
type: 'http',
|
|
678
|
+
scheme: 'bearer',
|
|
679
|
+
bearerFormat: 'JWT',
|
|
680
|
+
description: 'JWT Authentication',
|
|
681
|
+
},
|
|
682
|
+
},
|
|
683
|
+
},
|
|
684
|
+
});
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
#### Links
|
|
688
|
+
|
|
689
|
+
Links can be registered to describe relationships between operations:
|
|
690
|
+
|
|
691
|
+
```typescript
|
|
692
|
+
const link: ZodOpenApiLinkObject = {
|
|
693
|
+
id: 'getUserById',
|
|
694
|
+
operationId: 'getUser',
|
|
695
|
+
parameters: {
|
|
696
|
+
userId: '$request.path.id',
|
|
697
|
+
},
|
|
698
|
+
description: 'Link to get user by id',
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
// or
|
|
702
|
+
|
|
703
|
+
createDocument({
|
|
704
|
+
components: {
|
|
705
|
+
links: {
|
|
706
|
+
getUserById: {
|
|
707
|
+
operationId: 'getUser',
|
|
708
|
+
parameters: {
|
|
709
|
+
userId: '$request.path.id',
|
|
710
|
+
},
|
|
711
|
+
description: 'Link to get user by id',
|
|
712
|
+
},
|
|
713
|
+
},
|
|
714
|
+
},
|
|
715
|
+
});
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
#### Examples
|
|
667
719
|
|
|
720
|
+
Examples can be registered to provide sample values for schemas:
|
|
721
|
+
|
|
722
|
+
```typescript
|
|
723
|
+
const example: ZodOpenApiExampleObject = {
|
|
724
|
+
id: 'userExample',
|
|
725
|
+
summary: 'A sample user',
|
|
726
|
+
value: {
|
|
727
|
+
id: '123',
|
|
728
|
+
name: 'Jane Doe',
|
|
729
|
+
email: 'jane@example.com',
|
|
730
|
+
},
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
// or
|
|
734
|
+
|
|
735
|
+
createDocument({
|
|
736
|
+
components: {
|
|
737
|
+
examples: {
|
|
738
|
+
userExample: {
|
|
739
|
+
summary: 'A sample user',
|
|
740
|
+
value: {
|
|
741
|
+
id: '123',
|
|
742
|
+
name: 'Jane Doe',
|
|
743
|
+
email: 'jane@example.com',
|
|
744
|
+
},
|
|
745
|
+
},
|
|
746
|
+
},
|
|
747
|
+
},
|
|
748
|
+
});
|
|
749
|
+
```
|
|
668
750
|
|
|
669
751
|
### Zod Types
|
|
670
752
|
|
|
@@ -682,11 +764,11 @@ Output:
|
|
|
682
764
|
|
|
683
765
|
In general, you want to avoid using a registered input schema in an output context and vice versa. This is because the rendered input and output schemas of a simple Zod schema will differ, even with a simple Zod schema like `z.object()`.
|
|
684
766
|
|
|
685
|
-
```
|
|
767
|
+
```typescript
|
|
686
768
|
const schema = z.object({
|
|
687
769
|
name: z.string(),
|
|
688
770
|
});
|
|
689
|
-
|
|
771
|
+
```
|
|
690
772
|
|
|
691
773
|
Input schemas (request bodies, parameters):
|
|
692
774
|
|
package/dist/api.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentRegistry, Override, createComponents, createRegistry } from "./components-
|
|
1
|
+
import { ComponentRegistry, Override, createComponents, createRegistry } from "./components-DkESnIB9.mjs";
|
|
2
2
|
import { $ZodObject, $ZodType, $ZodTypes } from "zod/v4/core";
|
|
3
3
|
import { core } from "zod/v4";
|
|
4
4
|
|
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentRegistry, Override, createComponents, createRegistry } from "./components-
|
|
1
|
+
import { ComponentRegistry, Override, createComponents, createRegistry } from "./components-BLmIpmmY.js";
|
|
2
2
|
import { $ZodObject, $ZodType, $ZodTypes } from "zod/v4/core";
|
|
3
3
|
import { core } from "zod/v4";
|
|
4
4
|
|
package/dist/api.js
CHANGED
package/dist/api.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { createComponents, createRegistry, isAnyZodType, unwrapZodObject } from "./components-
|
|
1
|
+
import { createComponents, createRegistry, isAnyZodType, unwrapZodObject } from "./components-Cblv9pY1.mjs";
|
|
2
2
|
|
|
3
3
|
export { createComponents, createRegistry, isAnyZodType, unwrapZodObject };
|
|
@@ -381,9 +381,10 @@ interface ZodOpenApiRequestBodyObject extends Omit<RequestBodyObject, 'content'>
|
|
|
381
381
|
id?: string;
|
|
382
382
|
}
|
|
383
383
|
type ZodOpenApiHeadersObject = ZodObjectInput | HeadersObject;
|
|
384
|
-
interface ZodOpenApiResponseObject extends Omit<ResponseObject, 'content' | 'headers'> {
|
|
384
|
+
interface ZodOpenApiResponseObject extends Omit<ResponseObject, 'content' | 'headers' | 'links'> {
|
|
385
385
|
content?: ZodOpenApiContentObject;
|
|
386
386
|
headers?: ZodOpenApiHeadersObject;
|
|
387
|
+
links?: ZodOpenApiLinksObject;
|
|
387
388
|
/** Use this field to auto register this response object as a component */
|
|
388
389
|
id?: string;
|
|
389
390
|
}
|
|
@@ -427,7 +428,23 @@ interface ZodOpenApiPathsObject extends ISpecificationExtension {
|
|
|
427
428
|
type ZodOpenApiParameterObject = $ZodType | ParameterObject | ReferenceObject;
|
|
428
429
|
type ZodOpenApiHeaderObject = $ZodType | HeaderObject | ReferenceObject;
|
|
429
430
|
type ZodOpenApiSchemaObject = $ZodType | SchemaObject | ReferenceObject;
|
|
430
|
-
interface
|
|
431
|
+
interface ZodOpenApiSecuritySchemeObject extends SecuritySchemeObject {
|
|
432
|
+
/**
|
|
433
|
+
* Used to register this security scheme as a component.
|
|
434
|
+
*/
|
|
435
|
+
id?: string;
|
|
436
|
+
}
|
|
437
|
+
interface ZodOpenApiLinkObject extends LinkObject {
|
|
438
|
+
/** Use this field to auto register this link object as a component */
|
|
439
|
+
id?: string;
|
|
440
|
+
}
|
|
441
|
+
type ZodOpenApiLinksObject = Record<string, ZodOpenApiLinkObject | ReferenceObject>;
|
|
442
|
+
interface ZodOpenApiExampleObject extends ExampleObject {
|
|
443
|
+
/** Use this field to auto register this example object as a component */
|
|
444
|
+
id?: string;
|
|
445
|
+
}
|
|
446
|
+
type ZodOpenApiExamplesObject = Record<string, ZodOpenApiExampleObject | ReferenceObject>;
|
|
447
|
+
interface ZodOpenApiComponentsObject extends Omit<ComponentsObject, 'schemas' | 'responses' | 'requestBodies' | 'headers' | 'parameters' | 'pathItems' | 'callbacks' | 'securitySchemes' | 'examples'> {
|
|
431
448
|
parameters?: Record<string, ZodOpenApiParameterObject>;
|
|
432
449
|
schemas?: Record<string, ZodOpenApiSchemaObject>;
|
|
433
450
|
requestBodies?: Record<string, ZodOpenApiRequestBodyObject>;
|
|
@@ -435,6 +452,9 @@ interface ZodOpenApiComponentsObject extends Omit<ComponentsObject, 'schemas' |
|
|
|
435
452
|
responses?: Record<string, ZodOpenApiResponseObject>;
|
|
436
453
|
callbacks?: Record<string, ZodOpenApiCallbackObject>;
|
|
437
454
|
pathItems?: Record<string, ZodOpenApiPathItemObject>;
|
|
455
|
+
securitySchemes?: Record<string, ZodOpenApiSecuritySchemeObject>;
|
|
456
|
+
links?: Record<string, ZodOpenApiLinkObject>;
|
|
457
|
+
examples?: Record<string, ZodOpenApiExampleObject>;
|
|
438
458
|
}
|
|
439
459
|
type ZodOpenApiVersion = OpenApiVersion;
|
|
440
460
|
interface ZodOpenApiObject extends Omit<OpenAPIObject, 'openapi' | 'paths' | 'webhooks' | 'components'> {
|
|
@@ -553,6 +573,18 @@ interface ComponentRegistry {
|
|
|
553
573
|
ids: Map<string, PathItemObject | ReferenceObject>;
|
|
554
574
|
seen: WeakMap<ZodOpenApiPathItemObject, PathItemObject | ReferenceObject>;
|
|
555
575
|
};
|
|
576
|
+
securitySchemes: {
|
|
577
|
+
ids: Map<string, SecuritySchemeObject | ReferenceObject>;
|
|
578
|
+
seen: WeakMap<ZodOpenApiSecuritySchemeObject, SecuritySchemeObject | ReferenceObject>;
|
|
579
|
+
};
|
|
580
|
+
links: {
|
|
581
|
+
ids: Map<string, LinkObject | ReferenceObject>;
|
|
582
|
+
seen: WeakMap<ZodOpenApiLinkObject, LinkObject | ReferenceObject>;
|
|
583
|
+
};
|
|
584
|
+
examples: {
|
|
585
|
+
ids: Map<string, ExampleObject | ReferenceObject>;
|
|
586
|
+
seen: WeakMap<ZodOpenApiExampleObject, ExampleObject | ReferenceObject>;
|
|
587
|
+
};
|
|
556
588
|
};
|
|
557
589
|
addSchema: (schema: $ZodType, path: string[], opts: {
|
|
558
590
|
io: 'input' | 'output';
|
|
@@ -580,8 +612,17 @@ interface ComponentRegistry {
|
|
|
580
612
|
addCallback: (callback: ZodOpenApiCallbackObject, path: string[], opts?: {
|
|
581
613
|
manualId?: string;
|
|
582
614
|
}) => CallbackObject | ReferenceObject;
|
|
615
|
+
addSecurityScheme: (securityScheme: ZodOpenApiSecuritySchemeObject, path: string[], opts?: {
|
|
616
|
+
manualId?: string;
|
|
617
|
+
}) => SecuritySchemeObject | ReferenceObject;
|
|
618
|
+
addLink: (link: ZodOpenApiLinkObject, path: string[], opts?: {
|
|
619
|
+
manualId?: string;
|
|
620
|
+
}) => LinkObject | ReferenceObject;
|
|
621
|
+
addExample: (example: ZodOpenApiExampleObject, path: string[], opts?: {
|
|
622
|
+
manualId?: string;
|
|
623
|
+
}) => ExampleObject | ReferenceObject;
|
|
583
624
|
}
|
|
584
625
|
declare const createRegistry: (components?: ZodOpenApiComponentsObject) => ComponentRegistry;
|
|
585
626
|
declare const createComponents: (registry: ComponentRegistry, opts: CreateDocumentOptions) => ComponentsObject;
|
|
586
627
|
//#endregion
|
|
587
|
-
export { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, Override, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiVersion, createComponents, createDocument, createRegistry };
|
|
628
|
+
export { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, Override, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createComponents, createDocument, createRegistry };
|
|
@@ -27,19 +27,31 @@ const zod_v4 = __toESM(require("zod/v4"));
|
|
|
27
27
|
//#region src/zod.ts
|
|
28
28
|
const isAnyZodType = (schema) => typeof schema === "object" && schema !== null && "_zod" in schema;
|
|
29
29
|
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/create/examples.ts
|
|
32
|
+
const createExamples = (examples, registry$1, path) => {
|
|
33
|
+
if (!examples) return void 0;
|
|
34
|
+
const examplesObject = {};
|
|
35
|
+
for (const [name, example] of Object.entries(examples)) {
|
|
36
|
+
const exampleObject = registry$1.addExample(example, [...path, name]);
|
|
37
|
+
examplesObject[name] = exampleObject;
|
|
38
|
+
}
|
|
39
|
+
return examplesObject;
|
|
40
|
+
};
|
|
41
|
+
|
|
30
42
|
//#endregion
|
|
31
43
|
//#region src/create/content.ts
|
|
32
|
-
const createMediaTypeObject = (
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
const createMediaTypeObject = (mediaType, ctx, path) => {
|
|
45
|
+
const { schema, examples,...rest } = mediaType;
|
|
46
|
+
const mediaTypeObject = rest;
|
|
47
|
+
if (isAnyZodType(schema)) {
|
|
48
|
+
const schemaObject = ctx.registry.addSchema(schema, [...path, "schema"], {
|
|
35
49
|
io: ctx.io,
|
|
36
50
|
source: { type: "mediaType" }
|
|
37
51
|
});
|
|
38
|
-
|
|
39
|
-
...mediaTypeObject,
|
|
40
|
-
schema: schemaObject
|
|
41
|
-
};
|
|
52
|
+
mediaTypeObject.schema = schemaObject;
|
|
42
53
|
}
|
|
54
|
+
if (examples) mediaTypeObject.examples = createExamples(examples, ctx.registry, [...path, "examples"]);
|
|
43
55
|
return mediaTypeObject;
|
|
44
56
|
};
|
|
45
57
|
const createContent = (content, ctx, path) => {
|
|
@@ -83,6 +95,18 @@ const createHeaders = (headers, registry$1, path) => {
|
|
|
83
95
|
return headers;
|
|
84
96
|
};
|
|
85
97
|
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/create/links.ts
|
|
100
|
+
const createLinks = (links, registry$1, path) => {
|
|
101
|
+
if (!links) return void 0;
|
|
102
|
+
const linksObject = {};
|
|
103
|
+
for (const [name, link] of Object.entries(links)) {
|
|
104
|
+
const linkObject = registry$1.addLink(link, [...path, name]);
|
|
105
|
+
linksObject[name] = linkObject;
|
|
106
|
+
}
|
|
107
|
+
return linksObject;
|
|
108
|
+
};
|
|
109
|
+
|
|
86
110
|
//#endregion
|
|
87
111
|
//#region src/create/parameters.ts
|
|
88
112
|
const createManualParameters = (parameters, registry$1, path) => {
|
|
@@ -470,6 +494,18 @@ const createRegistry = (components) => {
|
|
|
470
494
|
pathItems: {
|
|
471
495
|
ids: /* @__PURE__ */ new Map(),
|
|
472
496
|
seen: /* @__PURE__ */ new WeakMap()
|
|
497
|
+
},
|
|
498
|
+
securitySchemes: {
|
|
499
|
+
ids: /* @__PURE__ */ new Map(),
|
|
500
|
+
seen: /* @__PURE__ */ new WeakMap()
|
|
501
|
+
},
|
|
502
|
+
links: {
|
|
503
|
+
ids: /* @__PURE__ */ new Map(),
|
|
504
|
+
seen: /* @__PURE__ */ new WeakMap()
|
|
505
|
+
},
|
|
506
|
+
examples: {
|
|
507
|
+
ids: /* @__PURE__ */ new Map(),
|
|
508
|
+
seen: /* @__PURE__ */ new WeakMap()
|
|
473
509
|
}
|
|
474
510
|
},
|
|
475
511
|
addSchema: (schema, path, opts) => {
|
|
@@ -507,13 +543,20 @@ const createRegistry = (components) => {
|
|
|
507
543
|
}
|
|
508
544
|
}
|
|
509
545
|
});
|
|
510
|
-
const { id: metaId,...rest } = meta?.param ?? {};
|
|
546
|
+
const { id: metaId, examples,...rest } = meta?.param ?? {};
|
|
511
547
|
const parameterObject = {
|
|
512
|
-
...rest,
|
|
513
|
-
name,
|
|
514
548
|
in: inLocation,
|
|
515
|
-
|
|
549
|
+
name,
|
|
550
|
+
schema: schemaObject,
|
|
551
|
+
...rest
|
|
516
552
|
};
|
|
553
|
+
const examplesObject = createExamples(examples, registry$1, [
|
|
554
|
+
...path,
|
|
555
|
+
inLocation,
|
|
556
|
+
name,
|
|
557
|
+
"examples"
|
|
558
|
+
]);
|
|
559
|
+
if (examplesObject) parameterObject.examples = examplesObject;
|
|
517
560
|
if (isRequired(parameter, "input")) parameterObject.required = true;
|
|
518
561
|
if (!parameterObject.description && meta?.description) parameterObject.description = meta.description;
|
|
519
562
|
const id = metaId ?? opts?.manualId;
|
|
@@ -607,7 +650,7 @@ const createRegistry = (components) => {
|
|
|
607
650
|
addResponse: (response, path, opts) => {
|
|
608
651
|
const seenResponse = registry$1.components.responses.seen.get(response);
|
|
609
652
|
if (seenResponse) return seenResponse;
|
|
610
|
-
const { content, headers, id: metaId,...rest } = response;
|
|
653
|
+
const { content, headers, links, id: metaId,...rest } = response;
|
|
611
654
|
const responseObject = rest;
|
|
612
655
|
const maybeHeaders = createHeaders(headers, registry$1, [...path, "headers"]);
|
|
613
656
|
if (maybeHeaders) responseObject.headers = maybeHeaders;
|
|
@@ -615,6 +658,7 @@ const createRegistry = (components) => {
|
|
|
615
658
|
registry: registry$1,
|
|
616
659
|
io: "output"
|
|
617
660
|
}, [...path, "content"]);
|
|
661
|
+
if (links) responseObject.links = createLinks(links, registry$1, [...path, "links"]);
|
|
618
662
|
const id = metaId ?? opts?.manualId;
|
|
619
663
|
if (id) {
|
|
620
664
|
if (registry$1.components.responses.ids.has(id)) throw new Error(`Response "${id}" at ${path.join(" > ")} is already registered`);
|
|
@@ -648,6 +692,54 @@ const createRegistry = (components) => {
|
|
|
648
692
|
}
|
|
649
693
|
registry$1.components.callbacks.seen.set(callback, callbackObject);
|
|
650
694
|
return callbackObject;
|
|
695
|
+
},
|
|
696
|
+
addSecurityScheme: (securityScheme, path, opts) => {
|
|
697
|
+
const seenSecurityScheme = registry$1.components.securitySchemes.seen.get(securityScheme);
|
|
698
|
+
if (seenSecurityScheme) return seenSecurityScheme;
|
|
699
|
+
const { id: metaId,...rest } = securityScheme;
|
|
700
|
+
const securitySchemeObject = rest;
|
|
701
|
+
const id = metaId ?? opts?.manualId;
|
|
702
|
+
if (id) {
|
|
703
|
+
if (registry$1.components.securitySchemes.ids.has(id)) throw new Error(`SecurityScheme "${id}" at ${path.join(" > ")} is already registered`);
|
|
704
|
+
const ref = { $ref: `#/components/securitySchemes/${id}` };
|
|
705
|
+
registry$1.components.securitySchemes.ids.set(id, securitySchemeObject);
|
|
706
|
+
registry$1.components.securitySchemes.seen.set(securityScheme, ref);
|
|
707
|
+
return ref;
|
|
708
|
+
}
|
|
709
|
+
registry$1.components.securitySchemes.seen.set(securityScheme, securitySchemeObject);
|
|
710
|
+
return securitySchemeObject;
|
|
711
|
+
},
|
|
712
|
+
addLink: (link, path, opts) => {
|
|
713
|
+
const seenLink = registry$1.components.links.seen.get(link);
|
|
714
|
+
if (seenLink) return seenLink;
|
|
715
|
+
const { id: metaId,...rest } = link;
|
|
716
|
+
const linkObject = rest;
|
|
717
|
+
const id = metaId ?? opts?.manualId;
|
|
718
|
+
if (id) {
|
|
719
|
+
if (registry$1.components.links.ids.has(id)) throw new Error(`Link "${id}" at ${path.join(" > ")} is already registered`);
|
|
720
|
+
const ref = { $ref: `#/components/links/${id}` };
|
|
721
|
+
registry$1.components.links.ids.set(id, linkObject);
|
|
722
|
+
registry$1.components.links.seen.set(link, ref);
|
|
723
|
+
return ref;
|
|
724
|
+
}
|
|
725
|
+
registry$1.components.links.seen.set(link, linkObject);
|
|
726
|
+
return linkObject;
|
|
727
|
+
},
|
|
728
|
+
addExample: (example, path, opts) => {
|
|
729
|
+
const seenExample = registry$1.components.examples.seen.get(example);
|
|
730
|
+
if (seenExample) return seenExample;
|
|
731
|
+
const { id: metaId,...rest } = example;
|
|
732
|
+
const exampleObject = rest;
|
|
733
|
+
const id = metaId ?? opts?.manualId;
|
|
734
|
+
if (id) {
|
|
735
|
+
if (registry$1.components.examples.ids.has(id)) throw new Error(`Example "${id}" at ${path.join(" > ")} is already registered`);
|
|
736
|
+
const ref = { $ref: `#/components/examples/${id}` };
|
|
737
|
+
registry$1.components.examples.ids.set(id, exampleObject);
|
|
738
|
+
registry$1.components.examples.seen.set(example, ref);
|
|
739
|
+
return ref;
|
|
740
|
+
}
|
|
741
|
+
registry$1.components.examples.seen.set(example, exampleObject);
|
|
742
|
+
return exampleObject;
|
|
651
743
|
}
|
|
652
744
|
};
|
|
653
745
|
registerSchemas(components?.schemas, registry$1);
|
|
@@ -657,6 +749,9 @@ const createRegistry = (components) => {
|
|
|
657
749
|
registerPathItems(components?.pathItems, registry$1);
|
|
658
750
|
registerRequestBodies(components?.requestBodies, registry$1);
|
|
659
751
|
registerCallbacks(components?.callbacks, registry$1);
|
|
752
|
+
registerSecuritySchemes(components?.securitySchemes, registry$1);
|
|
753
|
+
registerLinks(components?.links, registry$1);
|
|
754
|
+
registerExamples(components?.examples, registry$1);
|
|
660
755
|
return registry$1;
|
|
661
756
|
};
|
|
662
757
|
const registerSchemas = (schemas, registry$1) => {
|
|
@@ -746,6 +841,26 @@ const registerPathItems = (pathItems, registry$1) => {
|
|
|
746
841
|
key
|
|
747
842
|
], { manualId: key });
|
|
748
843
|
};
|
|
844
|
+
const registerSecuritySchemes = (securitySchemes, registry$1) => {
|
|
845
|
+
if (!securitySchemes) return;
|
|
846
|
+
for (const [key, schema] of Object.entries(securitySchemes)) registry$1.addSecurityScheme(schema, [
|
|
847
|
+
"components",
|
|
848
|
+
"securitySchemes",
|
|
849
|
+
key
|
|
850
|
+
], { manualId: key });
|
|
851
|
+
};
|
|
852
|
+
const registerLinks = (links, registry$1) => {
|
|
853
|
+
if (!links) return;
|
|
854
|
+
for (const [key, schema] of Object.entries(links)) registry$1.addLink(schema, [
|
|
855
|
+
"components",
|
|
856
|
+
"links",
|
|
857
|
+
key
|
|
858
|
+
], { manualId: key });
|
|
859
|
+
};
|
|
860
|
+
const registerExamples = (examples, registry$1) => {
|
|
861
|
+
if (!examples) return;
|
|
862
|
+
for (const [key, schema] of Object.entries(examples)) registry$1.components.examples.ids.set(key, schema);
|
|
863
|
+
};
|
|
749
864
|
const createIOSchemas = (ctx) => {
|
|
750
865
|
const { schemas, components, manual } = createSchemas(Object.fromEntries(ctx.registry.components.schemas[ctx.io]), ctx);
|
|
751
866
|
for (const [key, schema] of Object.entries(components)) ctx.registry.components.schemas.ids.set(key, schema);
|
|
@@ -787,6 +902,9 @@ const createComponents = (registry$1, opts) => {
|
|
|
787
902
|
if (registry$1.components.parameters.ids.size > 0) components.parameters = Object.fromEntries(registry$1.components.parameters.ids);
|
|
788
903
|
if (registry$1.components.callbacks.ids.size > 0) components.callbacks = Object.fromEntries(registry$1.components.callbacks.ids);
|
|
789
904
|
if (registry$1.components.pathItems.ids.size > 0) components.pathItems = Object.fromEntries(registry$1.components.pathItems.ids);
|
|
905
|
+
if (registry$1.components.securitySchemes.ids.size > 0) components.securitySchemes = Object.fromEntries(registry$1.components.securitySchemes.ids);
|
|
906
|
+
if (registry$1.components.links.ids.size > 0) components.links = Object.fromEntries(registry$1.components.links.ids);
|
|
907
|
+
if (registry$1.components.examples.ids.size > 0) components.examples = Object.fromEntries(registry$1.components.examples.ids);
|
|
790
908
|
return components;
|
|
791
909
|
};
|
|
792
910
|
|
|
@@ -4,19 +4,31 @@ import { object, registry, toJSONSchema } from "zod/v4";
|
|
|
4
4
|
//#region src/zod.ts
|
|
5
5
|
const isAnyZodType = (schema) => typeof schema === "object" && schema !== null && "_zod" in schema;
|
|
6
6
|
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/create/examples.ts
|
|
9
|
+
const createExamples = (examples, registry$1, path) => {
|
|
10
|
+
if (!examples) return void 0;
|
|
11
|
+
const examplesObject = {};
|
|
12
|
+
for (const [name, example] of Object.entries(examples)) {
|
|
13
|
+
const exampleObject = registry$1.addExample(example, [...path, name]);
|
|
14
|
+
examplesObject[name] = exampleObject;
|
|
15
|
+
}
|
|
16
|
+
return examplesObject;
|
|
17
|
+
};
|
|
18
|
+
|
|
7
19
|
//#endregion
|
|
8
20
|
//#region src/create/content.ts
|
|
9
|
-
const createMediaTypeObject = (
|
|
10
|
-
|
|
11
|
-
|
|
21
|
+
const createMediaTypeObject = (mediaType, ctx, path) => {
|
|
22
|
+
const { schema, examples,...rest } = mediaType;
|
|
23
|
+
const mediaTypeObject = rest;
|
|
24
|
+
if (isAnyZodType(schema)) {
|
|
25
|
+
const schemaObject = ctx.registry.addSchema(schema, [...path, "schema"], {
|
|
12
26
|
io: ctx.io,
|
|
13
27
|
source: { type: "mediaType" }
|
|
14
28
|
});
|
|
15
|
-
|
|
16
|
-
...mediaTypeObject,
|
|
17
|
-
schema: schemaObject
|
|
18
|
-
};
|
|
29
|
+
mediaTypeObject.schema = schemaObject;
|
|
19
30
|
}
|
|
31
|
+
if (examples) mediaTypeObject.examples = createExamples(examples, ctx.registry, [...path, "examples"]);
|
|
20
32
|
return mediaTypeObject;
|
|
21
33
|
};
|
|
22
34
|
const createContent = (content, ctx, path) => {
|
|
@@ -60,6 +72,18 @@ const createHeaders = (headers, registry$1, path) => {
|
|
|
60
72
|
return headers;
|
|
61
73
|
};
|
|
62
74
|
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/create/links.ts
|
|
77
|
+
const createLinks = (links, registry$1, path) => {
|
|
78
|
+
if (!links) return void 0;
|
|
79
|
+
const linksObject = {};
|
|
80
|
+
for (const [name, link] of Object.entries(links)) {
|
|
81
|
+
const linkObject = registry$1.addLink(link, [...path, name]);
|
|
82
|
+
linksObject[name] = linkObject;
|
|
83
|
+
}
|
|
84
|
+
return linksObject;
|
|
85
|
+
};
|
|
86
|
+
|
|
63
87
|
//#endregion
|
|
64
88
|
//#region src/create/parameters.ts
|
|
65
89
|
const createManualParameters = (parameters, registry$1, path) => {
|
|
@@ -447,6 +471,18 @@ const createRegistry = (components) => {
|
|
|
447
471
|
pathItems: {
|
|
448
472
|
ids: /* @__PURE__ */ new Map(),
|
|
449
473
|
seen: /* @__PURE__ */ new WeakMap()
|
|
474
|
+
},
|
|
475
|
+
securitySchemes: {
|
|
476
|
+
ids: /* @__PURE__ */ new Map(),
|
|
477
|
+
seen: /* @__PURE__ */ new WeakMap()
|
|
478
|
+
},
|
|
479
|
+
links: {
|
|
480
|
+
ids: /* @__PURE__ */ new Map(),
|
|
481
|
+
seen: /* @__PURE__ */ new WeakMap()
|
|
482
|
+
},
|
|
483
|
+
examples: {
|
|
484
|
+
ids: /* @__PURE__ */ new Map(),
|
|
485
|
+
seen: /* @__PURE__ */ new WeakMap()
|
|
450
486
|
}
|
|
451
487
|
},
|
|
452
488
|
addSchema: (schema, path, opts) => {
|
|
@@ -484,13 +520,20 @@ const createRegistry = (components) => {
|
|
|
484
520
|
}
|
|
485
521
|
}
|
|
486
522
|
});
|
|
487
|
-
const { id: metaId,...rest } = meta?.param ?? {};
|
|
523
|
+
const { id: metaId, examples,...rest } = meta?.param ?? {};
|
|
488
524
|
const parameterObject = {
|
|
489
|
-
...rest,
|
|
490
|
-
name,
|
|
491
525
|
in: inLocation,
|
|
492
|
-
|
|
526
|
+
name,
|
|
527
|
+
schema: schemaObject,
|
|
528
|
+
...rest
|
|
493
529
|
};
|
|
530
|
+
const examplesObject = createExamples(examples, registry$1, [
|
|
531
|
+
...path,
|
|
532
|
+
inLocation,
|
|
533
|
+
name,
|
|
534
|
+
"examples"
|
|
535
|
+
]);
|
|
536
|
+
if (examplesObject) parameterObject.examples = examplesObject;
|
|
494
537
|
if (isRequired(parameter, "input")) parameterObject.required = true;
|
|
495
538
|
if (!parameterObject.description && meta?.description) parameterObject.description = meta.description;
|
|
496
539
|
const id = metaId ?? opts?.manualId;
|
|
@@ -584,7 +627,7 @@ const createRegistry = (components) => {
|
|
|
584
627
|
addResponse: (response, path, opts) => {
|
|
585
628
|
const seenResponse = registry$1.components.responses.seen.get(response);
|
|
586
629
|
if (seenResponse) return seenResponse;
|
|
587
|
-
const { content, headers, id: metaId,...rest } = response;
|
|
630
|
+
const { content, headers, links, id: metaId,...rest } = response;
|
|
588
631
|
const responseObject = rest;
|
|
589
632
|
const maybeHeaders = createHeaders(headers, registry$1, [...path, "headers"]);
|
|
590
633
|
if (maybeHeaders) responseObject.headers = maybeHeaders;
|
|
@@ -592,6 +635,7 @@ const createRegistry = (components) => {
|
|
|
592
635
|
registry: registry$1,
|
|
593
636
|
io: "output"
|
|
594
637
|
}, [...path, "content"]);
|
|
638
|
+
if (links) responseObject.links = createLinks(links, registry$1, [...path, "links"]);
|
|
595
639
|
const id = metaId ?? opts?.manualId;
|
|
596
640
|
if (id) {
|
|
597
641
|
if (registry$1.components.responses.ids.has(id)) throw new Error(`Response "${id}" at ${path.join(" > ")} is already registered`);
|
|
@@ -625,6 +669,54 @@ const createRegistry = (components) => {
|
|
|
625
669
|
}
|
|
626
670
|
registry$1.components.callbacks.seen.set(callback, callbackObject);
|
|
627
671
|
return callbackObject;
|
|
672
|
+
},
|
|
673
|
+
addSecurityScheme: (securityScheme, path, opts) => {
|
|
674
|
+
const seenSecurityScheme = registry$1.components.securitySchemes.seen.get(securityScheme);
|
|
675
|
+
if (seenSecurityScheme) return seenSecurityScheme;
|
|
676
|
+
const { id: metaId,...rest } = securityScheme;
|
|
677
|
+
const securitySchemeObject = rest;
|
|
678
|
+
const id = metaId ?? opts?.manualId;
|
|
679
|
+
if (id) {
|
|
680
|
+
if (registry$1.components.securitySchemes.ids.has(id)) throw new Error(`SecurityScheme "${id}" at ${path.join(" > ")} is already registered`);
|
|
681
|
+
const ref = { $ref: `#/components/securitySchemes/${id}` };
|
|
682
|
+
registry$1.components.securitySchemes.ids.set(id, securitySchemeObject);
|
|
683
|
+
registry$1.components.securitySchemes.seen.set(securityScheme, ref);
|
|
684
|
+
return ref;
|
|
685
|
+
}
|
|
686
|
+
registry$1.components.securitySchemes.seen.set(securityScheme, securitySchemeObject);
|
|
687
|
+
return securitySchemeObject;
|
|
688
|
+
},
|
|
689
|
+
addLink: (link, path, opts) => {
|
|
690
|
+
const seenLink = registry$1.components.links.seen.get(link);
|
|
691
|
+
if (seenLink) return seenLink;
|
|
692
|
+
const { id: metaId,...rest } = link;
|
|
693
|
+
const linkObject = rest;
|
|
694
|
+
const id = metaId ?? opts?.manualId;
|
|
695
|
+
if (id) {
|
|
696
|
+
if (registry$1.components.links.ids.has(id)) throw new Error(`Link "${id}" at ${path.join(" > ")} is already registered`);
|
|
697
|
+
const ref = { $ref: `#/components/links/${id}` };
|
|
698
|
+
registry$1.components.links.ids.set(id, linkObject);
|
|
699
|
+
registry$1.components.links.seen.set(link, ref);
|
|
700
|
+
return ref;
|
|
701
|
+
}
|
|
702
|
+
registry$1.components.links.seen.set(link, linkObject);
|
|
703
|
+
return linkObject;
|
|
704
|
+
},
|
|
705
|
+
addExample: (example, path, opts) => {
|
|
706
|
+
const seenExample = registry$1.components.examples.seen.get(example);
|
|
707
|
+
if (seenExample) return seenExample;
|
|
708
|
+
const { id: metaId,...rest } = example;
|
|
709
|
+
const exampleObject = rest;
|
|
710
|
+
const id = metaId ?? opts?.manualId;
|
|
711
|
+
if (id) {
|
|
712
|
+
if (registry$1.components.examples.ids.has(id)) throw new Error(`Example "${id}" at ${path.join(" > ")} is already registered`);
|
|
713
|
+
const ref = { $ref: `#/components/examples/${id}` };
|
|
714
|
+
registry$1.components.examples.ids.set(id, exampleObject);
|
|
715
|
+
registry$1.components.examples.seen.set(example, ref);
|
|
716
|
+
return ref;
|
|
717
|
+
}
|
|
718
|
+
registry$1.components.examples.seen.set(example, exampleObject);
|
|
719
|
+
return exampleObject;
|
|
628
720
|
}
|
|
629
721
|
};
|
|
630
722
|
registerSchemas(components?.schemas, registry$1);
|
|
@@ -634,6 +726,9 @@ const createRegistry = (components) => {
|
|
|
634
726
|
registerPathItems(components?.pathItems, registry$1);
|
|
635
727
|
registerRequestBodies(components?.requestBodies, registry$1);
|
|
636
728
|
registerCallbacks(components?.callbacks, registry$1);
|
|
729
|
+
registerSecuritySchemes(components?.securitySchemes, registry$1);
|
|
730
|
+
registerLinks(components?.links, registry$1);
|
|
731
|
+
registerExamples(components?.examples, registry$1);
|
|
637
732
|
return registry$1;
|
|
638
733
|
};
|
|
639
734
|
const registerSchemas = (schemas, registry$1) => {
|
|
@@ -723,6 +818,26 @@ const registerPathItems = (pathItems, registry$1) => {
|
|
|
723
818
|
key
|
|
724
819
|
], { manualId: key });
|
|
725
820
|
};
|
|
821
|
+
const registerSecuritySchemes = (securitySchemes, registry$1) => {
|
|
822
|
+
if (!securitySchemes) return;
|
|
823
|
+
for (const [key, schema] of Object.entries(securitySchemes)) registry$1.addSecurityScheme(schema, [
|
|
824
|
+
"components",
|
|
825
|
+
"securitySchemes",
|
|
826
|
+
key
|
|
827
|
+
], { manualId: key });
|
|
828
|
+
};
|
|
829
|
+
const registerLinks = (links, registry$1) => {
|
|
830
|
+
if (!links) return;
|
|
831
|
+
for (const [key, schema] of Object.entries(links)) registry$1.addLink(schema, [
|
|
832
|
+
"components",
|
|
833
|
+
"links",
|
|
834
|
+
key
|
|
835
|
+
], { manualId: key });
|
|
836
|
+
};
|
|
837
|
+
const registerExamples = (examples, registry$1) => {
|
|
838
|
+
if (!examples) return;
|
|
839
|
+
for (const [key, schema] of Object.entries(examples)) registry$1.components.examples.ids.set(key, schema);
|
|
840
|
+
};
|
|
726
841
|
const createIOSchemas = (ctx) => {
|
|
727
842
|
const { schemas, components, manual } = createSchemas(Object.fromEntries(ctx.registry.components.schemas[ctx.io]), ctx);
|
|
728
843
|
for (const [key, schema] of Object.entries(components)) ctx.registry.components.schemas.ids.set(key, schema);
|
|
@@ -764,6 +879,9 @@ const createComponents = (registry$1, opts) => {
|
|
|
764
879
|
if (registry$1.components.parameters.ids.size > 0) components.parameters = Object.fromEntries(registry$1.components.parameters.ids);
|
|
765
880
|
if (registry$1.components.callbacks.ids.size > 0) components.callbacks = Object.fromEntries(registry$1.components.callbacks.ids);
|
|
766
881
|
if (registry$1.components.pathItems.ids.size > 0) components.pathItems = Object.fromEntries(registry$1.components.pathItems.ids);
|
|
882
|
+
if (registry$1.components.securitySchemes.ids.size > 0) components.securitySchemes = Object.fromEntries(registry$1.components.securitySchemes.ids);
|
|
883
|
+
if (registry$1.components.links.ids.size > 0) components.links = Object.fromEntries(registry$1.components.links.ids);
|
|
884
|
+
if (registry$1.components.examples.ids.size > 0) components.examples = Object.fromEntries(registry$1.components.examples.ids);
|
|
767
885
|
return components;
|
|
768
886
|
};
|
|
769
887
|
|
|
@@ -381,9 +381,10 @@ interface ZodOpenApiRequestBodyObject extends Omit<RequestBodyObject, 'content'>
|
|
|
381
381
|
id?: string;
|
|
382
382
|
}
|
|
383
383
|
type ZodOpenApiHeadersObject = ZodObjectInput | HeadersObject;
|
|
384
|
-
interface ZodOpenApiResponseObject extends Omit<ResponseObject, 'content' | 'headers'> {
|
|
384
|
+
interface ZodOpenApiResponseObject extends Omit<ResponseObject, 'content' | 'headers' | 'links'> {
|
|
385
385
|
content?: ZodOpenApiContentObject;
|
|
386
386
|
headers?: ZodOpenApiHeadersObject;
|
|
387
|
+
links?: ZodOpenApiLinksObject;
|
|
387
388
|
/** Use this field to auto register this response object as a component */
|
|
388
389
|
id?: string;
|
|
389
390
|
}
|
|
@@ -427,7 +428,23 @@ interface ZodOpenApiPathsObject extends ISpecificationExtension {
|
|
|
427
428
|
type ZodOpenApiParameterObject = $ZodType | ParameterObject | ReferenceObject;
|
|
428
429
|
type ZodOpenApiHeaderObject = $ZodType | HeaderObject | ReferenceObject;
|
|
429
430
|
type ZodOpenApiSchemaObject = $ZodType | SchemaObject | ReferenceObject;
|
|
430
|
-
interface
|
|
431
|
+
interface ZodOpenApiSecuritySchemeObject extends SecuritySchemeObject {
|
|
432
|
+
/**
|
|
433
|
+
* Used to register this security scheme as a component.
|
|
434
|
+
*/
|
|
435
|
+
id?: string;
|
|
436
|
+
}
|
|
437
|
+
interface ZodOpenApiLinkObject extends LinkObject {
|
|
438
|
+
/** Use this field to auto register this link object as a component */
|
|
439
|
+
id?: string;
|
|
440
|
+
}
|
|
441
|
+
type ZodOpenApiLinksObject = Record<string, ZodOpenApiLinkObject | ReferenceObject>;
|
|
442
|
+
interface ZodOpenApiExampleObject extends ExampleObject {
|
|
443
|
+
/** Use this field to auto register this example object as a component */
|
|
444
|
+
id?: string;
|
|
445
|
+
}
|
|
446
|
+
type ZodOpenApiExamplesObject = Record<string, ZodOpenApiExampleObject | ReferenceObject>;
|
|
447
|
+
interface ZodOpenApiComponentsObject extends Omit<ComponentsObject, 'schemas' | 'responses' | 'requestBodies' | 'headers' | 'parameters' | 'pathItems' | 'callbacks' | 'securitySchemes' | 'examples'> {
|
|
431
448
|
parameters?: Record<string, ZodOpenApiParameterObject>;
|
|
432
449
|
schemas?: Record<string, ZodOpenApiSchemaObject>;
|
|
433
450
|
requestBodies?: Record<string, ZodOpenApiRequestBodyObject>;
|
|
@@ -435,6 +452,9 @@ interface ZodOpenApiComponentsObject extends Omit<ComponentsObject, 'schemas' |
|
|
|
435
452
|
responses?: Record<string, ZodOpenApiResponseObject>;
|
|
436
453
|
callbacks?: Record<string, ZodOpenApiCallbackObject>;
|
|
437
454
|
pathItems?: Record<string, ZodOpenApiPathItemObject>;
|
|
455
|
+
securitySchemes?: Record<string, ZodOpenApiSecuritySchemeObject>;
|
|
456
|
+
links?: Record<string, ZodOpenApiLinkObject>;
|
|
457
|
+
examples?: Record<string, ZodOpenApiExampleObject>;
|
|
438
458
|
}
|
|
439
459
|
type ZodOpenApiVersion = OpenApiVersion;
|
|
440
460
|
interface ZodOpenApiObject extends Omit<OpenAPIObject, 'openapi' | 'paths' | 'webhooks' | 'components'> {
|
|
@@ -553,6 +573,18 @@ interface ComponentRegistry {
|
|
|
553
573
|
ids: Map<string, PathItemObject | ReferenceObject>;
|
|
554
574
|
seen: WeakMap<ZodOpenApiPathItemObject, PathItemObject | ReferenceObject>;
|
|
555
575
|
};
|
|
576
|
+
securitySchemes: {
|
|
577
|
+
ids: Map<string, SecuritySchemeObject | ReferenceObject>;
|
|
578
|
+
seen: WeakMap<ZodOpenApiSecuritySchemeObject, SecuritySchemeObject | ReferenceObject>;
|
|
579
|
+
};
|
|
580
|
+
links: {
|
|
581
|
+
ids: Map<string, LinkObject | ReferenceObject>;
|
|
582
|
+
seen: WeakMap<ZodOpenApiLinkObject, LinkObject | ReferenceObject>;
|
|
583
|
+
};
|
|
584
|
+
examples: {
|
|
585
|
+
ids: Map<string, ExampleObject | ReferenceObject>;
|
|
586
|
+
seen: WeakMap<ZodOpenApiExampleObject, ExampleObject | ReferenceObject>;
|
|
587
|
+
};
|
|
556
588
|
};
|
|
557
589
|
addSchema: (schema: $ZodType, path: string[], opts: {
|
|
558
590
|
io: 'input' | 'output';
|
|
@@ -580,8 +612,17 @@ interface ComponentRegistry {
|
|
|
580
612
|
addCallback: (callback: ZodOpenApiCallbackObject, path: string[], opts?: {
|
|
581
613
|
manualId?: string;
|
|
582
614
|
}) => CallbackObject | ReferenceObject;
|
|
615
|
+
addSecurityScheme: (securityScheme: ZodOpenApiSecuritySchemeObject, path: string[], opts?: {
|
|
616
|
+
manualId?: string;
|
|
617
|
+
}) => SecuritySchemeObject | ReferenceObject;
|
|
618
|
+
addLink: (link: ZodOpenApiLinkObject, path: string[], opts?: {
|
|
619
|
+
manualId?: string;
|
|
620
|
+
}) => LinkObject | ReferenceObject;
|
|
621
|
+
addExample: (example: ZodOpenApiExampleObject, path: string[], opts?: {
|
|
622
|
+
manualId?: string;
|
|
623
|
+
}) => ExampleObject | ReferenceObject;
|
|
583
624
|
}
|
|
584
625
|
declare const createRegistry: (components?: ZodOpenApiComponentsObject) => ComponentRegistry;
|
|
585
626
|
declare const createComponents: (registry: ComponentRegistry, opts: CreateDocumentOptions) => ComponentsObject;
|
|
586
627
|
//#endregion
|
|
587
|
-
export { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, Override, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiVersion, createComponents, createDocument, createRegistry };
|
|
628
|
+
export { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, Override, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createComponents, createDocument, createRegistry };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, Override, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiVersion, createDocument } from "./components-
|
|
1
|
+
import { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, Override, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createDocument } from "./components-DkESnIB9.mjs";
|
|
2
2
|
import { core } from "zod/v4";
|
|
3
3
|
|
|
4
4
|
//#region rolldown:runtime
|
|
@@ -22,4 +22,4 @@ declare namespace oas31_d_exports {
|
|
|
22
22
|
export { BaseParameterObject, CallbackObject, CallbacksObject, ComponentsObject, ContactObject, ContentObject, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject };
|
|
23
23
|
}
|
|
24
24
|
//#endregion
|
|
25
|
-
export { CreateDocumentOptions, Override, SchemaResult, ZodObjectInput, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiVersion, createDocument, createSchema, oas31_d_exports as oas31 };
|
|
25
|
+
export { CreateDocumentOptions, Override, SchemaResult, ZodObjectInput, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createDocument, createSchema, oas31_d_exports as oas31 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, Override, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiVersion, createDocument } from "./components-
|
|
1
|
+
import { BaseParameterObject, CallbackObject, CallbacksObject, ComponentRegistry, ComponentsObject, ContactObject, ContentObject, CreateDocumentOptions, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, Override, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject, ZodObjectInput, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createDocument } from "./components-BLmIpmmY.js";
|
|
2
2
|
import { core } from "zod/v4";
|
|
3
3
|
|
|
4
4
|
//#region rolldown:runtime
|
|
@@ -22,4 +22,4 @@ declare namespace oas31_d_exports {
|
|
|
22
22
|
export { BaseParameterObject, CallbackObject, CallbacksObject, ComponentsObject, ContactObject, ContentObject, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, IExtensionName, IExtensionType, ISpecificationExtension, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, ServerObject, ServerVariableObject, TagObject, XmlObject };
|
|
23
23
|
}
|
|
24
24
|
//#endregion
|
|
25
|
-
export { CreateDocumentOptions, Override, SchemaResult, ZodObjectInput, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiVersion, createDocument, createSchema, oas31_d_exports as oas31 };
|
|
25
|
+
export { CreateDocumentOptions, Override, SchemaResult, ZodObjectInput, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiExampleObject, ZodOpenApiExamplesObject, ZodOpenApiHeaderObject, ZodOpenApiHeadersObject, ZodOpenApiLinkObject, ZodOpenApiLinksObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameterObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiSchemaObject, ZodOpenApiSecuritySchemeObject, ZodOpenApiVersion, createDocument, createSchema, oas31_d_exports as oas31 };
|
package/dist/index.js
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponents, createPaths, createRegistry, createSchema } from "./components-
|
|
1
|
+
import { createComponents, createPaths, createRegistry, createSchema } from "./components-Cblv9pY1.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/create/document.ts
|
|
4
4
|
const createDocument = (zodOpenApiObject, opts = {}) => {
|