zod-openapi 5.0.0-beta.10 → 5.0.0-beta.11
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 +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +1 -1
- package/dist/api.mjs +1 -1
- package/dist/{components-CtvxFnRF.d.ts → components-29xRAW1K.d.mts} +4 -0
- package/dist/{components-DKJ1Dtzd.mjs → components-3Hqib_T0.mjs} +10 -8
- package/dist/{components-Cp63fKGN.js → components-BdF0iREJ.js} +10 -8
- package/dist/{components-DLZ-sf1V.d.mts → components-nS-mzdlW.d.ts} +4 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/api.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentRegistry, Override, createComponents, createRegistry } from "./components-
|
|
1
|
+
import { ComponentRegistry, Override, createComponents, createRegistry } from "./components-29xRAW1K.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-
|
|
1
|
+
import { ComponentRegistry, Override, createComponents, createRegistry } from "./components-nS-mzdlW.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
package/dist/api.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { createComponents, createRegistry, isAnyZodType, unwrapZodObject } from "./components-
|
|
1
|
+
import { createComponents, createRegistry, isAnyZodType, unwrapZodObject } from "./components-3Hqib_T0.mjs";
|
|
2
2
|
|
|
3
3
|
export { createComponents, createRegistry, isAnyZodType, unwrapZodObject };
|
|
@@ -473,6 +473,10 @@ interface CreateDocumentOptions {
|
|
|
473
473
|
* - `"ref"` — Default. Cycles will be broken using $defs
|
|
474
474
|
* - `"throw"` — Cycles will throw an error if encountered */
|
|
475
475
|
cycles?: 'ref' | 'throw';
|
|
476
|
+
/**
|
|
477
|
+
* The $ref path to use for a schema component. Defaults to `#/components/schemas/`
|
|
478
|
+
*/
|
|
479
|
+
schemaRefPath?: string;
|
|
476
480
|
}
|
|
477
481
|
declare const createDocument: (zodOpenApiObject: ZodOpenApiObject, opts?: CreateDocumentOptions) => OpenAPIObject;
|
|
478
482
|
//#endregion
|
|
@@ -236,14 +236,15 @@ const validate = (ctx, opts) => {
|
|
|
236
236
|
|
|
237
237
|
//#endregion
|
|
238
238
|
//#region src/create/schema/rename.ts
|
|
239
|
-
const renameComponents = (components, outputIds, ctx) => {
|
|
239
|
+
const renameComponents = (components, outputIds, ctx, refPath) => {
|
|
240
240
|
const componentsToRename = /* @__PURE__ */ new Map();
|
|
241
241
|
if (ctx.io === "input") return componentsToRename;
|
|
242
242
|
const componentDependencies = /* @__PURE__ */ new Map();
|
|
243
243
|
const stringifiedComponents = /* @__PURE__ */ new Map();
|
|
244
244
|
for (const [key, value] of Object.entries(components)) {
|
|
245
245
|
const stringified = JSON.stringify(value);
|
|
246
|
-
const
|
|
246
|
+
const regex = new RegExp(`"${refPath}([^"]+)"`, "g");
|
|
247
|
+
const matches = stringified.matchAll(regex);
|
|
247
248
|
const dependencies = /* @__PURE__ */ new Set();
|
|
248
249
|
for (const match of matches) {
|
|
249
250
|
const dep = match[1];
|
|
@@ -311,6 +312,7 @@ const createSchema = (schema, ctx = {
|
|
|
311
312
|
};
|
|
312
313
|
};
|
|
313
314
|
const createSchemas = (schemas, ctx) => {
|
|
315
|
+
const refPath = ctx.opts.schemaRefPath ?? "#/components/schemas/";
|
|
314
316
|
const entries = {};
|
|
315
317
|
for (const [name, { zodType }] of Object.entries(schemas)) entries[name] = zodType;
|
|
316
318
|
const zodRegistry = registry();
|
|
@@ -352,7 +354,7 @@ const createSchemas = (schemas, ctx) => {
|
|
|
352
354
|
const dynamicComponents = /* @__PURE__ */ new Map();
|
|
353
355
|
for (const [key, value] of Object.entries(components)) if (/^schema\d+$/.test(key)) {
|
|
354
356
|
const newName = `__schema${ctx.registry.components.schemas.dynamicSchemaCount++}`;
|
|
355
|
-
dynamicComponents.set(key, `"
|
|
357
|
+
dynamicComponents.set(key, `"${refPath}${newName}"`);
|
|
356
358
|
if (newName !== key) {
|
|
357
359
|
components[newName] = value;
|
|
358
360
|
delete components[key];
|
|
@@ -364,7 +366,7 @@ const createSchemas = (schemas, ctx) => {
|
|
|
364
366
|
if (dynamic) return dynamic;
|
|
365
367
|
const manualComponent = ctx.registry.components.schemas.manual.get(match);
|
|
366
368
|
if (manualComponent) manualUsed[match] = true;
|
|
367
|
-
return `"
|
|
369
|
+
return `"${refPath}${match}"`;
|
|
368
370
|
}));
|
|
369
371
|
const parsedComponents = parsedJsonSchema.schemas.__shared?.$defs ?? {};
|
|
370
372
|
parsedJsonSchema.schemas.__shared ??= { $defs: parsedComponents };
|
|
@@ -380,7 +382,7 @@ const createSchemas = (schemas, ctx) => {
|
|
|
380
382
|
parsedComponents[key] = manualComponent;
|
|
381
383
|
}
|
|
382
384
|
}
|
|
383
|
-
const componentsToRename = renameComponents(parsedComponents, outputIds, ctx);
|
|
385
|
+
const componentsToRename = renameComponents(parsedComponents, outputIds, ctx, refPath);
|
|
384
386
|
if (!componentsToRename.size) {
|
|
385
387
|
const parsedSchemas = parsedJsonSchema.schemas.zodOpenApiCreateSchema?.properties;
|
|
386
388
|
delete parsedJsonSchema.schemas.zodOpenApiCreateSchema;
|
|
@@ -391,10 +393,10 @@ const createSchemas = (schemas, ctx) => {
|
|
|
391
393
|
manual: parsedJsonSchema.schemas
|
|
392
394
|
};
|
|
393
395
|
}
|
|
394
|
-
const renamedJsonSchema = JSON.parse(JSON.stringify(parsedJsonSchema).replace(
|
|
396
|
+
const renamedJsonSchema = JSON.parse(JSON.stringify(parsedJsonSchema).replace(new RegExp(`"${refPath}([^"]+)"`, "g"), (_, match) => {
|
|
395
397
|
const replacement = componentsToRename.get(match);
|
|
396
|
-
if (replacement) return `"
|
|
397
|
-
return `"
|
|
398
|
+
if (replacement) return `"${refPath}${replacement}"`;
|
|
399
|
+
return `"${refPath}${match}"`;
|
|
398
400
|
}));
|
|
399
401
|
const renamedSchemas = renamedJsonSchema.schemas.zodOpenApiCreateSchema?.properties;
|
|
400
402
|
const renamedComponents = renamedJsonSchema.schemas.__shared?.$defs ?? {};
|
|
@@ -259,14 +259,15 @@ const validate = (ctx, opts) => {
|
|
|
259
259
|
|
|
260
260
|
//#endregion
|
|
261
261
|
//#region src/create/schema/rename.ts
|
|
262
|
-
const renameComponents = (components, outputIds, ctx) => {
|
|
262
|
+
const renameComponents = (components, outputIds, ctx, refPath) => {
|
|
263
263
|
const componentsToRename = /* @__PURE__ */ new Map();
|
|
264
264
|
if (ctx.io === "input") return componentsToRename;
|
|
265
265
|
const componentDependencies = /* @__PURE__ */ new Map();
|
|
266
266
|
const stringifiedComponents = /* @__PURE__ */ new Map();
|
|
267
267
|
for (const [key, value] of Object.entries(components)) {
|
|
268
268
|
const stringified = JSON.stringify(value);
|
|
269
|
-
const
|
|
269
|
+
const regex = new RegExp(`"${refPath}([^"]+)"`, "g");
|
|
270
|
+
const matches = stringified.matchAll(regex);
|
|
270
271
|
const dependencies = /* @__PURE__ */ new Set();
|
|
271
272
|
for (const match of matches) {
|
|
272
273
|
const dep = match[1];
|
|
@@ -334,6 +335,7 @@ const createSchema = (schema, ctx = {
|
|
|
334
335
|
};
|
|
335
336
|
};
|
|
336
337
|
const createSchemas = (schemas, ctx) => {
|
|
338
|
+
const refPath = ctx.opts.schemaRefPath ?? "#/components/schemas/";
|
|
337
339
|
const entries = {};
|
|
338
340
|
for (const [name, { zodType }] of Object.entries(schemas)) entries[name] = zodType;
|
|
339
341
|
const zodRegistry = (0, zod_v4.registry)();
|
|
@@ -375,7 +377,7 @@ const createSchemas = (schemas, ctx) => {
|
|
|
375
377
|
const dynamicComponents = /* @__PURE__ */ new Map();
|
|
376
378
|
for (const [key, value] of Object.entries(components)) if (/^schema\d+$/.test(key)) {
|
|
377
379
|
const newName = `__schema${ctx.registry.components.schemas.dynamicSchemaCount++}`;
|
|
378
|
-
dynamicComponents.set(key, `"
|
|
380
|
+
dynamicComponents.set(key, `"${refPath}${newName}"`);
|
|
379
381
|
if (newName !== key) {
|
|
380
382
|
components[newName] = value;
|
|
381
383
|
delete components[key];
|
|
@@ -387,7 +389,7 @@ const createSchemas = (schemas, ctx) => {
|
|
|
387
389
|
if (dynamic) return dynamic;
|
|
388
390
|
const manualComponent = ctx.registry.components.schemas.manual.get(match);
|
|
389
391
|
if (manualComponent) manualUsed[match] = true;
|
|
390
|
-
return `"
|
|
392
|
+
return `"${refPath}${match}"`;
|
|
391
393
|
}));
|
|
392
394
|
const parsedComponents = parsedJsonSchema.schemas.__shared?.$defs ?? {};
|
|
393
395
|
parsedJsonSchema.schemas.__shared ??= { $defs: parsedComponents };
|
|
@@ -403,7 +405,7 @@ const createSchemas = (schemas, ctx) => {
|
|
|
403
405
|
parsedComponents[key] = manualComponent;
|
|
404
406
|
}
|
|
405
407
|
}
|
|
406
|
-
const componentsToRename = renameComponents(parsedComponents, outputIds, ctx);
|
|
408
|
+
const componentsToRename = renameComponents(parsedComponents, outputIds, ctx, refPath);
|
|
407
409
|
if (!componentsToRename.size) {
|
|
408
410
|
const parsedSchemas = parsedJsonSchema.schemas.zodOpenApiCreateSchema?.properties;
|
|
409
411
|
delete parsedJsonSchema.schemas.zodOpenApiCreateSchema;
|
|
@@ -414,10 +416,10 @@ const createSchemas = (schemas, ctx) => {
|
|
|
414
416
|
manual: parsedJsonSchema.schemas
|
|
415
417
|
};
|
|
416
418
|
}
|
|
417
|
-
const renamedJsonSchema = JSON.parse(JSON.stringify(parsedJsonSchema).replace(
|
|
419
|
+
const renamedJsonSchema = JSON.parse(JSON.stringify(parsedJsonSchema).replace(new RegExp(`"${refPath}([^"]+)"`, "g"), (_, match) => {
|
|
418
420
|
const replacement = componentsToRename.get(match);
|
|
419
|
-
if (replacement) return `"
|
|
420
|
-
return `"
|
|
421
|
+
if (replacement) return `"${refPath}${replacement}"`;
|
|
422
|
+
return `"${refPath}${match}"`;
|
|
421
423
|
}));
|
|
422
424
|
const renamedSchemas = renamedJsonSchema.schemas.zodOpenApiCreateSchema?.properties;
|
|
423
425
|
const renamedComponents = renamedJsonSchema.schemas.__shared?.$defs ?? {};
|
|
@@ -473,6 +473,10 @@ interface CreateDocumentOptions {
|
|
|
473
473
|
* - `"ref"` — Default. Cycles will be broken using $defs
|
|
474
474
|
* - `"throw"` — Cycles will throw an error if encountered */
|
|
475
475
|
cycles?: 'ref' | 'throw';
|
|
476
|
+
/**
|
|
477
|
+
* The $ref path to use for a schema component. Defaults to `#/components/schemas/`
|
|
478
|
+
*/
|
|
479
|
+
schemaRefPath?: string;
|
|
476
480
|
}
|
|
477
481
|
declare const createDocument: (zodOpenApiObject: ZodOpenApiObject, opts?: CreateDocumentOptions) => OpenAPIObject;
|
|
478
482
|
//#endregion
|
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-
|
|
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-29xRAW1K.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-
|
|
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-nS-mzdlW.js";
|
|
2
2
|
import { core } from "zod/v4";
|
|
3
3
|
|
|
4
4
|
//#region rolldown:runtime
|
package/dist/index.js
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createComponents, createPaths, createRegistry, createSchema } from "./components-
|
|
1
|
+
import { createComponents, createPaths, createRegistry, createSchema } from "./components-3Hqib_T0.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/create/document.ts
|
|
4
4
|
const createDocument = (zodOpenApiObject, opts = {}) => {
|