zod-openapi 2.1.0 → 2.2.0

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.
Files changed (103) hide show
  1. package/README.md +4 -0
  2. package/lib-commonjs/create/components.js.map +1 -1
  3. package/lib-commonjs/create/content.js.map +1 -1
  4. package/lib-commonjs/create/paths.js.map +1 -1
  5. package/lib-commonjs/create/responses.js.map +1 -1
  6. package/lib-commonjs/create/schema/array.js.map +1 -1
  7. package/lib-commonjs/create/schema/brand.js +7 -0
  8. package/lib-commonjs/create/schema/brand.js.map +1 -0
  9. package/lib-commonjs/create/schema/catch.js.map +1 -1
  10. package/lib-commonjs/create/schema/default.js.map +1 -1
  11. package/lib-commonjs/create/schema/discriminatedUnion.js.map +1 -1
  12. package/lib-commonjs/create/schema/index.js +8 -0
  13. package/lib-commonjs/create/schema/index.js.map +1 -1
  14. package/lib-commonjs/create/schema/intersection.js.map +1 -1
  15. package/lib-commonjs/create/schema/lazy.js +24 -0
  16. package/lib-commonjs/create/schema/lazy.js.map +1 -0
  17. package/lib-commonjs/create/schema/manual.js.map +1 -1
  18. package/lib-commonjs/create/schema/metadata.js.map +1 -1
  19. package/lib-commonjs/create/schema/nullable.js +3 -0
  20. package/lib-commonjs/create/schema/nullable.js.map +1 -1
  21. package/lib-commonjs/create/schema/object.js +63 -12
  22. package/lib-commonjs/create/schema/object.js.map +1 -1
  23. package/lib-commonjs/create/schema/optional.js.map +1 -1
  24. package/lib-commonjs/create/schema/pipeline.js.map +1 -1
  25. package/lib-commonjs/create/schema/preprocess.js.map +1 -1
  26. package/lib-commonjs/create/schema/record.js.map +1 -1
  27. package/lib-commonjs/create/schema/refine.js.map +1 -1
  28. package/lib-commonjs/create/schema/transform.js.map +1 -1
  29. package/lib-commonjs/create/schema/tuple.js.map +1 -1
  30. package/lib-commonjs/create/schema/union.js.map +1 -1
  31. package/lib-commonjs/extendZod.js +0 -1
  32. package/lib-commonjs/extendZod.js.map +1 -1
  33. package/lib-es2015/create/components.js.map +1 -1
  34. package/lib-es2015/create/content.js.map +1 -1
  35. package/lib-es2015/create/paths.js +1 -1
  36. package/lib-es2015/create/paths.js.map +1 -1
  37. package/lib-es2015/create/responses.js +1 -1
  38. package/lib-es2015/create/responses.js.map +1 -1
  39. package/lib-es2015/create/schema/array.js.map +1 -1
  40. package/lib-es2015/create/schema/brand.js +3 -0
  41. package/lib-es2015/create/schema/brand.js.map +1 -0
  42. package/lib-es2015/create/schema/catch.js.map +1 -1
  43. package/lib-es2015/create/schema/default.js.map +1 -1
  44. package/lib-es2015/create/schema/discriminatedUnion.js.map +1 -1
  45. package/lib-es2015/create/schema/index.js +9 -1
  46. package/lib-es2015/create/schema/index.js.map +1 -1
  47. package/lib-es2015/create/schema/intersection.js.map +1 -1
  48. package/lib-es2015/create/schema/lazy.js +20 -0
  49. package/lib-es2015/create/schema/lazy.js.map +1 -0
  50. package/lib-es2015/create/schema/manual.js.map +1 -1
  51. package/lib-es2015/create/schema/metadata.js.map +1 -1
  52. package/lib-es2015/create/schema/nullable.js +3 -0
  53. package/lib-es2015/create/schema/nullable.js.map +1 -1
  54. package/lib-es2015/create/schema/object.js +63 -12
  55. package/lib-es2015/create/schema/object.js.map +1 -1
  56. package/lib-es2015/create/schema/optional.js.map +1 -1
  57. package/lib-es2015/create/schema/pipeline.js.map +1 -1
  58. package/lib-es2015/create/schema/preprocess.js.map +1 -1
  59. package/lib-es2015/create/schema/record.js.map +1 -1
  60. package/lib-es2015/create/schema/refine.js.map +1 -1
  61. package/lib-es2015/create/schema/transform.js.map +1 -1
  62. package/lib-es2015/create/schema/tuple.js.map +1 -1
  63. package/lib-es2015/create/schema/union.js.map +1 -1
  64. package/lib-es2015/extendZod.js +0 -1
  65. package/lib-es2015/extendZod.js.map +1 -1
  66. package/lib-types/create/components.d.ts +3 -3
  67. package/lib-types/create/content.d.ts +3 -3
  68. package/lib-types/create/document.d.ts +3 -3
  69. package/lib-types/create/errors.d.ts +1 -1
  70. package/lib-types/create/parameters.d.ts +4 -4
  71. package/lib-types/create/paths.d.ts +3 -3
  72. package/lib-types/create/responses.d.ts +4 -4
  73. package/lib-types/create/schema/array.d.ts +3 -3
  74. package/lib-types/create/schema/boolean.d.ts +2 -2
  75. package/lib-types/create/schema/brand.d.ts +4 -0
  76. package/lib-types/create/schema/catch.d.ts +3 -3
  77. package/lib-types/create/schema/date.d.ts +2 -2
  78. package/lib-types/create/schema/default.d.ts +3 -3
  79. package/lib-types/create/schema/discriminatedUnion.d.ts +3 -3
  80. package/lib-types/create/schema/enum.d.ts +2 -2
  81. package/lib-types/create/schema/index.d.ts +3 -3
  82. package/lib-types/create/schema/intersection.d.ts +3 -3
  83. package/lib-types/create/schema/lazy.d.ts +4 -0
  84. package/lib-types/create/schema/literal.d.ts +2 -2
  85. package/lib-types/create/schema/manual.d.ts +2 -2
  86. package/lib-types/create/schema/metadata.d.ts +3 -3
  87. package/lib-types/create/schema/nativeEnum.d.ts +3 -3
  88. package/lib-types/create/schema/null.d.ts +2 -2
  89. package/lib-types/create/schema/nullable.d.ts +3 -3
  90. package/lib-types/create/schema/number.d.ts +4 -4
  91. package/lib-types/create/schema/object.d.ts +10 -5
  92. package/lib-types/create/schema/optional.d.ts +3 -3
  93. package/lib-types/create/schema/pipeline.d.ts +3 -3
  94. package/lib-types/create/schema/preprocess.d.ts +3 -3
  95. package/lib-types/create/schema/record.d.ts +3 -3
  96. package/lib-types/create/schema/refine.d.ts +3 -3
  97. package/lib-types/create/schema/string.d.ts +2 -2
  98. package/lib-types/create/schema/transform.d.ts +3 -3
  99. package/lib-types/create/schema/tuple.d.ts +3 -3
  100. package/lib-types/create/schema/union.d.ts +3 -3
  101. package/lib-types/create/schema/unknown.d.ts +2 -2
  102. package/lib-types/extendZod.d.ts +4 -5
  103. package/package.json +2 -2
@@ -1,3 +1,3 @@
1
- import { ZodNull } from 'zod';
2
- import { oas31 } from '../../openapi3-ts/dist';
1
+ import type { ZodNull } from 'zod';
2
+ import type { oas31 } from '../../openapi3-ts/dist';
3
3
  export declare const createNullSchema: (_zodNull: ZodNull) => oas31.SchemaObject;
@@ -1,4 +1,4 @@
1
- import { ZodNullable } from 'zod';
2
- import { oas31 } from '../../openapi3-ts/dist';
3
- import { SchemaState } from '.';
1
+ import type { ZodNullable } from 'zod';
2
+ import type { oas31 } from '../../openapi3-ts/dist';
3
+ import { type SchemaState } from '.';
4
4
  export declare const createNullableSchema: (zodNullable: ZodNullable<any>, state: SchemaState) => oas31.SchemaObject;
@@ -1,7 +1,7 @@
1
- import { ZodNumber, ZodNumberCheck } from 'zod';
2
- import { oas30, oas31 } from '../../openapi3-ts/dist';
3
- import { ZodOpenApiVersion } from '../document';
4
- import { SchemaState } from '.';
1
+ import type { ZodNumber, ZodNumberCheck } from 'zod';
2
+ import type { oas30, oas31 } from '../../openapi3-ts/dist';
3
+ import type { ZodOpenApiVersion } from '../document';
4
+ import type { SchemaState } from '.';
5
5
  export declare const createNumberSchema: (zodNumber: ZodNumber, state: SchemaState) => oas31.SchemaObject;
6
6
  export declare const mapNumberChecks: () => void;
7
7
  export declare const mapMaximum: (zodNumberCheck: ZodNumberCheckMap, openapi: ZodOpenApiVersion) => Pick<oas31.SchemaObject | oas30.SchemaObject, 'maximum' | 'exclusiveMaximum'> | undefined;
@@ -1,8 +1,13 @@
1
- import { UnknownKeysParam, ZodObject, ZodRawShape } from 'zod';
2
- import { oas31 } from '../../openapi3-ts/dist';
3
- import { SchemaState } from '.';
1
+ import { type UnknownKeysParam, type ZodObject, type ZodRawShape, type ZodType } from 'zod';
2
+ import type { oas31 } from '../../openapi3-ts/dist';
3
+ import { type SchemaState } from '.';
4
4
  export declare const createObjectSchema: <T extends ZodRawShape, UnknownKeys extends UnknownKeysParam = UnknownKeysParam>(zodObject: ZodObject<T, UnknownKeys, any, any, any>, state: SchemaState) => oas31.SchemaObject;
5
- export declare const createExtendedSchema: (zodObject: ZodObject<any, any, any, any, any>, baseZodObject: ZodObject<any, any, any, any, any>, schemaRef: string, state: SchemaState) => oas31.SchemaObject;
6
- export declare const createObjectSchemaFromShape: (shape: ZodRawShape, strict: boolean, state: SchemaState) => oas31.SchemaObject;
5
+ export declare const createExtendedSchema: (zodObject: ZodObject<any, any, any, any, any>, baseZodObject: ZodObject<any, any, any, any, any> | undefined, state: SchemaState) => oas31.SchemaObject | undefined;
6
+ interface AdditionalPropertyOptions {
7
+ unknownKeys?: UnknownKeysParam;
8
+ catchAll: ZodType;
9
+ }
10
+ export declare const createObjectSchemaFromShape: (shape: ZodRawShape, { unknownKeys, catchAll }: AdditionalPropertyOptions, state: SchemaState) => oas31.SchemaObject;
7
11
  export declare const mapRequired: (shape: ZodRawShape) => oas31.SchemaObject['required'];
8
12
  export declare const mapProperties: (shape: ZodRawShape, state: SchemaState) => oas31.SchemaObject['properties'];
13
+ export {};
@@ -1,4 +1,4 @@
1
- import { ZodOptional } from 'zod';
2
- import { oas31 } from '../../openapi3-ts/dist';
3
- import { SchemaState } from '.';
1
+ import type { ZodOptional } from 'zod';
2
+ import type { oas31 } from '../../openapi3-ts/dist';
3
+ import { type SchemaState } from '.';
4
4
  export declare const createOptionalSchema: (zodOptional: ZodOptional<any>, state: SchemaState) => oas31.SchemaObject | oas31.ReferenceObject;
@@ -1,4 +1,4 @@
1
- import { ZodPipeline } from 'zod';
2
- import { oas31 } from '../../openapi3-ts/dist';
3
- import { SchemaState } from '.';
1
+ import type { ZodPipeline } from 'zod';
2
+ import type { oas31 } from '../../openapi3-ts/dist';
3
+ import { type SchemaState } from '.';
4
4
  export declare const createPipelineSchema: (zodPipeline: ZodPipeline<any, any>, state: SchemaState) => oas31.SchemaObject | oas31.ReferenceObject;
@@ -1,4 +1,4 @@
1
- import { ZodEffects } from 'zod';
2
- import { oas31 } from '../../openapi3-ts/dist';
3
- import { SchemaState } from '.';
1
+ import type { ZodEffects } from 'zod';
2
+ import type { oas31 } from '../../openapi3-ts/dist';
3
+ import { type SchemaState } from '.';
4
4
  export declare const createPreprocessSchema: (zodPreprocess: ZodEffects<any, any, any>, state: SchemaState) => oas31.SchemaObject | oas31.ReferenceObject;
@@ -1,4 +1,4 @@
1
- import { ZodRecord } from 'zod';
2
- import { oas31 } from '../../openapi3-ts/dist';
3
- import { SchemaState } from '.';
1
+ import type { ZodRecord } from 'zod';
2
+ import type { oas31 } from '../../openapi3-ts/dist';
3
+ import { type SchemaState } from '.';
4
4
  export declare const createRecordSchema: (zodRecord: ZodRecord<any, any>, state: SchemaState) => oas31.SchemaObject;
@@ -1,4 +1,4 @@
1
- import { ZodEffects } from 'zod';
2
- import { oas31 } from '../../openapi3-ts/dist';
3
- import { SchemaState } from '.';
1
+ import type { ZodEffects } from 'zod';
2
+ import type { oas31 } from '../../openapi3-ts/dist';
3
+ import { type SchemaState } from '.';
4
4
  export declare const createRefineSchema: (zodRefine: ZodEffects<any, any, any>, state: SchemaState) => oas31.SchemaObject | oas31.ReferenceObject;
@@ -1,3 +1,3 @@
1
- import { ZodString } from 'zod';
2
- import { oas31 } from '../../openapi3-ts/dist';
1
+ import type { ZodString } from 'zod';
2
+ import type { oas31 } from '../../openapi3-ts/dist';
3
3
  export declare const createStringSchema: (zodString: ZodString) => oas31.SchemaObject;
@@ -1,4 +1,4 @@
1
- import { ZodEffects } from 'zod';
2
- import { oas31 } from '../../openapi3-ts/dist';
3
- import { SchemaState } from '.';
1
+ import type { ZodEffects } from 'zod';
2
+ import type { oas31 } from '../../openapi3-ts/dist';
3
+ import { type SchemaState } from '.';
4
4
  export declare const createTransformSchema: (zodTransform: ZodEffects<any, any, any>, state: SchemaState) => oas31.SchemaObject | oas31.ReferenceObject;
@@ -1,4 +1,4 @@
1
- import { ZodTuple } from 'zod';
2
- import { oas31 } from '../../openapi3-ts/dist';
3
- import { SchemaState } from '.';
1
+ import type { ZodTuple } from 'zod';
2
+ import type { oas31 } from '../../openapi3-ts/dist';
3
+ import { type SchemaState } from '.';
4
4
  export declare const createTupleSchema: (zodTuple: ZodTuple<any, any>, state: SchemaState) => oas31.SchemaObject;
@@ -1,4 +1,4 @@
1
- import { ZodUnion } from 'zod';
2
- import { oas31 } from '../../openapi3-ts/dist';
3
- import { SchemaState } from '.';
1
+ import type { ZodUnion } from 'zod';
2
+ import type { oas31 } from '../../openapi3-ts/dist';
3
+ import { type SchemaState } from '.';
4
4
  export declare const createUnionSchema: (zodUnion: ZodUnion<any>, state: SchemaState) => oas31.SchemaObject;
@@ -1,3 +1,3 @@
1
- import { ZodUnknown } from 'zod';
2
- import { oas31 } from '../../openapi3-ts/dist';
1
+ import type { ZodUnknown } from 'zod';
2
+ import type { oas31 } from '../../openapi3-ts/dist';
3
3
  export declare const createUnknownSchema: (_zodUnknown: ZodUnknown) => oas31.SchemaObject;
@@ -1,8 +1,8 @@
1
- import { UnknownKeysParam, ZodDate, ZodObject, ZodRawShape, ZodTypeAny, z } from 'zod';
2
- import { CreationType } from './create/components';
3
- import { oas30, oas31 } from './openapi3-ts/dist';
1
+ import type { UnknownKeysParam, ZodDate, ZodObject, ZodRawShape, ZodTypeAny, z } from 'zod';
2
+ import type { CreationType } from './create/components';
3
+ import type { oas30, oas31 } from './openapi3-ts/dist';
4
4
  type SchemaObject = oas30.SchemaObject & oas31.SchemaObject;
5
- interface ZodOpenApiMetadata<T extends ZodTypeAny, TInferred = z.infer<T>> extends SchemaObject {
5
+ interface ZodOpenApiMetadata<T extends ZodTypeAny, TInferred = z.input<T> | z.output<T>> extends SchemaObject {
6
6
  example?: TInferred;
7
7
  examples?: [TInferred, ...TInferred[]];
8
8
  default?: T extends ZodDate ? string : TInferred;
@@ -39,7 +39,6 @@ interface ZodOpenApiMetadata<T extends ZodTypeAny, TInferred = z.infer<T>> exten
39
39
  }
40
40
  interface ZodOpenApiExtendMetadata {
41
41
  extends: ZodObject<any, any, any, any, any>;
42
- extendsRef?: string;
43
42
  }
44
43
  declare module 'zod' {
45
44
  interface ZodSchema<Output, Def extends ZodTypeDef, Input = Output> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod-openapi",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "A library to create full OpenAPI documents from your Zod types",
5
5
  "homepage": "https://github.com/samchungy/zod-openapi#readme",
6
6
  "bugs": {
@@ -38,7 +38,7 @@
38
38
  "@types/node": "^18.15.13",
39
39
  "eslint-plugin-zod-openapi": "^0.1.0",
40
40
  "openapi3-ts": "^4.1.2",
41
- "skuba": "6.0.2",
41
+ "skuba": "6.1.0",
42
42
  "yaml": "2.2.2",
43
43
  "zod": "3.21.4"
44
44
  },