@strapi/openapi 5.63.0 → 5.64.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.
- package/dist/utils/zod.d.ts +6 -5
- package/dist/utils/zod.d.ts.map +1 -1
- package/dist/utils/zod.js +7 -6
- package/dist/utils/zod.js.map +1 -1
- package/dist/utils/zod.mjs +7 -6
- package/dist/utils/zod.mjs.map +1 -1
- package/package.json +3 -3
package/dist/utils/zod.d.ts
CHANGED
|
@@ -2,16 +2,17 @@ import * as z from 'zod/v4';
|
|
|
2
2
|
import type { Core } from '@strapi/types';
|
|
3
3
|
import type { OpenAPIV3_1 } from 'openapi-types';
|
|
4
4
|
/**
|
|
5
|
-
* OpenAPI 3.1 uses the JSON Schema 2020-12 dialect
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* OpenAPI 3.1 uses the JSON Schema 2020-12 dialect, so `draft-2020-12` preserves valid 3.1
|
|
6
|
+
* schemas. Zod 4.6 added an `openapi-3.1` target; switching to it changes the generated
|
|
7
|
+
* document, so it is left for a separate change. Explicit output mode preserves the
|
|
8
|
+
* conversion direction used before these defaults were pinned.
|
|
8
9
|
*/
|
|
9
10
|
export declare const OPENAPI_SCHEMA_CONVERSION_OPTIONS: {
|
|
10
11
|
readonly target: "draft-2020-12";
|
|
11
12
|
readonly io: "output";
|
|
12
13
|
};
|
|
13
14
|
/**
|
|
14
|
-
* Zod 4
|
|
15
|
+
* Zod 4 embeds `$id` in registry `toJSONSchema` output when `uri` is configured.
|
|
15
16
|
* Strip it so OpenAPI documents stay stable — inline schemas use random UUIDs
|
|
16
17
|
* as registry IDs.
|
|
17
18
|
*/
|
|
@@ -27,7 +28,7 @@ export declare const toComponentsPath: (id: string) => string;
|
|
|
27
28
|
* Moves Zod's sibling `__shared` bucket into named component schemas and rewrites
|
|
28
29
|
* `$ref`s that targeted that bucket.
|
|
29
30
|
*
|
|
30
|
-
* Zod 4
|
|
31
|
+
* Zod 4 emits `#/components/schemas/__shared#/$defs/<id>` when an identified
|
|
31
32
|
* nested schema is not in the conversion registry. Those definitions must become
|
|
32
33
|
* first-class `components.schemas` entries; `__shared` is never written out.
|
|
33
34
|
*
|
package/dist/utils/zod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/utils/zod.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"zod.d.ts","sourceRoot":"","sources":["../../src/utils/zod.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,QAAQ,CAAC;AAE5B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC;;;CAG+B,CAAC;AAc9E;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,MAAM,EAAE,QAAQ,CAAC,KAAG,CAK/D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,IAAI,MAAM,WAAiC,CAAC;AA4C7E;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,GACnC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC/B,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,YAAY,CAoCzC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;CACtE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,YAAY,GACvB,WAAW,CAAC,CAAC,OAAO,EACpB,aAAa,IAAI,CAAC,wBAAwB,EAC1C,UAAU,mBAAmB,KAC5B,WAAW,CAAC,YAAY,GAAG,WAAW,CAAC,eA+BzC,CAAC"}
|
package/dist/utils/zod.js
CHANGED
|
@@ -24,23 +24,24 @@ function _interopNamespace(e) {
|
|
|
24
24
|
var z__namespace = /*#__PURE__*/_interopNamespace(z);
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* OpenAPI 3.1 uses the JSON Schema 2020-12 dialect
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* OpenAPI 3.1 uses the JSON Schema 2020-12 dialect, so `draft-2020-12` preserves valid 3.1
|
|
28
|
+
* schemas. Zod 4.6 added an `openapi-3.1` target; switching to it changes the generated
|
|
29
|
+
* document, so it is left for a separate change. Explicit output mode preserves the
|
|
30
|
+
* conversion direction used before these defaults were pinned.
|
|
30
31
|
*/ const OPENAPI_SCHEMA_CONVERSION_OPTIONS = {
|
|
31
32
|
target: 'draft-2020-12',
|
|
32
33
|
io: 'output'
|
|
33
34
|
};
|
|
34
35
|
const ZOD_SHARED_BUCKET = '__shared';
|
|
35
36
|
/**
|
|
36
|
-
* Zod 4
|
|
37
|
+
* Zod 4 emits `#/components/schemas/__shared#/$defs/<id>` (and close variants)
|
|
37
38
|
* when an identified nested schema is missing from the conversion registry.
|
|
38
39
|
*/ const ZOD_SHARED_REF_RE = /^#\/components\/schemas\/__shared#?\/(?:\$defs|definitions)\/(.+)$/;
|
|
39
40
|
const isPlainObject = (value)=>{
|
|
40
41
|
return typeof value === 'object' && value !== null && Array.isArray(value) === false;
|
|
41
42
|
};
|
|
42
43
|
/**
|
|
43
|
-
* Zod 4
|
|
44
|
+
* Zod 4 embeds `$id` in registry `toJSONSchema` output when `uri` is configured.
|
|
44
45
|
* Strip it so OpenAPI documents stay stable — inline schemas use random UUIDs
|
|
45
46
|
* as registry IDs.
|
|
46
47
|
*/ const stripJsonSchemaId = (schema)=>{
|
|
@@ -93,7 +94,7 @@ const rewriteZodSharedRefs = (value, seen = new WeakSet())=>{
|
|
|
93
94
|
* Moves Zod's sibling `__shared` bucket into named component schemas and rewrites
|
|
94
95
|
* `$ref`s that targeted that bucket.
|
|
95
96
|
*
|
|
96
|
-
* Zod 4
|
|
97
|
+
* Zod 4 emits `#/components/schemas/__shared#/$defs/<id>` when an identified
|
|
97
98
|
* nested schema is not in the conversion registry. Those definitions must become
|
|
98
99
|
* first-class `components.schemas` entries; `__shared` is never written out.
|
|
99
100
|
*
|
package/dist/utils/zod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.js","sources":["../../src/utils/zod.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport * as z from 'zod/v4';\n\nimport type { Core } from '@strapi/types';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\n/**\n * OpenAPI 3.1 uses the JSON Schema 2020-12 dialect. Zod 4.4.3 has no `openapi-3.1`\n * target, so `draft-2020-12` preserves valid 3.1 schemas. Explicit output mode preserves\n * the conversion direction used before these defaults were pinned.\n */\nexport const OPENAPI_SCHEMA_CONVERSION_OPTIONS = {\n target: 'draft-2020-12',\n io: 'output',\n} as const satisfies Pick<z.core.RegistryToJSONSchemaParams, 'target' | 'io'>;\n\nconst ZOD_SHARED_BUCKET = '__shared';\n\n/**\n * Zod 4.4.3 emits `#/components/schemas/__shared#/$defs/<id>` (and close variants)\n * when an identified nested schema is missing from the conversion registry.\n */\nconst ZOD_SHARED_REF_RE = /^#\\/components\\/schemas\\/__shared#?\\/(?:\\$defs|definitions)\\/(.+)$/;\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && Array.isArray(value) === false;\n};\n\n/**\n * Zod 4.4.3 embeds `$id` in registry `toJSONSchema` output when `uri` is configured.\n * Strip it so OpenAPI documents stay stable — inline schemas use random UUIDs\n * as registry IDs.\n */\nexport const stripJsonSchemaId = <T extends object>(schema: T): T => {\n if ('$id' in schema) {\n delete (schema as { $id?: string }).$id;\n }\n return schema;\n};\n\n/**\n * Generates a path string for referencing a component schema by its identifier.\n *\n * @param id - The identifier of the component schema.\n * @returns The constructed path string for the specified component schema.\n */\nexport const toComponentsPath = (id: string) => `#/components/schemas/${id}`;\n\nconst rewriteZodSharedRef = (ref: string): string => {\n const match = ZOD_SHARED_REF_RE.exec(ref);\n const id = match?.[1];\n\n if (id === undefined || id.length === 0) {\n return ref;\n }\n\n return toComponentsPath(id);\n};\n\nconst rewriteZodSharedRefs = (value: unknown, seen: WeakSet<object> = new WeakSet()): void => {\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n for (const item of value) {\n rewriteZodSharedRefs(item, seen);\n }\n return;\n }\n\n if (isPlainObject(value) === false) {\n return;\n }\n\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n\n const ref = value.$ref;\n if (typeof ref === 'string') {\n value.$ref = rewriteZodSharedRef(ref);\n }\n\n for (const nested of Object.values(value)) {\n rewriteZodSharedRefs(nested, seen);\n }\n};\n\n/**\n * Moves Zod's sibling `__shared` bucket into named component schemas and rewrites\n * `$ref`s that targeted that bucket.\n *\n * Zod 4.4.3 emits `#/components/schemas/__shared#/$defs/<id>` when an identified\n * nested schema is not in the conversion registry. Those definitions must become\n * first-class `components.schemas` entries; `__shared` is never written out.\n *\n * @returns Named schemas lifted from `__shared` (after `$id` stripping). Route\n * conversion copies these into the shared harvest bag so ComponentsWriter can\n * merge them into the document.\n */\nexport const liftZodSharedDefinitions = (\n schemas: Record<string, unknown>\n): Record<string, OpenAPIV3_1.SchemaObject> => {\n const harvested: Record<string, OpenAPIV3_1.SchemaObject> = {};\n const shared = schemas[ZOD_SHARED_BUCKET];\n\n if (isPlainObject(shared)) {\n const defs = shared.$defs ?? shared.definitions;\n\n if (isPlainObject(defs)) {\n for (const [id, def] of Object.entries(defs)) {\n if (isPlainObject(def) === false) {\n continue;\n }\n\n const cleaned = stripJsonSchemaId(def) as OpenAPIV3_1.SchemaObject;\n harvested[id] = cleaned;\n\n if (schemas[id] === undefined) {\n schemas[id] = cleaned;\n }\n }\n }\n\n delete schemas[ZOD_SHARED_BUCKET];\n }\n\n const seen = new WeakSet<object>();\n rewriteZodSharedRefs(schemas, seen);\n rewriteZodSharedRefs(harvested, seen);\n\n for (const schema of Object.values(schemas)) {\n if (isPlainObject(schema)) {\n stripJsonSchemaId(schema);\n }\n }\n\n return harvested;\n};\n\nexport type ZodToOpenAPIOptions = {\n /**\n * Shared harvest bag filled with named schemas lifted from Zod's `__shared`\n * bucket. Assemblers pass `context.registries.extractedComponentSchemas` so\n * ComponentsWriter can merge them into `components.schemas`.\n */\n extractedComponentSchemas?: Record<string, OpenAPIV3_1.SchemaObject>;\n};\n\n/**\n * Converts a Zod schema to an OpenAPI Schema Object.\n *\n * @description\n * Takes a Zod schema and converts it into an OpenAPI Schema Object (v3.1).\n * It uses a local registry to handle the conversion process and generates the appropriate\n * OpenAPI components. Identified nested schemas that Zod would otherwise park in\n * `__shared` are rewritten to `#/components/schemas/<id>` and copied into\n * `options.extractedComponentSchemas` when that bag is provided.\n *\n * @param zodSchema - The Zod schema to convert to OpenAPI format. Can be any valid Zod schema.\n * @param schemaStore - The application-owned content-API schema store to copy named\n * component definitions from. Conversion uses a local registry and does not read a\n * live Zod registry from the store.\n * @param options - Optional harvest bag shared across assemblers and ComponentsWriter.\n *\n * @returns An OpenAPI Schema Object representing the input Zod schema structure.\n * If the conversion cannot be completed, returns undefined.\n *\n * @example\n * ```typescript\n * import * as z from 'zod/v4';\n *\n * // Create a Zod schema\n * const userSchema = z.object({\n * id: z.number(),\n * name: z.string(),\n * email: z.string().email()\n * });\n *\n * // Convert to OpenAPI schema\n * const openAPISchema = zodToOpenAPI(userSchema, strapi.contentAPISchemaRegistry);\n * ```\n */\nexport const zodToOpenAPI = (\n zodSchema: z.ZodType,\n schemaStore: Core.ContentAPISchemaRegistry,\n options?: ZodToOpenAPIOptions\n): OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject => {\n try {\n const id = randomUUID();\n const registry = z.registry<{ id: string }>();\n\n // Add the schema to the local registry with a custom, unique ID\n registry.add(zodSchema, { id });\n\n // Copy Strapi-owned definitions into the local registry so references resolve without\n // generating \"__shared\" definitions.\n for (const [key, value] of schemaStore.entries()) {\n registry.add(value, { id: key });\n }\n\n // Generate the schemas and only return the one we want, transform the URI path to be OpenAPI compliant\n const { schemas } = z.toJSONSchema(registry, {\n ...OPENAPI_SCHEMA_CONVERSION_OPTIONS,\n uri: toComponentsPath,\n });\n\n const harvested = isPlainObject(schemas) ? liftZodSharedDefinitions(schemas) : {};\n\n if (options?.extractedComponentSchemas !== undefined) {\n Object.assign(options.extractedComponentSchemas, harvested);\n }\n\n // TODO: make sure it's compliant\n return stripJsonSchemaId(schemas[id] as OpenAPIV3_1.SchemaObject);\n } catch {\n throw new Error(\"Couldn't transform the zod schema into an OpenAPI schema\");\n }\n};\n"],"names":["OPENAPI_SCHEMA_CONVERSION_OPTIONS","target","io","ZOD_SHARED_BUCKET","ZOD_SHARED_REF_RE","isPlainObject","value","Array","isArray","stripJsonSchemaId","schema","$id","toComponentsPath","id","rewriteZodSharedRef","ref","match","exec","undefined","length","rewriteZodSharedRefs","seen","WeakSet","has","add","item","$ref","nested","Object","values","liftZodSharedDefinitions","schemas","harvested","shared","defs","$defs","definitions","def","entries","cleaned","zodToOpenAPI","zodSchema","schemaStore","options","randomUUID","registry","z","key","toJSONSchema","uri","extractedComponentSchemas","assign","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;;;UAKaA,iCAAAA,GAAoC;IAC/CC,MAAAA,EAAQ,eAAA;IACRC,EAAAA,EAAI;AACN;AAEA,MAAMC,iBAAAA,GAAoB,UAAA;AAE1B;;;AAGC,IACD,MAAMC,iBAAAA,GAAoB,oEAAA;AAE1B,MAAMC,gBAAgB,CAACC,KAAAA,GA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;QAEhF,IAAIY,OAAAA,EAASO,8BAA8BhC,SAAAA,EAAW;AACpDU,YAAAA,MAAAA,CAAOuB,MAAM,CAACR,OAAAA,CAAQO,yBAAyB,EAAElB,SAAAA,CAAAA;AACnD,QAAA;;QAGA,OAAOvB,iBAAAA,CAAkBsB,OAAO,CAAClB,EAAAA,CAAG,CAAA;AACtC,IAAA,CAAA,CAAE,OAAM;AACN,QAAA,MAAM,IAAIuC,KAAAA,CAAM,0DAAA,CAAA;AAClB,IAAA;AACF;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"zod.js","sources":["../../src/utils/zod.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport * as z from 'zod/v4';\n\nimport type { Core } from '@strapi/types';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\n/**\n * OpenAPI 3.1 uses the JSON Schema 2020-12 dialect, so `draft-2020-12` preserves valid 3.1\n * schemas. Zod 4.6 added an `openapi-3.1` target; switching to it changes the generated\n * document, so it is left for a separate change. Explicit output mode preserves the\n * conversion direction used before these defaults were pinned.\n */\nexport const OPENAPI_SCHEMA_CONVERSION_OPTIONS = {\n target: 'draft-2020-12',\n io: 'output',\n} as const satisfies Pick<z.core.RegistryToJSONSchemaParams, 'target' | 'io'>;\n\nconst ZOD_SHARED_BUCKET = '__shared';\n\n/**\n * Zod 4 emits `#/components/schemas/__shared#/$defs/<id>` (and close variants)\n * when an identified nested schema is missing from the conversion registry.\n */\nconst ZOD_SHARED_REF_RE = /^#\\/components\\/schemas\\/__shared#?\\/(?:\\$defs|definitions)\\/(.+)$/;\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && Array.isArray(value) === false;\n};\n\n/**\n * Zod 4 embeds `$id` in registry `toJSONSchema` output when `uri` is configured.\n * Strip it so OpenAPI documents stay stable — inline schemas use random UUIDs\n * as registry IDs.\n */\nexport const stripJsonSchemaId = <T extends object>(schema: T): T => {\n if ('$id' in schema) {\n delete (schema as { $id?: string }).$id;\n }\n return schema;\n};\n\n/**\n * Generates a path string for referencing a component schema by its identifier.\n *\n * @param id - The identifier of the component schema.\n * @returns The constructed path string for the specified component schema.\n */\nexport const toComponentsPath = (id: string) => `#/components/schemas/${id}`;\n\nconst rewriteZodSharedRef = (ref: string): string => {\n const match = ZOD_SHARED_REF_RE.exec(ref);\n const id = match?.[1];\n\n if (id === undefined || id.length === 0) {\n return ref;\n }\n\n return toComponentsPath(id);\n};\n\nconst rewriteZodSharedRefs = (value: unknown, seen: WeakSet<object> = new WeakSet()): void => {\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n for (const item of value) {\n rewriteZodSharedRefs(item, seen);\n }\n return;\n }\n\n if (isPlainObject(value) === false) {\n return;\n }\n\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n\n const ref = value.$ref;\n if (typeof ref === 'string') {\n value.$ref = rewriteZodSharedRef(ref);\n }\n\n for (const nested of Object.values(value)) {\n rewriteZodSharedRefs(nested, seen);\n }\n};\n\n/**\n * Moves Zod's sibling `__shared` bucket into named component schemas and rewrites\n * `$ref`s that targeted that bucket.\n *\n * Zod 4 emits `#/components/schemas/__shared#/$defs/<id>` when an identified\n * nested schema is not in the conversion registry. Those definitions must become\n * first-class `components.schemas` entries; `__shared` is never written out.\n *\n * @returns Named schemas lifted from `__shared` (after `$id` stripping). Route\n * conversion copies these into the shared harvest bag so ComponentsWriter can\n * merge them into the document.\n */\nexport const liftZodSharedDefinitions = (\n schemas: Record<string, unknown>\n): Record<string, OpenAPIV3_1.SchemaObject> => {\n const harvested: Record<string, OpenAPIV3_1.SchemaObject> = {};\n const shared = schemas[ZOD_SHARED_BUCKET];\n\n if (isPlainObject(shared)) {\n const defs = shared.$defs ?? shared.definitions;\n\n if (isPlainObject(defs)) {\n for (const [id, def] of Object.entries(defs)) {\n if (isPlainObject(def) === false) {\n continue;\n }\n\n const cleaned = stripJsonSchemaId(def) as OpenAPIV3_1.SchemaObject;\n harvested[id] = cleaned;\n\n if (schemas[id] === undefined) {\n schemas[id] = cleaned;\n }\n }\n }\n\n delete schemas[ZOD_SHARED_BUCKET];\n }\n\n const seen = new WeakSet<object>();\n rewriteZodSharedRefs(schemas, seen);\n rewriteZodSharedRefs(harvested, seen);\n\n for (const schema of Object.values(schemas)) {\n if (isPlainObject(schema)) {\n stripJsonSchemaId(schema);\n }\n }\n\n return harvested;\n};\n\nexport type ZodToOpenAPIOptions = {\n /**\n * Shared harvest bag filled with named schemas lifted from Zod's `__shared`\n * bucket. Assemblers pass `context.registries.extractedComponentSchemas` so\n * ComponentsWriter can merge them into `components.schemas`.\n */\n extractedComponentSchemas?: Record<string, OpenAPIV3_1.SchemaObject>;\n};\n\n/**\n * Converts a Zod schema to an OpenAPI Schema Object.\n *\n * @description\n * Takes a Zod schema and converts it into an OpenAPI Schema Object (v3.1).\n * It uses a local registry to handle the conversion process and generates the appropriate\n * OpenAPI components. Identified nested schemas that Zod would otherwise park in\n * `__shared` are rewritten to `#/components/schemas/<id>` and copied into\n * `options.extractedComponentSchemas` when that bag is provided.\n *\n * @param zodSchema - The Zod schema to convert to OpenAPI format. Can be any valid Zod schema.\n * @param schemaStore - The application-owned content-API schema store to copy named\n * component definitions from. Conversion uses a local registry and does not read a\n * live Zod registry from the store.\n * @param options - Optional harvest bag shared across assemblers and ComponentsWriter.\n *\n * @returns An OpenAPI Schema Object representing the input Zod schema structure.\n * If the conversion cannot be completed, returns undefined.\n *\n * @example\n * ```typescript\n * import * as z from 'zod/v4';\n *\n * // Create a Zod schema\n * const userSchema = z.object({\n * id: z.number(),\n * name: z.string(),\n * email: z.string().email()\n * });\n *\n * // Convert to OpenAPI schema\n * const openAPISchema = zodToOpenAPI(userSchema, strapi.contentAPISchemaRegistry);\n * ```\n */\nexport const zodToOpenAPI = (\n zodSchema: z.ZodType,\n schemaStore: Core.ContentAPISchemaRegistry,\n options?: ZodToOpenAPIOptions\n): OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject => {\n try {\n const id = randomUUID();\n const registry = z.registry<{ id: string }>();\n\n // Add the schema to the local registry with a custom, unique ID\n registry.add(zodSchema, { id });\n\n // Copy Strapi-owned definitions into the local registry so references resolve without\n // generating \"__shared\" definitions.\n for (const [key, value] of schemaStore.entries()) {\n registry.add(value, { id: key });\n }\n\n // Generate the schemas and only return the one we want, transform the URI path to be OpenAPI compliant\n const { schemas } = z.toJSONSchema(registry, {\n ...OPENAPI_SCHEMA_CONVERSION_OPTIONS,\n uri: toComponentsPath,\n });\n\n const harvested = isPlainObject(schemas) ? liftZodSharedDefinitions(schemas) : {};\n\n if (options?.extractedComponentSchemas !== undefined) {\n Object.assign(options.extractedComponentSchemas, harvested);\n }\n\n // TODO: make sure it's compliant\n return stripJsonSchemaId(schemas[id] as OpenAPIV3_1.SchemaObject);\n } catch {\n throw new Error(\"Couldn't transform the zod schema into an OpenAPI schema\");\n }\n};\n"],"names":["OPENAPI_SCHEMA_CONVERSION_OPTIONS","target","io","ZOD_SHARED_BUCKET","ZOD_SHARED_REF_RE","isPlainObject","value","Array","isArray","stripJsonSchemaId","schema","$id","toComponentsPath","id","rewriteZodSharedRef","ref","match","exec","undefined","length","rewriteZodSharedRefs","seen","WeakSet","has","add","item","$ref","nested","Object","values","liftZodSharedDefinitions","schemas","harvested","shared","defs","$defs","definitions","def","entries","cleaned","zodToOpenAPI","zodSchema","schemaStore","options","randomUUID","registry","z","key","toJSONSchema","uri","extractedComponentSchemas","assign","Error"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;;;;UAMaA,iCAAAA,GAAoC;IAC/CC,MAAAA,EAAQ,eAAA;IACRC,EAAAA,EAAI;AACN;AAEA,MAAMC,iBAAAA,GAAoB,UAAA;AAE1B;;;AAGC,IACD,MAAMC,iBAAAA,GAAoB,oEAAA;AAE1B,MAAMC,gBAAgB,CAACC,KAAAA,GAAAA;IACrB,OAAO,OAAOA,UAAU,QAAA,IAAYA,KAAAA,KAAU,QAAQC,KAAAA,CA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,CAAOuB,MAAM,CAACR,OAAAA,CAAQO,yBAAyB,EAAElB,SAAAA,CAAAA;AACnD,QAAA;;QAGA,OAAOvB,iBAAAA,CAAkBsB,OAAO,CAAClB,EAAAA,CAAG,CAAA;AACtC,IAAA,CAAA,CAAE,OAAM;AACN,QAAA,MAAM,IAAIuC,KAAAA,CAAM,0DAAA,CAAA;AAClB,IAAA;AACF;;;;;;;;"}
|
package/dist/utils/zod.mjs
CHANGED
|
@@ -2,23 +2,24 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import * as z from 'zod/v4';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* OpenAPI 3.1 uses the JSON Schema 2020-12 dialect
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* OpenAPI 3.1 uses the JSON Schema 2020-12 dialect, so `draft-2020-12` preserves valid 3.1
|
|
6
|
+
* schemas. Zod 4.6 added an `openapi-3.1` target; switching to it changes the generated
|
|
7
|
+
* document, so it is left for a separate change. Explicit output mode preserves the
|
|
8
|
+
* conversion direction used before these defaults were pinned.
|
|
8
9
|
*/ const OPENAPI_SCHEMA_CONVERSION_OPTIONS = {
|
|
9
10
|
target: 'draft-2020-12',
|
|
10
11
|
io: 'output'
|
|
11
12
|
};
|
|
12
13
|
const ZOD_SHARED_BUCKET = '__shared';
|
|
13
14
|
/**
|
|
14
|
-
* Zod 4
|
|
15
|
+
* Zod 4 emits `#/components/schemas/__shared#/$defs/<id>` (and close variants)
|
|
15
16
|
* when an identified nested schema is missing from the conversion registry.
|
|
16
17
|
*/ const ZOD_SHARED_REF_RE = /^#\/components\/schemas\/__shared#?\/(?:\$defs|definitions)\/(.+)$/;
|
|
17
18
|
const isPlainObject = (value)=>{
|
|
18
19
|
return typeof value === 'object' && value !== null && Array.isArray(value) === false;
|
|
19
20
|
};
|
|
20
21
|
/**
|
|
21
|
-
* Zod 4
|
|
22
|
+
* Zod 4 embeds `$id` in registry `toJSONSchema` output when `uri` is configured.
|
|
22
23
|
* Strip it so OpenAPI documents stay stable — inline schemas use random UUIDs
|
|
23
24
|
* as registry IDs.
|
|
24
25
|
*/ const stripJsonSchemaId = (schema)=>{
|
|
@@ -71,7 +72,7 @@ const rewriteZodSharedRefs = (value, seen = new WeakSet())=>{
|
|
|
71
72
|
* Moves Zod's sibling `__shared` bucket into named component schemas and rewrites
|
|
72
73
|
* `$ref`s that targeted that bucket.
|
|
73
74
|
*
|
|
74
|
-
* Zod 4
|
|
75
|
+
* Zod 4 emits `#/components/schemas/__shared#/$defs/<id>` when an identified
|
|
75
76
|
* nested schema is not in the conversion registry. Those definitions must become
|
|
76
77
|
* first-class `components.schemas` entries; `__shared` is never written out.
|
|
77
78
|
*
|
package/dist/utils/zod.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod.mjs","sources":["../../src/utils/zod.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport * as z from 'zod/v4';\n\nimport type { Core } from '@strapi/types';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\n/**\n * OpenAPI 3.1 uses the JSON Schema 2020-12 dialect. Zod 4.4.3 has no `openapi-3.1`\n * target, so `draft-2020-12` preserves valid 3.1 schemas. Explicit output mode preserves\n * the conversion direction used before these defaults were pinned.\n */\nexport const OPENAPI_SCHEMA_CONVERSION_OPTIONS = {\n target: 'draft-2020-12',\n io: 'output',\n} as const satisfies Pick<z.core.RegistryToJSONSchemaParams, 'target' | 'io'>;\n\nconst ZOD_SHARED_BUCKET = '__shared';\n\n/**\n * Zod 4.4.3 emits `#/components/schemas/__shared#/$defs/<id>` (and close variants)\n * when an identified nested schema is missing from the conversion registry.\n */\nconst ZOD_SHARED_REF_RE = /^#\\/components\\/schemas\\/__shared#?\\/(?:\\$defs|definitions)\\/(.+)$/;\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && Array.isArray(value) === false;\n};\n\n/**\n * Zod 4.4.3 embeds `$id` in registry `toJSONSchema` output when `uri` is configured.\n * Strip it so OpenAPI documents stay stable — inline schemas use random UUIDs\n * as registry IDs.\n */\nexport const stripJsonSchemaId = <T extends object>(schema: T): T => {\n if ('$id' in schema) {\n delete (schema as { $id?: string }).$id;\n }\n return schema;\n};\n\n/**\n * Generates a path string for referencing a component schema by its identifier.\n *\n * @param id - The identifier of the component schema.\n * @returns The constructed path string for the specified component schema.\n */\nexport const toComponentsPath = (id: string) => `#/components/schemas/${id}`;\n\nconst rewriteZodSharedRef = (ref: string): string => {\n const match = ZOD_SHARED_REF_RE.exec(ref);\n const id = match?.[1];\n\n if (id === undefined || id.length === 0) {\n return ref;\n }\n\n return toComponentsPath(id);\n};\n\nconst rewriteZodSharedRefs = (value: unknown, seen: WeakSet<object> = new WeakSet()): void => {\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n for (const item of value) {\n rewriteZodSharedRefs(item, seen);\n }\n return;\n }\n\n if (isPlainObject(value) === false) {\n return;\n }\n\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n\n const ref = value.$ref;\n if (typeof ref === 'string') {\n value.$ref = rewriteZodSharedRef(ref);\n }\n\n for (const nested of Object.values(value)) {\n rewriteZodSharedRefs(nested, seen);\n }\n};\n\n/**\n * Moves Zod's sibling `__shared` bucket into named component schemas and rewrites\n * `$ref`s that targeted that bucket.\n *\n * Zod 4.4.3 emits `#/components/schemas/__shared#/$defs/<id>` when an identified\n * nested schema is not in the conversion registry. Those definitions must become\n * first-class `components.schemas` entries; `__shared` is never written out.\n *\n * @returns Named schemas lifted from `__shared` (after `$id` stripping). Route\n * conversion copies these into the shared harvest bag so ComponentsWriter can\n * merge them into the document.\n */\nexport const liftZodSharedDefinitions = (\n schemas: Record<string, unknown>\n): Record<string, OpenAPIV3_1.SchemaObject> => {\n const harvested: Record<string, OpenAPIV3_1.SchemaObject> = {};\n const shared = schemas[ZOD_SHARED_BUCKET];\n\n if (isPlainObject(shared)) {\n const defs = shared.$defs ?? shared.definitions;\n\n if (isPlainObject(defs)) {\n for (const [id, def] of Object.entries(defs)) {\n if (isPlainObject(def) === false) {\n continue;\n }\n\n const cleaned = stripJsonSchemaId(def) as OpenAPIV3_1.SchemaObject;\n harvested[id] = cleaned;\n\n if (schemas[id] === undefined) {\n schemas[id] = cleaned;\n }\n }\n }\n\n delete schemas[ZOD_SHARED_BUCKET];\n }\n\n const seen = new WeakSet<object>();\n rewriteZodSharedRefs(schemas, seen);\n rewriteZodSharedRefs(harvested, seen);\n\n for (const schema of Object.values(schemas)) {\n if (isPlainObject(schema)) {\n stripJsonSchemaId(schema);\n }\n }\n\n return harvested;\n};\n\nexport type ZodToOpenAPIOptions = {\n /**\n * Shared harvest bag filled with named schemas lifted from Zod's `__shared`\n * bucket. Assemblers pass `context.registries.extractedComponentSchemas` so\n * ComponentsWriter can merge them into `components.schemas`.\n */\n extractedComponentSchemas?: Record<string, OpenAPIV3_1.SchemaObject>;\n};\n\n/**\n * Converts a Zod schema to an OpenAPI Schema Object.\n *\n * @description\n * Takes a Zod schema and converts it into an OpenAPI Schema Object (v3.1).\n * It uses a local registry to handle the conversion process and generates the appropriate\n * OpenAPI components. Identified nested schemas that Zod would otherwise park in\n * `__shared` are rewritten to `#/components/schemas/<id>` and copied into\n * `options.extractedComponentSchemas` when that bag is provided.\n *\n * @param zodSchema - The Zod schema to convert to OpenAPI format. Can be any valid Zod schema.\n * @param schemaStore - The application-owned content-API schema store to copy named\n * component definitions from. Conversion uses a local registry and does not read a\n * live Zod registry from the store.\n * @param options - Optional harvest bag shared across assemblers and ComponentsWriter.\n *\n * @returns An OpenAPI Schema Object representing the input Zod schema structure.\n * If the conversion cannot be completed, returns undefined.\n *\n * @example\n * ```typescript\n * import * as z from 'zod/v4';\n *\n * // Create a Zod schema\n * const userSchema = z.object({\n * id: z.number(),\n * name: z.string(),\n * email: z.string().email()\n * });\n *\n * // Convert to OpenAPI schema\n * const openAPISchema = zodToOpenAPI(userSchema, strapi.contentAPISchemaRegistry);\n * ```\n */\nexport const zodToOpenAPI = (\n zodSchema: z.ZodType,\n schemaStore: Core.ContentAPISchemaRegistry,\n options?: ZodToOpenAPIOptions\n): OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject => {\n try {\n const id = randomUUID();\n const registry = z.registry<{ id: string }>();\n\n // Add the schema to the local registry with a custom, unique ID\n registry.add(zodSchema, { id });\n\n // Copy Strapi-owned definitions into the local registry so references resolve without\n // generating \"__shared\" definitions.\n for (const [key, value] of schemaStore.entries()) {\n registry.add(value, { id: key });\n }\n\n // Generate the schemas and only return the one we want, transform the URI path to be OpenAPI compliant\n const { schemas } = z.toJSONSchema(registry, {\n ...OPENAPI_SCHEMA_CONVERSION_OPTIONS,\n uri: toComponentsPath,\n });\n\n const harvested = isPlainObject(schemas) ? liftZodSharedDefinitions(schemas) : {};\n\n if (options?.extractedComponentSchemas !== undefined) {\n Object.assign(options.extractedComponentSchemas, harvested);\n }\n\n // TODO: make sure it's compliant\n return stripJsonSchemaId(schemas[id] as OpenAPIV3_1.SchemaObject);\n } catch {\n throw new Error(\"Couldn't transform the zod schema into an OpenAPI schema\");\n }\n};\n"],"names":["OPENAPI_SCHEMA_CONVERSION_OPTIONS","target","io","ZOD_SHARED_BUCKET","ZOD_SHARED_REF_RE","isPlainObject","value","Array","isArray","stripJsonSchemaId","schema","$id","toComponentsPath","id","rewriteZodSharedRef","ref","match","exec","undefined","length","rewriteZodSharedRefs","seen","WeakSet","has","add","item","$ref","nested","Object","values","liftZodSharedDefinitions","schemas","harvested","shared","defs","$defs","definitions","def","entries","cleaned","zodToOpenAPI","zodSchema","schemaStore","options","randomUUID","registry","z","key","toJSONSchema","uri","extractedComponentSchemas","assign","Error"],"mappings":";;;AAMA;;;;UAKaA,iCAAAA,GAAoC;IAC/CC,MAAAA,EAAQ,eAAA;IACRC,EAAAA,EAAI;AACN;AAEA,MAAMC,iBAAAA,GAAoB,UAAA;AAE1B;;;AAGC,IACD,MAAMC,iBAAAA,GAA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AAAA,CAAAA,GAAWD,wBAAAA,CAAyBC,WAAW,EAAC;QAEhF,IAAIY,OAAAA,EAASO,8BAA8BhC,SAAAA,EAAW;AACpDU,YAAAA,MAAAA,CAAOuB,MAAM,CAACR,OAAAA,CAAQO,yBAAyB,EAAElB,SAAAA,CAAAA;AACnD,QAAA;;QAGA,OAAOvB,iBAAAA,CAAkBsB,OAAO,CAAClB,EAAAA,CAAG,CAAA;AACtC,IAAA,CAAA,CAAE,OAAM;AACN,QAAA,MAAM,IAAIuC,KAAAA,CAAM,0DAAA,CAAA;AAClB,IAAA;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"zod.mjs","sources":["../../src/utils/zod.ts"],"sourcesContent":["import { randomUUID } from 'node:crypto';\nimport * as z from 'zod/v4';\n\nimport type { Core } from '@strapi/types';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\n/**\n * OpenAPI 3.1 uses the JSON Schema 2020-12 dialect, so `draft-2020-12` preserves valid 3.1\n * schemas. Zod 4.6 added an `openapi-3.1` target; switching to it changes the generated\n * document, so it is left for a separate change. Explicit output mode preserves the\n * conversion direction used before these defaults were pinned.\n */\nexport const OPENAPI_SCHEMA_CONVERSION_OPTIONS = {\n target: 'draft-2020-12',\n io: 'output',\n} as const satisfies Pick<z.core.RegistryToJSONSchemaParams, 'target' | 'io'>;\n\nconst ZOD_SHARED_BUCKET = '__shared';\n\n/**\n * Zod 4 emits `#/components/schemas/__shared#/$defs/<id>` (and close variants)\n * when an identified nested schema is missing from the conversion registry.\n */\nconst ZOD_SHARED_REF_RE = /^#\\/components\\/schemas\\/__shared#?\\/(?:\\$defs|definitions)\\/(.+)$/;\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n return typeof value === 'object' && value !== null && Array.isArray(value) === false;\n};\n\n/**\n * Zod 4 embeds `$id` in registry `toJSONSchema` output when `uri` is configured.\n * Strip it so OpenAPI documents stay stable — inline schemas use random UUIDs\n * as registry IDs.\n */\nexport const stripJsonSchemaId = <T extends object>(schema: T): T => {\n if ('$id' in schema) {\n delete (schema as { $id?: string }).$id;\n }\n return schema;\n};\n\n/**\n * Generates a path string for referencing a component schema by its identifier.\n *\n * @param id - The identifier of the component schema.\n * @returns The constructed path string for the specified component schema.\n */\nexport const toComponentsPath = (id: string) => `#/components/schemas/${id}`;\n\nconst rewriteZodSharedRef = (ref: string): string => {\n const match = ZOD_SHARED_REF_RE.exec(ref);\n const id = match?.[1];\n\n if (id === undefined || id.length === 0) {\n return ref;\n }\n\n return toComponentsPath(id);\n};\n\nconst rewriteZodSharedRefs = (value: unknown, seen: WeakSet<object> = new WeakSet()): void => {\n if (Array.isArray(value)) {\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n for (const item of value) {\n rewriteZodSharedRefs(item, seen);\n }\n return;\n }\n\n if (isPlainObject(value) === false) {\n return;\n }\n\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n\n const ref = value.$ref;\n if (typeof ref === 'string') {\n value.$ref = rewriteZodSharedRef(ref);\n }\n\n for (const nested of Object.values(value)) {\n rewriteZodSharedRefs(nested, seen);\n }\n};\n\n/**\n * Moves Zod's sibling `__shared` bucket into named component schemas and rewrites\n * `$ref`s that targeted that bucket.\n *\n * Zod 4 emits `#/components/schemas/__shared#/$defs/<id>` when an identified\n * nested schema is not in the conversion registry. Those definitions must become\n * first-class `components.schemas` entries; `__shared` is never written out.\n *\n * @returns Named schemas lifted from `__shared` (after `$id` stripping). Route\n * conversion copies these into the shared harvest bag so ComponentsWriter can\n * merge them into the document.\n */\nexport const liftZodSharedDefinitions = (\n schemas: Record<string, unknown>\n): Record<string, OpenAPIV3_1.SchemaObject> => {\n const harvested: Record<string, OpenAPIV3_1.SchemaObject> = {};\n const shared = schemas[ZOD_SHARED_BUCKET];\n\n if (isPlainObject(shared)) {\n const defs = shared.$defs ?? shared.definitions;\n\n if (isPlainObject(defs)) {\n for (const [id, def] of Object.entries(defs)) {\n if (isPlainObject(def) === false) {\n continue;\n }\n\n const cleaned = stripJsonSchemaId(def) as OpenAPIV3_1.SchemaObject;\n harvested[id] = cleaned;\n\n if (schemas[id] === undefined) {\n schemas[id] = cleaned;\n }\n }\n }\n\n delete schemas[ZOD_SHARED_BUCKET];\n }\n\n const seen = new WeakSet<object>();\n rewriteZodSharedRefs(schemas, seen);\n rewriteZodSharedRefs(harvested, seen);\n\n for (const schema of Object.values(schemas)) {\n if (isPlainObject(schema)) {\n stripJsonSchemaId(schema);\n }\n }\n\n return harvested;\n};\n\nexport type ZodToOpenAPIOptions = {\n /**\n * Shared harvest bag filled with named schemas lifted from Zod's `__shared`\n * bucket. Assemblers pass `context.registries.extractedComponentSchemas` so\n * ComponentsWriter can merge them into `components.schemas`.\n */\n extractedComponentSchemas?: Record<string, OpenAPIV3_1.SchemaObject>;\n};\n\n/**\n * Converts a Zod schema to an OpenAPI Schema Object.\n *\n * @description\n * Takes a Zod schema and converts it into an OpenAPI Schema Object (v3.1).\n * It uses a local registry to handle the conversion process and generates the appropriate\n * OpenAPI components. Identified nested schemas that Zod would otherwise park in\n * `__shared` are rewritten to `#/components/schemas/<id>` and copied into\n * `options.extractedComponentSchemas` when that bag is provided.\n *\n * @param zodSchema - The Zod schema to convert to OpenAPI format. Can be any valid Zod schema.\n * @param schemaStore - The application-owned content-API schema store to copy named\n * component definitions from. Conversion uses a local registry and does not read a\n * live Zod registry from the store.\n * @param options - Optional harvest bag shared across assemblers and ComponentsWriter.\n *\n * @returns An OpenAPI Schema Object representing the input Zod schema structure.\n * If the conversion cannot be completed, returns undefined.\n *\n * @example\n * ```typescript\n * import * as z from 'zod/v4';\n *\n * // Create a Zod schema\n * const userSchema = z.object({\n * id: z.number(),\n * name: z.string(),\n * email: z.string().email()\n * });\n *\n * // Convert to OpenAPI schema\n * const openAPISchema = zodToOpenAPI(userSchema, strapi.contentAPISchemaRegistry);\n * ```\n */\nexport const zodToOpenAPI = (\n zodSchema: z.ZodType,\n schemaStore: Core.ContentAPISchemaRegistry,\n options?: ZodToOpenAPIOptions\n): OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject => {\n try {\n const id = randomUUID();\n const registry = z.registry<{ id: string }>();\n\n // Add the schema to the local registry with a custom, unique ID\n registry.add(zodSchema, { id });\n\n // Copy Strapi-owned definitions into the local registry so references resolve without\n // generating \"__shared\" definitions.\n for (const [key, value] of schemaStore.entries()) {\n registry.add(value, { id: key });\n }\n\n // Generate the schemas and only return the one we want, transform the URI path to be OpenAPI compliant\n const { schemas } = z.toJSONSchema(registry, {\n ...OPENAPI_SCHEMA_CONVERSION_OPTIONS,\n uri: toComponentsPath,\n });\n\n const harvested = isPlainObject(schemas) ? liftZodSharedDefinitions(schemas) : {};\n\n if (options?.extractedComponentSchemas !== undefined) {\n Object.assign(options.extractedComponentSchemas, harvested);\n }\n\n // TODO: make sure it's compliant\n return stripJsonSchemaId(schemas[id] as OpenAPIV3_1.SchemaObject);\n } catch {\n throw new Error(\"Couldn't transform the zod schema into an OpenAPI schema\");\n }\n};\n"],"names":["OPENAPI_SCHEMA_CONVERSION_OPTIONS","target","io","ZOD_SHARED_BUCKET","ZOD_SHARED_REF_RE","isPlainObject","value","Array","isArray","stripJsonSchemaId","schema","$id","toComponentsPath","id","rewriteZodSharedRef","ref","match","exec","undefined","length","rewriteZodSharedRefs","seen","WeakSet","has","add","item","$ref","nested","Object","values","liftZodSharedDefinitions","schemas","harvested","shared","defs","$defs","definitions","def","entries","cleaned","zodToOpenAPI","zodSchema","schemaStore","options","randomUUID","registry","z","key","toJSONSchema","uri","extractedComponentSchemas","assign","Error"],"mappings":";;;AAMA;;;;;UAMaA,iCAAAA,GAAoC;IAC/CC,MAAAA,EAAQ,eAAA;IACRC,EAAAA,EAAI;AACN;AAEA,MAAMC,iBAAAA,GAAoB,UAAA;AAE1B;;;AAGC,IACD,MAAMC,iBAAAA,GAAoB,oEAAA;AAE1B,MAAMC,gBAAgB,CAACC,KAAAA,GAAAA;IACrB,OAAO,OAAOA,UAAU,QAAA,IAAYA,KAAAA,KAA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pDU,YAAAA,MAAAA,CAAOuB,MAAM,CAACR,OAAAA,CAAQO,yBAAyB,EAAElB,SAAAA,CAAAA;AACnD,QAAA;;QAGA,OAAOvB,iBAAAA,CAAkBsB,OAAO,CAAClB,EAAAA,CAAG,CAAA;AACtC,IAAA,CAAA,CAAE,OAAM;AACN,QAAA,MAAM,IAAIuC,KAAAA,CAAM,0DAAA,CAAA;AAClB,IAAA;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/openapi",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.64.0",
|
|
4
4
|
"description": "A tool set to help generate and validate API documentation for Strapi projects",
|
|
5
5
|
"homepage": "https://strapi.io",
|
|
6
6
|
"bugs": {
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"debug": "4.3.4",
|
|
62
62
|
"openapi-types": "12.1.3",
|
|
63
|
-
"zod": "4.
|
|
63
|
+
"zod": "4.6.7"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@strapi/types": "5.
|
|
66
|
+
"@strapi/types": "5.64.0",
|
|
67
67
|
"@types/debug": "^4",
|
|
68
68
|
"@types/jest": "29.5.2",
|
|
69
69
|
"@types/node": "22.20.0",
|