zod-openapi 5.0.0-beta.12 → 5.0.0-beta.13

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/dist/api.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ComponentRegistry, Override, createComponents, createRegistry } from "./components-VJHAKH5Q.mjs";
1
+ import { ComponentRegistry, Override, createComponents, createRegistry } from "./components-Ck7iRc2n.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-Ci95nsUp.js";
1
+ import { ComponentRegistry, Override, createComponents, createRegistry } from "./components-DLKlRo1M.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
@@ -1,4 +1,4 @@
1
- const require_components = require('./components-DPGXI3C3.js');
1
+ const require_components = require('./components-D7SEPn4F.js');
2
2
 
3
3
  exports.createComponents = require_components.createComponents;
4
4
  exports.createRegistry = require_components.createRegistry;
package/dist/api.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { createComponents, createRegistry, isAnyZodType, unwrapZodObject } from "./components-GWr6bv6y.mjs";
1
+ import { createComponents, createRegistry, isAnyZodType, unwrapZodObject } from "./components-DGJXTZGV.mjs";
2
2
 
3
3
  export { createComponents, createRegistry, isAnyZodType, unwrapZodObject };
@@ -481,6 +481,15 @@ interface CreateDocumentOptions {
481
481
  declare const createDocument: (zodOpenApiObject: ZodOpenApiObject, opts?: CreateDocumentOptions) => OpenAPIObject;
482
482
  //#endregion
483
483
  //#region src/create/components.d.ts
484
+ type SchemaSource = {
485
+ type: 'mediaType' | 'header';
486
+ } | {
487
+ type: 'parameter';
488
+ location: {
489
+ in: string;
490
+ name: string;
491
+ };
492
+ };
484
493
  interface ComponentRegistry {
485
494
  components: {
486
495
  schemas: {
@@ -488,12 +497,16 @@ interface ComponentRegistry {
488
497
  input: Map<string, {
489
498
  zodType: $ZodType;
490
499
  schemaObject: SchemaObject | ReferenceObject;
491
- path: string[];
500
+ source: SchemaSource & {
501
+ path: string[];
502
+ };
492
503
  }>;
493
504
  output: Map<string, {
494
505
  zodType: $ZodType;
495
506
  schemaObject: SchemaObject | ReferenceObject;
496
- path: string[];
507
+ source: SchemaSource & {
508
+ path: string[];
509
+ };
497
510
  }>;
498
511
  ids: Map<string, SchemaObject | ReferenceObject>;
499
512
  manual: Map<string, {
@@ -533,8 +546,9 @@ interface ComponentRegistry {
533
546
  seen: WeakMap<ZodOpenApiPathItemObject, PathItemObject | ReferenceObject>;
534
547
  };
535
548
  };
536
- addSchema: (schema: $ZodType, path: string[], opts?: {
549
+ addSchema: (schema: $ZodType, path: string[], opts: {
537
550
  io: 'input' | 'output';
551
+ source: SchemaSource;
538
552
  }) => SchemaObject | ReferenceObject;
539
553
  addHeader: (header: $ZodType, path: string[], opts?: {
540
554
  manualId?: string;
@@ -31,7 +31,10 @@ const isAnyZodType = (schema) => typeof schema === "object" && schema !== null &
31
31
  //#region src/create/content.ts
32
32
  const createMediaTypeObject = (mediaTypeObject, ctx, path) => {
33
33
  if (isAnyZodType(mediaTypeObject.schema)) {
34
- const schemaObject = ctx.registry.addSchema(mediaTypeObject.schema, [...path, "schema"], { io: ctx.io });
34
+ const schemaObject = ctx.registry.addSchema(mediaTypeObject.schema, [...path, "schema"], {
35
+ io: ctx.io,
36
+ source: { type: "mediaType" }
37
+ });
35
38
  return {
36
39
  ...mediaTypeObject,
37
40
  schema: schemaObject
@@ -470,12 +473,14 @@ const createRegistry = (components) => {
470
473
  }
471
474
  },
472
475
  addSchema: (schema, path, opts) => {
473
- const io = opts?.io ?? "output";
474
476
  const schemaObject = {};
475
- registry$1.components.schemas[io].set(path.join(" > "), {
477
+ registry$1.components.schemas[opts.io].set(path.join(" > "), {
476
478
  schemaObject,
477
479
  zodType: schema,
478
- path
480
+ source: {
481
+ path,
482
+ ...opts?.source
483
+ }
479
484
  });
480
485
  return schemaObject;
481
486
  },
@@ -486,7 +491,21 @@ const createRegistry = (components) => {
486
491
  const name = opts?.location?.name ?? meta?.param?.name;
487
492
  const inLocation = opts?.location?.in ?? meta?.param?.in;
488
493
  if (!name || !inLocation) throw new Error(`Parameter at ${path.join(" > ")} is missing \`.meta({ param: { name, in } })\` information`);
489
- const schemaObject = registry$1.addSchema(parameter, [...path, "schema"], { io: "input" });
494
+ const schemaObject = registry$1.addSchema(parameter, [
495
+ ...path,
496
+ inLocation,
497
+ name,
498
+ "schema"
499
+ ], {
500
+ io: "input",
501
+ source: {
502
+ type: "parameter",
503
+ location: {
504
+ in: inLocation,
505
+ name
506
+ }
507
+ }
508
+ });
490
509
  const { id: metaId,...rest } = meta?.param ?? {};
491
510
  const parameterObject = {
492
511
  ...rest,
@@ -498,7 +517,7 @@ const createRegistry = (components) => {
498
517
  if (!parameterObject.description && meta?.description) parameterObject.description = meta.description;
499
518
  const id = metaId ?? opts?.manualId;
500
519
  if (id) {
501
- if (registry$1.components.parameters.ids.has(id)) throw new Error(`Schema "${id}" is already registered`);
520
+ if (registry$1.components.parameters.ids.has(id)) throw new Error(`Schema "${id}" at ${path.join(" > ")} is already registered`);
502
521
  const ref = { $ref: `#/components/parameters/${id}` };
503
522
  registry$1.components.parameters.seen.set(parameter, ref);
504
523
  registry$1.components.parameters.ids.set(id, parameterObject);
@@ -516,7 +535,10 @@ const createRegistry = (components) => {
516
535
  const headerObject = rest;
517
536
  if (isRequired(header, "output")) headerObject.required = true;
518
537
  if (!headerObject.description && meta?.description) headerObject.description = meta.description;
519
- headerObject.schema = registry$1.addSchema(header, [...path, "schema"], { io: "output" });
538
+ headerObject.schema = registry$1.addSchema(header, [...path, "schema"], {
539
+ io: "output",
540
+ source: { type: "header" }
541
+ });
520
542
  if (id) {
521
543
  if (registry$1.components.schemas.ids.has(id)) throw new Error(`Schema "${id}" is already registered`);
522
544
  const ref = { $ref: `#/components/headers/${id}` };
@@ -8,7 +8,10 @@ const isAnyZodType = (schema) => typeof schema === "object" && schema !== null &
8
8
  //#region src/create/content.ts
9
9
  const createMediaTypeObject = (mediaTypeObject, ctx, path) => {
10
10
  if (isAnyZodType(mediaTypeObject.schema)) {
11
- const schemaObject = ctx.registry.addSchema(mediaTypeObject.schema, [...path, "schema"], { io: ctx.io });
11
+ const schemaObject = ctx.registry.addSchema(mediaTypeObject.schema, [...path, "schema"], {
12
+ io: ctx.io,
13
+ source: { type: "mediaType" }
14
+ });
12
15
  return {
13
16
  ...mediaTypeObject,
14
17
  schema: schemaObject
@@ -447,12 +450,14 @@ const createRegistry = (components) => {
447
450
  }
448
451
  },
449
452
  addSchema: (schema, path, opts) => {
450
- const io = opts?.io ?? "output";
451
453
  const schemaObject = {};
452
- registry$1.components.schemas[io].set(path.join(" > "), {
454
+ registry$1.components.schemas[opts.io].set(path.join(" > "), {
453
455
  schemaObject,
454
456
  zodType: schema,
455
- path
457
+ source: {
458
+ path,
459
+ ...opts?.source
460
+ }
456
461
  });
457
462
  return schemaObject;
458
463
  },
@@ -463,7 +468,21 @@ const createRegistry = (components) => {
463
468
  const name = opts?.location?.name ?? meta?.param?.name;
464
469
  const inLocation = opts?.location?.in ?? meta?.param?.in;
465
470
  if (!name || !inLocation) throw new Error(`Parameter at ${path.join(" > ")} is missing \`.meta({ param: { name, in } })\` information`);
466
- const schemaObject = registry$1.addSchema(parameter, [...path, "schema"], { io: "input" });
471
+ const schemaObject = registry$1.addSchema(parameter, [
472
+ ...path,
473
+ inLocation,
474
+ name,
475
+ "schema"
476
+ ], {
477
+ io: "input",
478
+ source: {
479
+ type: "parameter",
480
+ location: {
481
+ in: inLocation,
482
+ name
483
+ }
484
+ }
485
+ });
467
486
  const { id: metaId,...rest } = meta?.param ?? {};
468
487
  const parameterObject = {
469
488
  ...rest,
@@ -475,7 +494,7 @@ const createRegistry = (components) => {
475
494
  if (!parameterObject.description && meta?.description) parameterObject.description = meta.description;
476
495
  const id = metaId ?? opts?.manualId;
477
496
  if (id) {
478
- if (registry$1.components.parameters.ids.has(id)) throw new Error(`Schema "${id}" is already registered`);
497
+ if (registry$1.components.parameters.ids.has(id)) throw new Error(`Schema "${id}" at ${path.join(" > ")} is already registered`);
479
498
  const ref = { $ref: `#/components/parameters/${id}` };
480
499
  registry$1.components.parameters.seen.set(parameter, ref);
481
500
  registry$1.components.parameters.ids.set(id, parameterObject);
@@ -493,7 +512,10 @@ const createRegistry = (components) => {
493
512
  const headerObject = rest;
494
513
  if (isRequired(header, "output")) headerObject.required = true;
495
514
  if (!headerObject.description && meta?.description) headerObject.description = meta.description;
496
- headerObject.schema = registry$1.addSchema(header, [...path, "schema"], { io: "output" });
515
+ headerObject.schema = registry$1.addSchema(header, [...path, "schema"], {
516
+ io: "output",
517
+ source: { type: "header" }
518
+ });
497
519
  if (id) {
498
520
  if (registry$1.components.schemas.ids.has(id)) throw new Error(`Schema "${id}" is already registered`);
499
521
  const ref = { $ref: `#/components/headers/${id}` };
@@ -481,6 +481,15 @@ interface CreateDocumentOptions {
481
481
  declare const createDocument: (zodOpenApiObject: ZodOpenApiObject, opts?: CreateDocumentOptions) => OpenAPIObject;
482
482
  //#endregion
483
483
  //#region src/create/components.d.ts
484
+ type SchemaSource = {
485
+ type: 'mediaType' | 'header';
486
+ } | {
487
+ type: 'parameter';
488
+ location: {
489
+ in: string;
490
+ name: string;
491
+ };
492
+ };
484
493
  interface ComponentRegistry {
485
494
  components: {
486
495
  schemas: {
@@ -488,12 +497,16 @@ interface ComponentRegistry {
488
497
  input: Map<string, {
489
498
  zodType: $ZodType;
490
499
  schemaObject: SchemaObject | ReferenceObject;
491
- path: string[];
500
+ source: SchemaSource & {
501
+ path: string[];
502
+ };
492
503
  }>;
493
504
  output: Map<string, {
494
505
  zodType: $ZodType;
495
506
  schemaObject: SchemaObject | ReferenceObject;
496
- path: string[];
507
+ source: SchemaSource & {
508
+ path: string[];
509
+ };
497
510
  }>;
498
511
  ids: Map<string, SchemaObject | ReferenceObject>;
499
512
  manual: Map<string, {
@@ -533,8 +546,9 @@ interface ComponentRegistry {
533
546
  seen: WeakMap<ZodOpenApiPathItemObject, PathItemObject | ReferenceObject>;
534
547
  };
535
548
  };
536
- addSchema: (schema: $ZodType, path: string[], opts?: {
549
+ addSchema: (schema: $ZodType, path: string[], opts: {
537
550
  io: 'input' | 'output';
551
+ source: SchemaSource;
538
552
  }) => SchemaObject | ReferenceObject;
539
553
  addHeader: (header: $ZodType, path: string[], opts?: {
540
554
  manualId?: string;
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-VJHAKH5Q.mjs";
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-Ck7iRc2n.mjs";
2
2
  import { core } from "zod/v4";
3
3
 
4
4
  //#region rolldown:runtime
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-Ci95nsUp.js";
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-DLKlRo1M.js";
2
2
  import { core } from "zod/v4";
3
3
 
4
4
  //#region rolldown:runtime
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const require_components = require('./components-DPGXI3C3.js');
1
+ const require_components = require('./components-D7SEPn4F.js');
2
2
 
3
3
  //#region src/create/document.ts
4
4
  const createDocument = (zodOpenApiObject, opts = {}) => {
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { createComponents, createPaths, createRegistry, createSchema } from "./components-GWr6bv6y.mjs";
1
+ import { createComponents, createPaths, createRegistry, createSchema } from "./components-DGJXTZGV.mjs";
2
2
 
3
3
  //#region src/create/document.ts
4
4
  const createDocument = (zodOpenApiObject, opts = {}) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod-openapi",
3
- "version": "5.0.0-beta.12",
3
+ "version": "5.0.0-beta.13",
4
4
  "description": "Convert Zod Schemas to OpenAPI v3.x documentation",
5
5
  "keywords": [
6
6
  "typescript",