zod-openapi 5.0.0-beta.4 → 5.0.0-beta.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/README.md +208 -71
- package/api/index.d.ts +1 -0
- package/api/package.json +5 -0
- package/dist/api.cjs +8 -0
- package/dist/api.d.mts +3 -22
- package/dist/api.d.ts +3 -22
- package/dist/api.mjs +8 -4
- package/dist/components.chunk.cjs +2463 -0
- package/dist/components.chunk.mjs +2464 -0
- package/dist/create/components.d.ts +125 -0
- package/dist/create/content.d.ts +8 -0
- package/dist/create/document.d.ts +91 -0
- package/dist/create/parameters.d.ts +9 -0
- package/dist/create/schema/single.d.ts +33 -0
- package/dist/extend.cjs +4 -0
- package/dist/extend.d.mts +1 -0
- package/dist/extend.d.ts +1 -0
- package/dist/extend.mjs +3 -0
- package/dist/extendZod.chunk.cjs +95 -0
- package/dist/extendZod.chunk.mjs +96 -0
- package/dist/extendZod.d.ts +6 -0
- package/dist/extendZodSymbols.chunk.cjs +5 -0
- package/dist/extendZodSymbols.chunk.mjs +6 -0
- package/dist/extendZodSymbols.d.ts +4 -0
- package/dist/extendZodTypes.d.ts +91 -0
- package/dist/index.cjs +60 -0
- package/dist/index.d.mts +7 -23
- package/dist/index.d.ts +7 -23
- package/dist/index.mjs +59 -18
- package/dist/openapi.d.ts +5 -0
- package/dist/openapi3-ts/dist/model/oas-common.d.ts +16 -0
- package/dist/openapi3-ts/dist/model/openapi30.d.ts +291 -0
- package/dist/openapi3-ts/dist/model/openapi31.d.ts +298 -0
- package/dist/openapi3-ts/dist/model/specification-extension.d.ts +7 -0
- package/dist/openapi3-ts/dist/oas30.d.ts +3 -0
- package/dist/openapi3-ts/dist/oas31.d.ts +3 -0
- package/extend/index.d.ts +1 -0
- package/extend/package.json +5 -0
- package/package.json +30 -13
- package/dist/api.js +0 -8
- package/dist/components-5_CJdR73.d.ts +0 -543
- package/dist/components-CXjVnBr-.js +0 -782
- package/dist/components-CvutxtFV.mjs +0 -741
- package/dist/components-DAYTA1Um.d.mts +0 -543
- package/dist/create/componentsSideEffects.d.mts +0 -6
- package/dist/create/componentsSideEffects.d.ts +0 -6
- package/dist/create/componentsSideEffects.js +0 -48
- package/dist/create/componentsSideEffects.mjs +0 -48
- package/dist/index.js +0 -20
- package/dist/zod-BvA30wad.mjs +0 -5
- package/dist/zod-i2t01GF0.js +0 -40
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="zod-openapi.
|
|
2
|
+
<img src="zod-openapi.svg" 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 for using <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/node
|
|
11
|
+
<a href="https://nodejs.org/en/"><img src="https://img.shields.io/badge/node-%3E%3D%2018-brightgreen"/></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,18 +29,46 @@ pnpm install zod zod-openapi
|
|
|
29
29
|
|
|
30
30
|
## Usage
|
|
31
31
|
|
|
32
|
-
###
|
|
32
|
+
### Extending Zod
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
This package extends Zod by adding an `.openapi()` method. Call this at the top of your entry point(s). You can apply this extension in two ways:
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
#### Subpath Import
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import 'zod-openapi/extend';
|
|
40
|
+
import { z } from 'zod';
|
|
41
|
+
|
|
42
|
+
z.string().openapi({ description: 'Hello world!', example: 'Hello world' });
|
|
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. |
|
|
44
72
|
|
|
45
73
|
### `createDocument`
|
|
46
74
|
|
|
@@ -54,7 +82,7 @@ import { createDocument } from 'zod-openapi';
|
|
|
54
82
|
const jobId = z.string().openapi({
|
|
55
83
|
description: 'A unique identifier for a job',
|
|
56
84
|
example: '12345',
|
|
57
|
-
|
|
85
|
+
ref: 'jobId',
|
|
58
86
|
});
|
|
59
87
|
|
|
60
88
|
const title = z.string().openapi({
|
|
@@ -176,12 +204,9 @@ const document = createDocument({
|
|
|
176
204
|
|
|
177
205
|
```typescript
|
|
178
206
|
const document = createDocument(details, {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
delete ctx.jsonSchema.anyOf;
|
|
183
|
-
}
|
|
184
|
-
},
|
|
207
|
+
defaultDateSchema: { type: 'string', format: 'date-time' }, // defaults to { type: 'string' }
|
|
208
|
+
unionOneOf: true, // defaults to false. Forces all ZodUnions to output oneOf instead of anyOf. An `.openapi()` `unionOneOf` value takes precedence over this one.
|
|
209
|
+
enforceDiscriminatedUnionComponents: true, // defaults to false. Throws an error if a Discriminated Union member is not registered as a component.
|
|
185
210
|
});
|
|
186
211
|
```
|
|
187
212
|
|
|
@@ -197,7 +222,7 @@ import { createSchema } from 'zod-openapi';
|
|
|
197
222
|
const jobId = z.string().openapi({
|
|
198
223
|
description: 'A unique identifier for a job',
|
|
199
224
|
example: '12345',
|
|
200
|
-
|
|
225
|
+
ref: 'jobId',
|
|
201
226
|
});
|
|
202
227
|
|
|
203
228
|
const title = z.string().openapi({
|
|
@@ -399,7 +424,7 @@ If we take the example in `createDocument` and instead create `title` as follows
|
|
|
399
424
|
const title = z.string().openapi({
|
|
400
425
|
description: 'Job title',
|
|
401
426
|
example: 'My job',
|
|
402
|
-
|
|
427
|
+
ref: 'jobTitle', // <- new field
|
|
403
428
|
});
|
|
404
429
|
```
|
|
405
430
|
|
|
@@ -447,6 +472,30 @@ createDocument({
|
|
|
447
472
|
});
|
|
448
473
|
```
|
|
449
474
|
|
|
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
|
+
|
|
450
499
|
#### Parameters
|
|
451
500
|
|
|
452
501
|
Query, Path, Header & Cookie parameters can be similarly registered:
|
|
@@ -456,7 +505,7 @@ Query, Path, Header & Cookie parameters can be similarly registered:
|
|
|
456
505
|
const jobId = z.string().openapi({
|
|
457
506
|
description: 'Job ID',
|
|
458
507
|
example: '1234',
|
|
459
|
-
param: {
|
|
508
|
+
param: { ref: 'jobRef' },
|
|
460
509
|
});
|
|
461
510
|
|
|
462
511
|
createDocument({
|
|
@@ -477,7 +526,7 @@ createDocument({
|
|
|
477
526
|
const jobId = z.string().openapi({
|
|
478
527
|
description: 'Job ID',
|
|
479
528
|
example: '1234',
|
|
480
|
-
param: { in: 'header', name: 'jobId',
|
|
529
|
+
param: { in: 'header', name: 'jobId', ref: 'jobRef' },
|
|
481
530
|
});
|
|
482
531
|
|
|
483
532
|
createDocument({
|
|
@@ -514,7 +563,7 @@ Response headers can be similarly registered:
|
|
|
514
563
|
const header = z.string().openapi({
|
|
515
564
|
description: 'Job ID',
|
|
516
565
|
example: '1234',
|
|
517
|
-
header: {
|
|
566
|
+
header: { ref: 'some-header' },
|
|
518
567
|
});
|
|
519
568
|
|
|
520
569
|
// or
|
|
@@ -545,7 +594,7 @@ const response: ZodOpenApiResponseObject = {
|
|
|
545
594
|
schema: z.object({ a: z.string() }),
|
|
546
595
|
},
|
|
547
596
|
},
|
|
548
|
-
|
|
597
|
+
ref: 'some-response',
|
|
549
598
|
};
|
|
550
599
|
|
|
551
600
|
//or
|
|
@@ -574,7 +623,7 @@ Callbacks can also be registered
|
|
|
574
623
|
|
|
575
624
|
```typescript
|
|
576
625
|
const callback: ZodOpenApiCallbackObject = {
|
|
577
|
-
|
|
626
|
+
ref: 'some-callback'
|
|
578
627
|
post: {
|
|
579
628
|
responses: {
|
|
580
629
|
200: {
|
|
@@ -615,77 +664,99 @@ createDocument({
|
|
|
615
664
|
});
|
|
616
665
|
```
|
|
617
666
|
|
|
618
|
-
### Zod
|
|
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.
|
|
667
|
+
### Zod Effects
|
|
621
668
|
|
|
622
|
-
|
|
669
|
+
`.transform()`, `.catch()`, `.default()` and `.pipe()` are complicated because they all comprise of two different types that we could generate (input & output).
|
|
623
670
|
|
|
624
|
-
|
|
625
|
-
- Request Body
|
|
671
|
+
We attempt to determine what type of schema to create based on the following contexts:
|
|
626
672
|
|
|
627
|
-
|
|
673
|
+
_Input_: Request Bodies, Request Parameters, Headers
|
|
628
674
|
|
|
629
|
-
|
|
630
|
-
- Response Headers
|
|
675
|
+
_Output_: Responses, Response Headers
|
|
631
676
|
|
|
632
|
-
|
|
677
|
+
As an example:
|
|
633
678
|
|
|
634
679
|
```ts
|
|
635
|
-
|
|
636
|
-
|
|
680
|
+
z.object({
|
|
681
|
+
a: z.string().default('a'),
|
|
637
682
|
});
|
|
638
683
|
```
|
|
639
684
|
|
|
640
|
-
|
|
685
|
+
In a request context, this would render the following OpenAPI schema:
|
|
641
686
|
|
|
642
|
-
```
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
}
|
|
649
|
-
},
|
|
650
|
-
"required": ["name"]
|
|
651
|
-
}
|
|
687
|
+
```yaml
|
|
688
|
+
type: 'object'
|
|
689
|
+
properties:
|
|
690
|
+
- a:
|
|
691
|
+
type: 'string'
|
|
692
|
+
default: 'a'
|
|
652
693
|
```
|
|
653
694
|
|
|
654
|
-
|
|
695
|
+
or the following for a response:
|
|
655
696
|
|
|
656
|
-
```
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
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
|
|
710
|
+
|
|
711
|
+
```ts
|
|
712
|
+
z.string().transform((str) => str.trim());
|
|
667
713
|
```
|
|
668
714
|
|
|
669
|
-
|
|
715
|
+
Whilst the TypeScript compiler can understand that the result is still a `string`, unfortunately we cannot introspect this as your transform function may be far more complicated than this example. To address this, you can set the `effectType` on the schema to `same`, `input` or `output`.
|
|
670
716
|
|
|
671
|
-
|
|
717
|
+
`same` - This informs Zod OpenAPI to pick either the input schema or output schema to generate with because they should be the same.
|
|
672
718
|
|
|
673
|
-
|
|
719
|
+
```ts
|
|
720
|
+
z.string()
|
|
721
|
+
.transform((str) => str.trim())
|
|
722
|
+
.openapi({ effectType: 'same' });
|
|
723
|
+
```
|
|
724
|
+
|
|
725
|
+
If the transform were to drift from this, you will receive a TypeScript error:
|
|
674
726
|
|
|
675
727
|
```ts
|
|
676
|
-
|
|
677
|
-
.
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
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)
|
|
681
733
|
```
|
|
682
734
|
|
|
735
|
+
`input` or `output` - This tells Zod OpenAPI to pick a specific schema to create whenever we run into this schema, regardless of it is a request or response schema.
|
|
736
|
+
|
|
737
|
+
```ts
|
|
738
|
+
z.string()
|
|
739
|
+
.transform((str) => str.length)
|
|
740
|
+
.openapi({ effectType: 'input' });
|
|
741
|
+
```
|
|
742
|
+
|
|
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
|
+
|
|
683
751
|
## Supported OpenAPI Versions
|
|
684
752
|
|
|
685
753
|
Currently the following versions of OpenAPI are supported
|
|
686
754
|
|
|
755
|
+
- `3.0.0`
|
|
756
|
+
- `3.0.1`
|
|
757
|
+
- `3.0.2`
|
|
758
|
+
- `3.0.3`
|
|
687
759
|
- `3.1.0`
|
|
688
|
-
- `3.1.1`
|
|
689
760
|
|
|
690
761
|
Setting the `openapi` field will change how the some of the components are rendered.
|
|
691
762
|
|
|
@@ -714,6 +785,72 @@ As an example `z.string().nullable()` will be rendered differently
|
|
|
714
785
|
}
|
|
715
786
|
```
|
|
716
787
|
|
|
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
|
+
|
|
717
854
|
## Examples
|
|
718
855
|
|
|
719
856
|
See the library in use in the [examples](./examples/) folder.
|
package/api/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../dist/api";
|
package/api/package.json
ADDED
package/dist/api.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const components = require("./components.chunk.cjs");
|
|
4
|
+
exports.createComponents = components.createComponents;
|
|
5
|
+
exports.createMediaTypeSchema = components.createMediaTypeSchema;
|
|
6
|
+
exports.createParamOrRef = components.createParamOrRef;
|
|
7
|
+
exports.getDefaultComponents = components.getDefaultComponents;
|
|
8
|
+
exports.getZodObject = components.getZodObject;
|
package/dist/api.d.mts
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 };
|
|
1
|
+
export { ComponentsObject, createComponents, getDefaultComponents } from './create/components.js';
|
|
2
|
+
export { createMediaTypeSchema } from './create/content.js';
|
|
3
|
+
export { createParamOrRef, getZodObject } from './create/parameters.js';
|
package/dist/api.d.ts
CHANGED
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 };
|
|
1
|
+
export { ComponentsObject, createComponents, getDefaultComponents } from './create/components.js';
|
|
2
|
+
export { createMediaTypeSchema } from './create/content.js';
|
|
3
|
+
export { createParamOrRef, getZodObject } from './create/parameters.js';
|
package/dist/api.mjs
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { createComponents, createMediaTypeSchema, createParamOrRef, getDefaultComponents, getZodObject } from "./components.chunk.mjs";
|
|
2
|
+
export {
|
|
3
|
+
createComponents,
|
|
4
|
+
createMediaTypeSchema,
|
|
5
|
+
createParamOrRef,
|
|
6
|
+
getDefaultComponents,
|
|
7
|
+
getZodObject
|
|
8
|
+
};
|