@anatine/zod-openapi
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -5,2 +5,4 @@ # Changelog | ||
### [2.2.2](https://github.com/anatine/zod-plugins/compare/zod-openapi-2.2.1...zod-openapi-2.2.2) (2023-12-15) | ||
### [2.2.1](https://github.com/anatine/zod-plugins/compare/zod-openapi-2.2.0...zod-openapi-2.2.1) (2023-10-31) | ||
@@ -7,0 +9,0 @@ |
{ | ||
"name": "@anatine/zod-openapi", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "Zod to OpenAPI converter", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -172,10 +172,12 @@ "use strict"; | ||
return (0, ts_deepmerge_1.default)({ | ||
type: 'string', | ||
format: 'null', | ||
nullable: true, | ||
type: 'null', | ||
}, zodRef.description ? { description: zodRef.description } : {}, ...schemas); | ||
} | ||
function parseOptionalNullable({ schemas, zodRef, useOutput, }) { | ||
function parseOptional({ schemas, zodRef, useOutput, }) { | ||
return (0, ts_deepmerge_1.default)(generateSchema(zodRef.unwrap(), useOutput), zodRef.description ? { description: zodRef.description } : {}, ...schemas); | ||
} | ||
function parseNullable({ schemas, zodRef, useOutput, }) { | ||
const schema = generateSchema(zodRef.unwrap(), useOutput); | ||
return (0, ts_deepmerge_1.default)(Object.assign(Object.assign({}, schema), { type: [schema.type, 'null'] }), zodRef.description ? { description: zodRef.description } : {}, ...schemas); | ||
} | ||
function parseDefault({ schemas, zodRef, useOutput, }) { | ||
@@ -258,2 +260,5 @@ return (0, ts_deepmerge_1.default)(Object.assign({ default: zodRef._def.defaultValue() }, generateSchema(zodRef._def.innerType, useOutput)), zodRef.description ? { description: zodRef.description } : {}, ...schemas); | ||
} | ||
function parseReadonly({ zodRef, useOutput, schemas, }) { | ||
return (0, ts_deepmerge_1.default)(generateSchema(zodRef._def.innerType, useOutput), zodRef.description ? { description: zodRef.description } : {}, ...schemas); | ||
} | ||
const workerMap = { | ||
@@ -268,4 +273,4 @@ ZodObject: parseObject, | ||
ZodNull: parseNull, | ||
ZodOptional: parseOptionalNullable, | ||
ZodNullable: parseOptionalNullable, | ||
ZodOptional: parseOptional, | ||
ZodNullable: parseNullable, | ||
ZodDefault: parseDefault, | ||
@@ -295,2 +300,3 @@ ZodArray: parseArray, | ||
ZodPipeline: parsePipeline, | ||
ZodReadonly: parseReadonly, | ||
}; | ||
@@ -300,3 +306,2 @@ function generateSchema(zodRef, useOutput) { | ||
const schemas = [ | ||
zodRef.isNullable && zodRef.isNullable() ? { nullable: true } : {}, | ||
...(Array.isArray(metaOpenApi) ? metaOpenApi : [metaOpenApi]), | ||
@@ -303,0 +308,0 @@ ]; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44155
379