zod-openapi 5.0.0-beta.5 → 5.0.0-beta.6
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 +71 -208
- package/api/index.d.ts +1 -1
- package/dist/api.d.mts +22 -3
- package/dist/api.d.ts +22 -3
- package/dist/api.js +8 -0
- package/dist/api.mjs +4 -8
- package/dist/components-5_CJdR73.d.ts +543 -0
- package/dist/components-CXjVnBr-.js +782 -0
- package/dist/components-CvutxtFV.mjs +741 -0
- package/dist/components-DAYTA1Um.d.mts +543 -0
- package/dist/create/componentsSideEffects.d.mts +6 -0
- package/dist/create/componentsSideEffects.d.ts +6 -0
- package/dist/create/componentsSideEffects.js +48 -0
- package/dist/create/componentsSideEffects.mjs +48 -0
- package/dist/index.d.mts +23 -7
- package/dist/index.d.ts +23 -7
- package/dist/index.js +20 -0
- package/dist/index.mjs +18 -59
- package/dist/zod-BvA30wad.mjs +5 -0
- package/dist/zod-i2t01GF0.js +40 -0
- package/package.json +14 -32
- package/dist/api.cjs +0 -8
- package/dist/components.chunk.cjs +0 -2463
- package/dist/components.chunk.mjs +0 -2464
- package/dist/create/components.d.ts +0 -125
- package/dist/create/content.d.ts +0 -8
- package/dist/create/document.d.ts +0 -91
- package/dist/create/parameters.d.ts +0 -9
- package/dist/create/schema/single.d.ts +0 -33
- package/dist/extend.cjs +0 -4
- package/dist/extend.d.mts +0 -1
- package/dist/extend.d.ts +0 -1
- package/dist/extend.mjs +0 -3
- package/dist/extendZod.chunk.cjs +0 -95
- package/dist/extendZod.chunk.mjs +0 -96
- package/dist/extendZod.d.ts +0 -6
- package/dist/extendZodSymbols.chunk.cjs +0 -5
- package/dist/extendZodSymbols.chunk.mjs +0 -6
- package/dist/extendZodSymbols.d.ts +0 -4
- package/dist/extendZodTypes.d.ts +0 -91
- package/dist/index.cjs +0 -60
- package/dist/openapi.d.ts +0 -5
- package/dist/openapi3-ts/dist/model/oas-common.d.ts +0 -16
- package/dist/openapi3-ts/dist/model/openapi30.d.ts +0 -291
- package/dist/openapi3-ts/dist/model/openapi31.d.ts +0 -298
- package/dist/openapi3-ts/dist/model/specification-extension.d.ts +0 -7
- package/dist/openapi3-ts/dist/oas30.d.ts +0 -3
- package/dist/openapi3-ts/dist/oas31.d.ts +0 -3
- package/extend/index.d.ts +0 -1
- package/extend/package.json +0 -5
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="zod-openapi.
|
|
2
|
+
<img src="zod-openapi.png" width="200px" align="center" alt="zod-openapi logo" />
|
|
3
3
|
<h1 align="center">zod-openapi</h1>
|
|
4
4
|
</p>
|
|
5
5
|
<p align="center">
|
|
6
|
-
A TypeScript library
|
|
6
|
+
A TypeScript library which uses <a href="https://github.com/colinhacks/zod">Zod</a> schemas to generate OpenAPI v3.x documentation.
|
|
7
7
|
</p>
|
|
8
8
|
<div align="center">
|
|
9
9
|
<a href="https://www.npmjs.com/package/zod-openapi"><img src="https://img.shields.io/npm/v/zod-openapi"/></a>
|
|
10
10
|
<a href="https://www.npmjs.com/package/zod-openapi"><img src="https://img.shields.io/npm/dm/zod-openapi"/></a>
|
|
11
|
-
<a href="https://nodejs.org/en/"><img src="https://img.shields.io/
|
|
11
|
+
<a href="https://nodejs.org/en/"><img src="https://img.shields.io/node/v/zod-openapi"/></a>
|
|
12
12
|
<a href="https://github.com/samchungy/zod-openapi/actions/workflows/test.yml"><img src="https://github.com/samchungy/zod-openapi/actions/workflows/test.yml/badge.svg"/></a>
|
|
13
13
|
<a href="https://github.com/samchungy/zod-openapi/actions/workflows/release.yml"><img src="https://github.com/samchungy/zod-openapi/actions/workflows/release.yml/badge.svg"/></a>
|
|
14
14
|
<a href="https://github.com/seek-oss/skuba"><img src="https://img.shields.io/badge/🤿%20skuba-powered-009DC4"/></a>
|
|
@@ -29,46 +29,18 @@ pnpm install zod zod-openapi
|
|
|
29
29
|
|
|
30
30
|
## Usage
|
|
31
31
|
|
|
32
|
-
###
|
|
32
|
+
### `.meta()`
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
Use the `.meta()` method to add metadata to a Zod schema. It accepts an object with the following options:
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
#### Manual Extension
|
|
46
|
-
|
|
47
|
-
This method is useful if you have a specific instance of Zod or a Zod instance from another library that you want to extend.
|
|
48
|
-
|
|
49
|
-
```typescript
|
|
50
|
-
import { z } from 'zod';
|
|
51
|
-
import { extendZodWithOpenApi } from 'zod-openapi';
|
|
52
|
-
|
|
53
|
-
extendZodWithOpenApi(z);
|
|
54
|
-
|
|
55
|
-
z.string().openapi({ description: 'Hello world!', example: 'hello world' });
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### `.openapi()`
|
|
59
|
-
|
|
60
|
-
Use the `.openapi()` method to add metadata to a Zod schema. It accepts an object with the following options:
|
|
61
|
-
|
|
62
|
-
| Option | Description |
|
|
63
|
-
| ----------------- | ------------------------------------------------------------------------------------------------------------------------- |
|
|
64
|
-
| `OpenAPI Options` | Accepts any option available for a [SchemaObject](https://swagger.io/docs/specification/data-models/data-types/). |
|
|
65
|
-
| `effectType` | Overrides the creation type for a [Zod Effect](#zod-effects). |
|
|
66
|
-
| `header` | Adds metadata for [response headers](#response-headers). |
|
|
67
|
-
| `param` | Adds metadata for [request parameters](#parameters). |
|
|
68
|
-
| `ref` | Registers a schema as a reusable OpenAPI component. |
|
|
69
|
-
| `refType` | Defines the creation type for a component not explicitly referenced in the document. |
|
|
70
|
-
| `type` | Overrides the generated type. If provided, no metadata will be generated. |
|
|
71
|
-
| `unionOneOf` | Forces a `oneOf` instead of `anyOf` for unions. See [CreateDocumentOptions](#CreateDocumentOptions) for a global setting. |
|
|
36
|
+
| Option | Description |
|
|
37
|
+
| ---------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
38
|
+
| `id` | Registers a schema as a reusable OpenAPI component. |
|
|
39
|
+
| `header` | Adds metadata for [response headers](#response-headers). |
|
|
40
|
+
| `param` | Adds metadata for [request parameters](#parameters). |
|
|
41
|
+
| `override` | Allows you to override the rendered OpenAPI schema. This takes either an object or a function |
|
|
42
|
+
| `outputId` | Allows you to set a different ID for the output schema. This is useful when the input and output schemas differ. |
|
|
43
|
+
| `unusedIO` | Allows you to set the `io` for an unused schema added to the components section. Defaults to `output` |
|
|
72
44
|
|
|
73
45
|
### `createDocument`
|
|
74
46
|
|
|
@@ -82,7 +54,7 @@ import { createDocument } from 'zod-openapi';
|
|
|
82
54
|
const jobId = z.string().openapi({
|
|
83
55
|
description: 'A unique identifier for a job',
|
|
84
56
|
example: '12345',
|
|
85
|
-
|
|
57
|
+
id: 'jobId',
|
|
86
58
|
});
|
|
87
59
|
|
|
88
60
|
const title = z.string().openapi({
|
|
@@ -204,9 +176,12 @@ const document = createDocument({
|
|
|
204
176
|
|
|
205
177
|
```typescript
|
|
206
178
|
const document = createDocument(details, {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
179
|
+
override: ({ jsonSchema, zodSchema }) => {
|
|
180
|
+
if (jsonSchema.anyOf) {
|
|
181
|
+
ctx.jsonSchema.oneOf = ctx.jsonSchema.anyOf;
|
|
182
|
+
delete ctx.jsonSchema.anyOf;
|
|
183
|
+
}
|
|
184
|
+
},
|
|
210
185
|
});
|
|
211
186
|
```
|
|
212
187
|
|
|
@@ -222,7 +197,7 @@ import { createSchema } from 'zod-openapi';
|
|
|
222
197
|
const jobId = z.string().openapi({
|
|
223
198
|
description: 'A unique identifier for a job',
|
|
224
199
|
example: '12345',
|
|
225
|
-
|
|
200
|
+
id: 'jobId',
|
|
226
201
|
});
|
|
227
202
|
|
|
228
203
|
const title = z.string().openapi({
|
|
@@ -424,7 +399,7 @@ If we take the example in `createDocument` and instead create `title` as follows
|
|
|
424
399
|
const title = z.string().openapi({
|
|
425
400
|
description: 'Job title',
|
|
426
401
|
example: 'My job',
|
|
427
|
-
|
|
402
|
+
id: 'jobTitle', // <- new field
|
|
428
403
|
});
|
|
429
404
|
```
|
|
430
405
|
|
|
@@ -472,30 +447,6 @@ createDocument({
|
|
|
472
447
|
});
|
|
473
448
|
```
|
|
474
449
|
|
|
475
|
-
Unfortunately, as a limitation of this library, you should attach an `.openapi()` field or `.describe()` to the schema that you are passing into the components or you will not reap the full benefits of component generation.
|
|
476
|
-
|
|
477
|
-
```ts
|
|
478
|
-
// ❌ Avoid this
|
|
479
|
-
const title = z.string();
|
|
480
|
-
|
|
481
|
-
// ✅ Recommended ways
|
|
482
|
-
const title = z.string().describe('Job title');
|
|
483
|
-
const title = z.string().openapi({
|
|
484
|
-
description: 'Job title',
|
|
485
|
-
example: 'My job',
|
|
486
|
-
});
|
|
487
|
-
|
|
488
|
-
createDocument({
|
|
489
|
-
components: {
|
|
490
|
-
schemas: {
|
|
491
|
-
jobTitle: title,
|
|
492
|
-
},
|
|
493
|
-
},
|
|
494
|
-
});
|
|
495
|
-
```
|
|
496
|
-
|
|
497
|
-
Overall, I recommend utilising the auto registering components over manual registration.
|
|
498
|
-
|
|
499
450
|
#### Parameters
|
|
500
451
|
|
|
501
452
|
Query, Path, Header & Cookie parameters can be similarly registered:
|
|
@@ -505,7 +456,7 @@ Query, Path, Header & Cookie parameters can be similarly registered:
|
|
|
505
456
|
const jobId = z.string().openapi({
|
|
506
457
|
description: 'Job ID',
|
|
507
458
|
example: '1234',
|
|
508
|
-
param: {
|
|
459
|
+
param: { id: 'jobRef' },
|
|
509
460
|
});
|
|
510
461
|
|
|
511
462
|
createDocument({
|
|
@@ -526,7 +477,7 @@ createDocument({
|
|
|
526
477
|
const jobId = z.string().openapi({
|
|
527
478
|
description: 'Job ID',
|
|
528
479
|
example: '1234',
|
|
529
|
-
param: { in: 'header', name: 'jobId',
|
|
480
|
+
param: { in: 'header', name: 'jobId', id: 'jobRef' },
|
|
530
481
|
});
|
|
531
482
|
|
|
532
483
|
createDocument({
|
|
@@ -563,7 +514,7 @@ Response headers can be similarly registered:
|
|
|
563
514
|
const header = z.string().openapi({
|
|
564
515
|
description: 'Job ID',
|
|
565
516
|
example: '1234',
|
|
566
|
-
header: {
|
|
517
|
+
header: { id: 'some-header' },
|
|
567
518
|
});
|
|
568
519
|
|
|
569
520
|
// or
|
|
@@ -594,7 +545,7 @@ const response: ZodOpenApiResponseObject = {
|
|
|
594
545
|
schema: z.object({ a: z.string() }),
|
|
595
546
|
},
|
|
596
547
|
},
|
|
597
|
-
|
|
548
|
+
id: 'some-response',
|
|
598
549
|
};
|
|
599
550
|
|
|
600
551
|
//or
|
|
@@ -623,7 +574,7 @@ Callbacks can also be registered
|
|
|
623
574
|
|
|
624
575
|
```typescript
|
|
625
576
|
const callback: ZodOpenApiCallbackObject = {
|
|
626
|
-
|
|
577
|
+
id: 'some-callback'
|
|
627
578
|
post: {
|
|
628
579
|
responses: {
|
|
629
580
|
200: {
|
|
@@ -664,99 +615,77 @@ createDocument({
|
|
|
664
615
|
});
|
|
665
616
|
```
|
|
666
617
|
|
|
667
|
-
### Zod
|
|
618
|
+
### Zod Types
|
|
619
|
+
|
|
620
|
+
Zod types are composed of two different parts: the input and the output. This library decides which type to create based on if it is used in a request or response context.
|
|
668
621
|
|
|
669
|
-
|
|
622
|
+
Input:
|
|
670
623
|
|
|
671
|
-
|
|
624
|
+
- Request Parameters (query, path, header, cookie)
|
|
625
|
+
- Request Body
|
|
672
626
|
|
|
673
|
-
|
|
627
|
+
Output:
|
|
674
628
|
|
|
675
|
-
|
|
629
|
+
- Response Body
|
|
630
|
+
- Response Headers
|
|
676
631
|
|
|
677
|
-
|
|
632
|
+
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()`.
|
|
678
633
|
|
|
679
634
|
```ts
|
|
680
|
-
z.object({
|
|
681
|
-
|
|
635
|
+
const schema = z.object({
|
|
636
|
+
name: z.string(),
|
|
682
637
|
});
|
|
683
638
|
```
|
|
684
639
|
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
```yaml
|
|
688
|
-
type: 'object'
|
|
689
|
-
properties:
|
|
690
|
-
- a:
|
|
691
|
-
type: 'string'
|
|
692
|
-
default: 'a'
|
|
693
|
-
```
|
|
694
|
-
|
|
695
|
-
or the following for a response:
|
|
696
|
-
|
|
697
|
-
```yaml
|
|
698
|
-
type: 'object'
|
|
699
|
-
properties:
|
|
700
|
-
- a:
|
|
701
|
-
type: 'string'
|
|
702
|
-
default: 'a'
|
|
703
|
-
required:
|
|
704
|
-
- a
|
|
705
|
-
```
|
|
706
|
-
|
|
707
|
-
Note how the response schema created an extra `required` field. This means, if you were to register a Zod schema with `.default()` as a component and use it in both a request or response, your schema would be invalid. Zod OpenAPI keeps track of this usage and will throw an error if this occurs.
|
|
708
|
-
|
|
709
|
-
#### EffectType
|
|
640
|
+
Input:
|
|
710
641
|
|
|
711
|
-
```
|
|
712
|
-
|
|
642
|
+
```json
|
|
643
|
+
{
|
|
644
|
+
"type": "object",
|
|
645
|
+
"properties": {
|
|
646
|
+
"name": {
|
|
647
|
+
"type": "string"
|
|
648
|
+
}
|
|
649
|
+
},
|
|
650
|
+
"required": ["name"]
|
|
651
|
+
}
|
|
713
652
|
```
|
|
714
653
|
|
|
715
|
-
|
|
654
|
+
Output:
|
|
716
655
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
656
|
+
```json
|
|
657
|
+
{
|
|
658
|
+
"type": "object",
|
|
659
|
+
"properties": {
|
|
660
|
+
"name": {
|
|
661
|
+
"type": "string"
|
|
662
|
+
}
|
|
663
|
+
},
|
|
664
|
+
"required": ["name"],
|
|
665
|
+
"additionalProperties": false
|
|
666
|
+
}
|
|
723
667
|
```
|
|
724
668
|
|
|
725
|
-
|
|
669
|
+
Unless you are strictly using `z.looseObject()`s or `z.strictObject()`s throughout your codebase you will likely run into issues where the input and output schemas differ. This library will do a best effort to check equality using a simple JSON.stringify() === JSON.stringify() check. If your registered schema contains dynamically created components, this will always fail.
|
|
726
670
|
|
|
727
|
-
|
|
728
|
-
z.string()
|
|
729
|
-
.transform((str) => str.length)
|
|
730
|
-
.openapi({ effectType: 'same' });
|
|
731
|
-
// ~~~~~~~~~~
|
|
732
|
-
// Type 'same' is not assignable to type 'CreationType | undefined'.ts(2322)
|
|
733
|
-
```
|
|
671
|
+
If the schemas are not equal, it will automatically handle this by outputting the `output` schema with an `Output` suffix.
|
|
734
672
|
|
|
735
|
-
|
|
673
|
+
You can override this by setting the `outputId` field with the `.meta()` method.
|
|
736
674
|
|
|
737
675
|
```ts
|
|
738
|
-
z
|
|
739
|
-
.
|
|
740
|
-
|
|
676
|
+
const schema = z
|
|
677
|
+
.object({
|
|
678
|
+
name: z.string(),
|
|
679
|
+
})
|
|
680
|
+
.meta({ id: 'MyObject', outputId: 'MyObjectResponse' });
|
|
741
681
|
```
|
|
742
682
|
|
|
743
|
-
#### Preprocess
|
|
744
|
-
|
|
745
|
-
`.preprocess()` will always return the `output` type even if we are creating an input schema. If a different input type is required you can achieve this with a `.transform()` combined with a `.pipe()` or simply declare a manual `type` in `.openapi()`.
|
|
746
|
-
|
|
747
|
-
#### Component Effects
|
|
748
|
-
|
|
749
|
-
If you are adding a ZodSchema directly to the `components` section which is not referenced anywhere in the document, additional context may be required to create either an input or output schema. You can do this by setting the `refType` field to `input` or `output` in `.openapi()`. This defaults to `output` by default.
|
|
750
|
-
|
|
751
683
|
## Supported OpenAPI Versions
|
|
752
684
|
|
|
753
685
|
Currently the following versions of OpenAPI are supported
|
|
754
686
|
|
|
755
|
-
- `3.0.0`
|
|
756
|
-
- `3.0.1`
|
|
757
|
-
- `3.0.2`
|
|
758
|
-
- `3.0.3`
|
|
759
687
|
- `3.1.0`
|
|
688
|
+
- `3.1.1`
|
|
760
689
|
|
|
761
690
|
Setting the `openapi` field will change how the some of the components are rendered.
|
|
762
691
|
|
|
@@ -785,72 +714,6 @@ As an example `z.string().nullable()` will be rendered differently
|
|
|
785
714
|
}
|
|
786
715
|
```
|
|
787
716
|
|
|
788
|
-
## Supported Zod Schema
|
|
789
|
-
|
|
790
|
-
- ZodAny
|
|
791
|
-
- ZodArray
|
|
792
|
-
- `minItems`/`maxItems` mapping for `.length()`, `.min()`, `.max()`
|
|
793
|
-
- ZodBigInt
|
|
794
|
-
- `integer` `type` and `int64` `format` mapping
|
|
795
|
-
- ZodBoolean
|
|
796
|
-
- ZodBranded
|
|
797
|
-
- ZodCatch
|
|
798
|
-
- Treated as ZodDefault
|
|
799
|
-
- ZodCustom
|
|
800
|
-
- ZodDate
|
|
801
|
-
- `type` is mapped as `string` by default
|
|
802
|
-
- ZodDefault
|
|
803
|
-
- ZodDiscriminatedUnion
|
|
804
|
-
- `discriminator` mapping when all schemas in the union are [registered](#creating-components). The discriminator must be a `ZodLiteral`, `ZodEnum` or `ZodNativeEnum` with string values. Only values wrapped in `ZodBranded`, `ZodReadOnly` and `ZodCatch` are supported.
|
|
805
|
-
- ZodEffects
|
|
806
|
-
- `transform` support for request schemas. See [Zod Effects](#zod-effects) for how to enable response schema support
|
|
807
|
-
- `pre-process` support. We assume that the input type is the same as the output type. Otherwise pipe and transform can be used instead.
|
|
808
|
-
- `refine` full support
|
|
809
|
-
- ZodEnum
|
|
810
|
-
- ZodIntersection
|
|
811
|
-
- ZodLazy
|
|
812
|
-
- The recursive schema within the ZodLazy or the ZodLazy _**must**_ be registered as a component. See [Creating Components](#creating-components) for more information.
|
|
813
|
-
- ZodLiteral
|
|
814
|
-
- ZodNativeEnum
|
|
815
|
-
- supporting `string`, `number` and combined enums.
|
|
816
|
-
- ZodNever
|
|
817
|
-
- ZodNull
|
|
818
|
-
- ZodNullable
|
|
819
|
-
- ZodNumber
|
|
820
|
-
- `integer` `type` mapping for `.int()`
|
|
821
|
-
- `exclusiveMin`/`min`/`exclusiveMax`/`max` mapping for `.min()`, `.max()`, `lt()`, `gt()`, `.positive()`, `.negative()`, `.nonnegative()`, `.nonpositive()`.
|
|
822
|
-
- `multipleOf` mapping for `.multipleOf()`
|
|
823
|
-
- ZodObject
|
|
824
|
-
- `additionalProperties` mapping for `.catchall()`, `.strict()`
|
|
825
|
-
- `allOf` mapping for `.extend()` when the base object is registered and does not have `catchall()`, `strict()` and extension does not override a field.
|
|
826
|
-
- ZodOptional
|
|
827
|
-
- ZodPipeline
|
|
828
|
-
- See [Zod Effects](#zod-effects) for more information.
|
|
829
|
-
- ZodReadonly
|
|
830
|
-
- ZodRecord
|
|
831
|
-
- ZodSet
|
|
832
|
-
- Treated as an array with `uniqueItems` (you may need to add a pre-process to convert it to a set)
|
|
833
|
-
- ZodString
|
|
834
|
-
- `format` mapping for `.url()`, `.uuid()`, `.email()`, `.datetime()`, `.date()`, `.time()`, `.duration()`, `.ip({ version: 'v4' })`, `.ip({ version: 'v6' })`, `.cidr({ version: 'v4' })`, `.cidr({ version: 'v6' })`
|
|
835
|
-
- `minLength`/`maxLength` mapping for `.length()`, `.min()`, `.max()`
|
|
836
|
-
- `pattern` mapping for `.regex()`, `.startsWith()`, `.endsWith()`, `.includes()`
|
|
837
|
-
- `contentEncoding` mapping for `.base64()` for OpenAPI 3.1.0+
|
|
838
|
-
- ZodTuple
|
|
839
|
-
- `items` mapping for `.rest()`
|
|
840
|
-
- `prefixItems` mapping for OpenAPI 3.1.0+
|
|
841
|
-
- ZodUndefined
|
|
842
|
-
- ZodUnion
|
|
843
|
-
- By default it outputs an `anyOf` schema. Use `unionOneOf` to change this to output `oneOf` instead.
|
|
844
|
-
- ZodUnknown
|
|
845
|
-
|
|
846
|
-
If this library cannot determine a type for a Zod Schema, it will throw an error. To avoid this, declare a manual `type` in the `.openapi()` section of that schema.
|
|
847
|
-
|
|
848
|
-
eg.
|
|
849
|
-
|
|
850
|
-
```typescript
|
|
851
|
-
z.custom().openapi({ type: 'string' });
|
|
852
|
-
```
|
|
853
|
-
|
|
854
717
|
## Examples
|
|
855
718
|
|
|
856
719
|
See the library in use in the [examples](./examples/) folder.
|
package/api/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from '../dist/api';
|
package/dist/api.d.mts
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ComponentRegistry, MediaTypeObject, Override, ParameterLocation, ParameterObject, ReferenceObject, ZodOpenApiMediaTypeObject, createComponents, createRegistry, isAnyZodType } from "./components-DAYTA1Um.mjs";
|
|
2
|
+
import { $ZodObject, $ZodType, $ZodTypes } from "zod/v4/core";
|
|
3
|
+
|
|
4
|
+
//#region src/create/content.d.ts
|
|
5
|
+
declare const createMediaTypeObject: (mediaTypeObject: ZodOpenApiMediaTypeObject, ctx: {
|
|
6
|
+
registry: ComponentRegistry;
|
|
7
|
+
io: "input" | "output";
|
|
8
|
+
}, path: string[]) => MediaTypeObject;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/create/parameters.d.ts
|
|
11
|
+
declare const createParameter: (parameter: $ZodType, location: {
|
|
12
|
+
in: ParameterLocation;
|
|
13
|
+
name: string;
|
|
14
|
+
} | undefined, ctx: {
|
|
15
|
+
registry: ComponentRegistry;
|
|
16
|
+
io: "input" | "output";
|
|
17
|
+
}, path: string[]) => ParameterObject | ReferenceObject;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/create/object.d.ts
|
|
20
|
+
declare const unwrapZodObject: (zodType: $ZodTypes, io: "input" | "output", path: string[]) => $ZodObject;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Override, createComponents, createMediaTypeObject, createParameter, createRegistry, isAnyZodType, unwrapZodObject };
|
package/dist/api.d.ts
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ComponentRegistry, MediaTypeObject, Override, ParameterLocation, ParameterObject, ReferenceObject, ZodOpenApiMediaTypeObject, createComponents, createRegistry, isAnyZodType } from "./components-5_CJdR73.js";
|
|
2
|
+
import { $ZodObject, $ZodType, $ZodTypes } from "zod/v4/core";
|
|
3
|
+
|
|
4
|
+
//#region src/create/content.d.ts
|
|
5
|
+
declare const createMediaTypeObject: (mediaTypeObject: ZodOpenApiMediaTypeObject, ctx: {
|
|
6
|
+
registry: ComponentRegistry;
|
|
7
|
+
io: "input" | "output";
|
|
8
|
+
}, path: string[]) => MediaTypeObject;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/create/parameters.d.ts
|
|
11
|
+
declare const createParameter: (parameter: $ZodType, location: {
|
|
12
|
+
in: ParameterLocation;
|
|
13
|
+
name: string;
|
|
14
|
+
} | undefined, ctx: {
|
|
15
|
+
registry: ComponentRegistry;
|
|
16
|
+
io: "input" | "output";
|
|
17
|
+
}, path: string[]) => ParameterObject | ReferenceObject;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/create/object.d.ts
|
|
20
|
+
declare const unwrapZodObject: (zodType: $ZodTypes, io: "input" | "output", path: string[]) => $ZodObject;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { Override, createComponents, createMediaTypeObject, createParameter, createRegistry, isAnyZodType, unwrapZodObject };
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
require('./zod-i2t01GF0.js');
|
|
2
|
+
const require_components = require('./components-CXjVnBr-.js');
|
|
3
|
+
|
|
4
|
+
exports.createComponents = require_components.createComponents;
|
|
5
|
+
exports.createMediaTypeObject = require_components.createMediaTypeObject;
|
|
6
|
+
exports.createParameter = require_components.createParameter;
|
|
7
|
+
exports.createRegistry = require_components.createRegistry;
|
|
8
|
+
exports.unwrapZodObject = require_components.unwrapZodObject;
|
package/dist/api.mjs
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
createParamOrRef,
|
|
6
|
-
getDefaultComponents,
|
|
7
|
-
getZodObject
|
|
8
|
-
};
|
|
1
|
+
import "./zod-BvA30wad.mjs";
|
|
2
|
+
import { createComponents, createMediaTypeObject, createParameter, createRegistry, unwrapZodObject } from "./components-CvutxtFV.mjs";
|
|
3
|
+
|
|
4
|
+
export { createComponents, createMediaTypeObject, createParameter, createRegistry, unwrapZodObject };
|