zod-openapi 4.2.4 → 5.0.0-beta.1

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.
@@ -15,7 +15,8 @@ const openApiVersions = [
15
15
  "3.0.1",
16
16
  "3.0.2",
17
17
  "3.0.3",
18
- "3.1.0"
18
+ "3.1.0",
19
+ "3.1.1"
19
20
  ];
20
21
  const satisfiesVersion = (test, against) => openApiVersions.indexOf(test) >= openApiVersions.indexOf(against);
21
22
  const createDescriptionMetadata = (schema, description, state) => {
@@ -714,7 +715,7 @@ const getZodNumberChecks = (zodNumber) => zodNumber._def.checks.reduce((acc, che
714
715
  }, {});
715
716
  const mapNumberType = (zodNumberChecks) => zodNumberChecks.int ? "integer" : "number";
716
717
  const createOptionalSchema = (zodOptional, state) => createSchemaObject(zodOptional.unwrap(), state, ["optional"]);
717
- const isOptionalObjectKey = (zodSchema) => isZodType(zodSchema, "ZodNever") || isZodType(zodSchema, "ZodUndefined") || isZodType(zodSchema, "ZodLiteral") && zodSchema._def.value === void 0;
718
+ const isOptionalObjectKey = (zodSchema) => isZodType(zodSchema, "ZodNever") || isZodType(zodSchema, "ZodUndefined") || isZodType(zodSchema, "ZodOptional") && isOptionalObjectKey(zodSchema.unwrap()) || isZodType(zodSchema, "ZodLiteral") && zodSchema._def.value === void 0;
718
719
  const createObjectSchema = (zodObject, previous, state) => {
719
720
  const extendedSchema = createExtendedSchema(
720
721
  zodObject,
@@ -801,7 +802,6 @@ const createExtendedSchema = (zodObject, baseZodObject, state) => {
801
802
  if (schemaLength === 1 && extendedSchema.schema.description) {
802
803
  return createDescriptionMetadata(
803
804
  {
804
- type: "ref",
805
805
  schema: {
806
806
  $ref: createComponentSchemaRef(
807
807
  completeComponent.ref,
@@ -1948,11 +1948,12 @@ const createRequestBody = (requestBodyObject, components, subpath, documentOptio
1948
1948
  $ref: createComponentRequestBodyRef(component.ref)
1949
1949
  };
1950
1950
  }
1951
- const ref = requestBodyObject.ref ?? (component == null ? void 0 : component.ref);
1951
+ const { ref: reqBodyRef, ...cleanRequestBody } = requestBodyObject;
1952
+ const ref = reqBodyRef ?? (component == null ? void 0 : component.ref);
1952
1953
  const requestBody = {
1953
- ...requestBodyObject,
1954
+ ...cleanRequestBody,
1954
1955
  content: createContent(
1955
- requestBodyObject.content,
1956
+ cleanRequestBody.content,
1956
1957
  components,
1957
1958
  "input",
1958
1959
  [...subpath, "content"],
@@ -14,7 +14,8 @@ const openApiVersions = [
14
14
  "3.0.1",
15
15
  "3.0.2",
16
16
  "3.0.3",
17
- "3.1.0"
17
+ "3.1.0",
18
+ "3.1.1"
18
19
  ];
19
20
  const satisfiesVersion = (test, against) => openApiVersions.indexOf(test) >= openApiVersions.indexOf(against);
20
21
  const createDescriptionMetadata = (schema, description, state) => {
@@ -713,7 +714,7 @@ const getZodNumberChecks = (zodNumber) => zodNumber._def.checks.reduce((acc, che
713
714
  }, {});
714
715
  const mapNumberType = (zodNumberChecks) => zodNumberChecks.int ? "integer" : "number";
715
716
  const createOptionalSchema = (zodOptional, state) => createSchemaObject(zodOptional.unwrap(), state, ["optional"]);
716
- const isOptionalObjectKey = (zodSchema) => isZodType(zodSchema, "ZodNever") || isZodType(zodSchema, "ZodUndefined") || isZodType(zodSchema, "ZodLiteral") && zodSchema._def.value === void 0;
717
+ const isOptionalObjectKey = (zodSchema) => isZodType(zodSchema, "ZodNever") || isZodType(zodSchema, "ZodUndefined") || isZodType(zodSchema, "ZodOptional") && isOptionalObjectKey(zodSchema.unwrap()) || isZodType(zodSchema, "ZodLiteral") && zodSchema._def.value === void 0;
717
718
  const createObjectSchema = (zodObject, previous, state) => {
718
719
  const extendedSchema = createExtendedSchema(
719
720
  zodObject,
@@ -800,7 +801,6 @@ const createExtendedSchema = (zodObject, baseZodObject, state) => {
800
801
  if (schemaLength === 1 && extendedSchema.schema.description) {
801
802
  return createDescriptionMetadata(
802
803
  {
803
- type: "ref",
804
804
  schema: {
805
805
  $ref: createComponentSchemaRef(
806
806
  completeComponent.ref,
@@ -1947,11 +1947,12 @@ const createRequestBody = (requestBodyObject, components, subpath, documentOptio
1947
1947
  $ref: createComponentRequestBodyRef(component.ref)
1948
1948
  };
1949
1949
  }
1950
- const ref = requestBodyObject.ref ?? (component == null ? void 0 : component.ref);
1950
+ const { ref: reqBodyRef, ...cleanRequestBody } = requestBodyObject;
1951
+ const ref = reqBodyRef ?? (component == null ? void 0 : component.ref);
1951
1952
  const requestBody = {
1952
- ...requestBodyObject,
1953
+ ...cleanRequestBody,
1953
1954
  content: createContent(
1954
- requestBodyObject.content,
1955
+ cleanRequestBody.content,
1955
1956
  components,
1956
1957
  "input",
1957
1958
  [...subpath, "content"],
@@ -1,7 +1,7 @@
1
1
  import { ZodType } from 'zod';
2
- import { SchemaObject as SchemaObject$1, ReferenceObject as ReferenceObject$1, ParameterObject as ParameterObject$1, HeaderObject as HeaderObject$1, ResponseObject as ResponseObject$1, RequestBodyObject as RequestBodyObject$1, CallbackObject as CallbackObject$1 } from '../openapi3-ts/dist/model/openapi30.js';
3
- import { ComponentsObject as ComponentsObject$1, SchemaObject, ReferenceObject, ParameterObject, ParameterLocation, HeaderObject, ResponseObject, RequestBodyObject, CallbackObject } from '../openapi3-ts/dist/model/openapi31.js';
4
- import { ZodOpenApiVersion, ZodOpenApiComponentsObject, CreateDocumentOptions, ZodOpenApiResponseObject, ZodOpenApiRequestBodyObject, ZodOpenApiCallbackObject } from './document.js';
2
+ import { SchemaObject as SchemaObject$1, ReferenceObject as ReferenceObject$1, ParameterObject as ParameterObject$1, HeaderObject as HeaderObject$1, RequestBodyObject as RequestBodyObject$1, ResponseObject as ResponseObject$1, CallbackObject as CallbackObject$1 } from '../openapi3-ts/dist/model/openapi30.js';
3
+ import { SchemaObject, ReferenceObject, ParameterLocation, ParameterObject, HeaderObject, RequestBodyObject, ResponseObject, CallbackObject, ComponentsObject as ComponentsObject$1 } from '../openapi3-ts/dist/model/openapi31.js';
4
+ import { ZodOpenApiComponentsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiCallbackObject, ZodOpenApiVersion, CreateDocumentOptions } from './document.js';
5
5
 
6
6
  type CreationType = 'input' | 'output';
7
7
  type BaseEffect = {
@@ -121,4 +121,5 @@ interface ComponentsObject {
121
121
  declare const getDefaultComponents: (componentsObject?: ZodOpenApiComponentsObject, openapi?: ZodOpenApiVersion) => ComponentsObject;
122
122
  declare const createComponents: (componentsObject: ZodOpenApiComponentsObject, components: ComponentsObject, documentOptions?: CreateDocumentOptions) => ComponentsObject$1 | undefined;
123
123
 
124
- export { type BaseCallbackComponent, type CallbackComponent, type CallbackComponentMap, type CompleteCallbackComponent, type CompleteHeaderComponent, type CompleteParameterComponent, type CompleteRequestBodyComponent, type CompleteResponseComponent, type CompleteSchemaComponent, type ComponentEffect, type ComponentsObject, type CreationType, type Effect, type HeaderComponent, type HeaderComponentMap, type InProgressSchemaComponent, type ManualSchemaComponent, type ParameterComponent, type ParameterComponentMap, type PartialCallbackComponent, type PartialHeaderComponent, type PartialParameterComponent, type PartialRequestBodyComponent, type PartialResponseComponent, type RequestBodyComponent, type RequestBodyComponentMap, type ResolvedEffect, type ResponseComponent, type ResponseComponentMap, type SchemaComponent, type SchemaComponentMap, type SchemaEffect, createComponents, getDefaultComponents };
124
+ export { createComponents, getDefaultComponents };
125
+ export type { BaseCallbackComponent, CallbackComponent, CallbackComponentMap, CompleteCallbackComponent, CompleteHeaderComponent, CompleteParameterComponent, CompleteRequestBodyComponent, CompleteResponseComponent, CompleteSchemaComponent, ComponentEffect, ComponentsObject, CreationType, Effect, HeaderComponent, HeaderComponentMap, InProgressSchemaComponent, ManualSchemaComponent, ParameterComponent, ParameterComponentMap, PartialCallbackComponent, PartialHeaderComponent, PartialParameterComponent, PartialRequestBodyComponent, PartialResponseComponent, RequestBodyComponent, RequestBodyComponentMap, ResolvedEffect, ResponseComponent, ResponseComponentMap, SchemaComponent, SchemaComponentMap, SchemaEffect };
@@ -1,8 +1,8 @@
1
1
  import { ZodType, AnyZodObject, ZodTypeDef } from 'zod';
2
2
  import { OpenApiVersion } from '../openapi.js';
3
- import { MediaTypeObject as MediaTypeObject$1, RequestBodyObject as RequestBodyObject$1, ResponseObject as ResponseObject$1, HeadersObject, ReferenceObject as ReferenceObject$1, ParameterLocation as ParameterLocation$1, OperationObject as OperationObject$1, ParameterObject as ParameterObject$1, PathItemObject as PathItemObject$1, ComponentsObject as ComponentsObject$1, SchemaObject as SchemaObject$1, HeaderObject as HeaderObject$1 } from '../openapi3-ts/dist/model/openapi30.js';
3
+ import { MediaTypeObject as MediaTypeObject$1, RequestBodyObject as RequestBodyObject$1, ResponseObject as ResponseObject$1, HeadersObject, ReferenceObject as ReferenceObject$1, ParameterLocation as ParameterLocation$1, PathItemObject as PathItemObject$1, OperationObject as OperationObject$1, ParameterObject as ParameterObject$1, ComponentsObject as ComponentsObject$1, SchemaObject as SchemaObject$1, HeaderObject as HeaderObject$1 } from '../openapi3-ts/dist/model/openapi30.js';
4
4
  import { ISpecificationExtension } from '../openapi3-ts/dist/model/specification-extension.js';
5
- import { MediaTypeObject, SchemaObject, ReferenceObject, RequestBodyObject, ResponseObject, HeadersObject as HeadersObject$1, ParameterLocation, OperationObject, ParameterObject, PathItemObject, ComponentsObject, HeaderObject, OpenAPIObject } from '../openapi3-ts/dist/model/openapi31.js';
5
+ import { MediaTypeObject, SchemaObject, ReferenceObject, RequestBodyObject, ResponseObject, HeadersObject as HeadersObject$1, ParameterLocation, PathItemObject, OperationObject, ParameterObject, ComponentsObject, HeaderObject, OpenAPIObject } from '../openapi3-ts/dist/model/openapi31.js';
6
6
 
7
7
  interface ZodOpenApiMediaTypeObject extends Omit<MediaTypeObject & MediaTypeObject$1, 'schema'> {
8
8
  schema?: ZodType | SchemaObject | ReferenceObject;
@@ -87,4 +87,5 @@ interface CreateDocumentOptions {
87
87
  }
88
88
  declare const createDocument: (zodOpenApiObject: ZodOpenApiObject, documentOptions?: CreateDocumentOptions) => OpenAPIObject;
89
89
 
90
- export { type CreateDocumentOptions, type ZodObjectInputType, type ZodOpenApiCallbackObject, type ZodOpenApiCallbacksObject, type ZodOpenApiComponentsObject, type ZodOpenApiContentObject, type ZodOpenApiMediaTypeObject, type ZodOpenApiObject, type ZodOpenApiOperationObject, type ZodOpenApiParameters, type ZodOpenApiPathItemObject, type ZodOpenApiPathsObject, type ZodOpenApiRequestBodyObject, type ZodOpenApiResponseObject, type ZodOpenApiResponsesObject, type ZodOpenApiVersion, createDocument };
90
+ export { createDocument };
91
+ export type { CreateDocumentOptions, ZodObjectInputType, ZodOpenApiCallbackObject, ZodOpenApiCallbacksObject, ZodOpenApiComponentsObject, ZodOpenApiContentObject, ZodOpenApiMediaTypeObject, ZodOpenApiObject, ZodOpenApiOperationObject, ZodOpenApiParameters, ZodOpenApiPathItemObject, ZodOpenApiPathsObject, ZodOpenApiRequestBodyObject, ZodOpenApiResponseObject, ZodOpenApiResponsesObject, ZodOpenApiVersion };
@@ -29,4 +29,5 @@ interface CreateSchemaOptions extends CreateDocumentOptions {
29
29
  }
30
30
  declare const createSchema: (zodType: ZodType, opts?: CreateSchemaOptions) => SchemaResult;
31
31
 
32
- export { type CreateSchemaOptions, type SchemaResult, createSchema };
32
+ export { createSchema };
33
+ export type { CreateSchemaOptions, SchemaResult };
@@ -1,8 +1,8 @@
1
1
  import { ZodTypeAny, z, ZodObject } from 'zod';
2
2
  import { CreationType } from './create/components.js';
3
3
  import { currentSymbol, previousSymbol } from './extendZodSymbols.js';
4
- import { HeaderObject as HeaderObject$1, SchemaObject as SchemaObject$1 } from './openapi3-ts/dist/model/openapi30.js';
5
- import { ParameterObject, ExampleObject, ReferenceObject, HeaderObject, SchemaObject as SchemaObject$2 } from './openapi3-ts/dist/model/openapi31.js';
4
+ import { SchemaObject as SchemaObject$1, HeaderObject as HeaderObject$1 } from './openapi3-ts/dist/model/openapi30.js';
5
+ import { SchemaObject as SchemaObject$2, ParameterObject, ExampleObject, ReferenceObject, HeaderObject } from './openapi3-ts/dist/model/openapi31.js';
6
6
 
7
7
  type SchemaObject = SchemaObject$1 & SchemaObject$2;
8
8
  type ReplaceDate<T> = T extends Date ? Date | string : T;
package/dist/openapi.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- declare const openApiVersions: readonly ["3.0.0", "3.0.1", "3.0.2", "3.0.3", "3.1.0"];
1
+ declare const openApiVersions: readonly ["3.0.0", "3.0.1", "3.0.2", "3.0.3", "3.1.0", "3.1.1"];
2
2
  type OpenApiVersion = (typeof openApiVersions)[number];
3
3
 
4
- export { type OpenApiVersion, openApiVersions };
4
+ export { openApiVersions };
5
+ export type { OpenApiVersion };
@@ -287,4 +287,5 @@ interface SecurityRequirementObject {
287
287
  [name: string]: string[];
288
288
  }
289
289
 
290
- export { type BaseParameterObject, type CallbackObject, type CallbacksObject, type ComponentsObject, type ContactObject, type ContentObject, type DiscriminatorObject, type EncodingObject, type EncodingPropertyObject, type ExampleObject, type ExamplesObject, type ExternalDocumentationObject, type HeaderObject, type HeadersObject, ISpecificationExtension, type InfoObject, type LicenseObject, type LinkObject, type LinkParametersObject, type LinksObject, type MediaTypeObject, type OAuthFlowObject, type OAuthFlowsObject, type OpenAPIObject, type OperationObject, type ParameterLocation, type ParameterObject, type ParameterStyle, type PathItemObject, type PathObject, type PathsObject, type ReferenceObject, type RequestBodyObject, type ResponseObject, type ResponsesObject, type SchemaObject, type SchemaObjectFormat, type SchemaObjectType, type SchemasObject, type ScopesObject, type SecurityRequirementObject, type SecuritySchemeObject, type SecuritySchemeType, ServerObject, type TagObject, type XmlObject };
290
+ export { ISpecificationExtension, ServerObject };
291
+ export type { BaseParameterObject, CallbackObject, CallbacksObject, ComponentsObject, ContactObject, ContentObject, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, InfoObject, LicenseObject, LinkObject, LinkParametersObject, LinksObject, MediaTypeObject, OAuthFlowObject, OAuthFlowsObject, OpenAPIObject, OperationObject, ParameterLocation, ParameterObject, ParameterStyle, PathItemObject, PathObject, PathsObject, ReferenceObject, RequestBodyObject, ResponseObject, ResponsesObject, SchemaObject, SchemaObjectFormat, SchemaObjectType, SchemasObject, ScopesObject, SecurityRequirementObject, SecuritySchemeObject, SecuritySchemeType, TagObject, XmlObject };
@@ -294,4 +294,5 @@ interface SecurityRequirementObject {
294
294
  [name: string]: string[];
295
295
  }
296
296
 
297
- export { type BaseParameterObject, type CallbackObject, type CallbacksObject, type ComponentsObject, type ContactObject, type ContentObject, type DiscriminatorObject, type EncodingObject, type EncodingPropertyObject, type ExampleObject, type ExamplesObject, type ExternalDocumentationObject, type HeaderObject, type HeadersObject, ISpecificationExtension, type InfoObject, type LicenseObject, type LinkObject, type LinkParametersObject, type LinksObject, type MediaTypeObject, type OAuthFlowObject, type OAuthFlowsObject, type OpenAPIObject, type OperationObject, type ParameterLocation, type ParameterObject, type ParameterStyle, type PathItemObject, type PathObject, type PathsObject, type ReferenceObject, type RequestBodyObject, type ResponseObject, type ResponsesObject, type SchemaObject, type SchemaObjectType, type SchemasObject, type ScopesObject, type SecurityRequirementObject, type SecuritySchemeObject, type SecuritySchemeType, ServerObject, type TagObject, type XmlObject };
297
+ export { ISpecificationExtension, ServerObject };
298
+ export type { BaseParameterObject, CallbackObject, CallbacksObject, ComponentsObject, ContactObject, ContentObject, DiscriminatorObject, EncodingObject, EncodingPropertyObject, ExampleObject, ExamplesObject, ExternalDocumentationObject, HeaderObject, HeadersObject, 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, TagObject, XmlObject };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod-openapi",
3
- "version": "4.2.4",
3
+ "version": "5.0.0-beta.1",
4
4
  "description": "Convert Zod Schemas to OpenAPI v3.x documentation",
5
5
  "keywords": [
6
6
  "typescript",
@@ -72,20 +72,20 @@
72
72
  "test:watch": "skuba test --watch"
73
73
  },
74
74
  "devDependencies": {
75
- "@arethetypeswrong/cli": "0.17.2",
76
- "@crackle/cli": "0.15.5",
77
- "@redocly/cli": "1.34.0",
78
- "@types/node": "^20.3.0",
75
+ "@arethetypeswrong/cli": "0.18.1",
76
+ "@crackle/cli": "0.16.0",
77
+ "@redocly/cli": "1.34.3",
78
+ "@types/node": "22.15.21",
79
79
  "eslint-plugin-zod-openapi": "1.0.0",
80
80
  "openapi3-ts": "4.4.0",
81
- "skuba": "10.1.0",
82
- "yaml": "2.7.0",
83
- "zod": "3.24.2"
81
+ "skuba": "11.0.1-fix-node16-compatibility-20250523051131",
82
+ "yaml": "2.8.0",
83
+ "zod": "3.25.23"
84
84
  },
85
85
  "peerDependencies": {
86
86
  "zod": "^3.21.4"
87
87
  },
88
- "packageManager": "pnpm@9.0.5",
88
+ "packageManager": "pnpm@10.11.0",
89
89
  "engines": {
90
90
  "node": ">=18"
91
91
  },
@@ -97,6 +97,6 @@
97
97
  "entryPoint": "src/index.ts",
98
98
  "template": "oss-npm-package",
99
99
  "type": "package",
100
- "version": "10.1.0"
100
+ "version": "11.0.0"
101
101
  }
102
102
  }