@anatine/zod-openapi
Advanced tools
Comparing version 1.11.1 to 1.12.0
@@ -5,2 +5,14 @@ # Changelog | ||
## [1.12.0](https://github.com/anatine/zod-plugins/compare/zod-openapi-1.11.1...zod-openapi-1.12.0) (2023-01-17) | ||
### Features | ||
* set additionalProperties to false if strict ([80c7012](https://github.com/anatine/zod-plugins/commit/80c7012922bb4b1a59a5b96d0b5680e7cc436976)) | ||
### Bug Fixes | ||
* **zod-openapi:** no empty required to conform to OpenApi 3.0 ([5d7731e](https://github.com/anatine/zod-plugins/commit/5d7731e3ae8b457664f2a750274005d0a5a50f7f)) | ||
### [1.11.1](https://github.com/anatine/zod-plugins/compare/zod-openapi-1.11.0...zod-openapi-1.11.1) (2023-01-01) | ||
@@ -7,0 +19,0 @@ |
{ | ||
"name": "@anatine/zod-openapi", | ||
"version": "1.11.1", | ||
"version": "1.12.0", | ||
"description": "Zod to OpenAPI converter", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -121,15 +121,19 @@ "use strict"; | ||
additionalProperties = true; | ||
else if (zodRef._def.unknownKeys === 'strict') | ||
additionalProperties = false; | ||
// So that `undefined` values don't end up in the schema and be weird | ||
additionalProperties = additionalProperties ? { additionalProperties } : {}; | ||
return (0, ts_deepmerge_1.default)(Object.assign({ type: 'object', properties: iterateZodObject({ | ||
additionalProperties = additionalProperties != null ? { additionalProperties } : {}; | ||
const requiredProperties = Object.keys(zodRef.shape).filter((key) => { | ||
const item = zodRef.shape[key]; | ||
return (!(item.isOptional() || | ||
item instanceof zod_1.z.ZodDefault || | ||
item._def.typeName === 'ZodDefault') && | ||
!(item instanceof zod_1.z.ZodNever || item._def.typeName === 'ZodDefault')); | ||
}); | ||
const required = requiredProperties.length > 0 ? { required: requiredProperties } : {}; | ||
return (0, ts_deepmerge_1.default)(Object.assign(Object.assign({ type: 'object', properties: iterateZodObject({ | ||
zodRef: zodRef, | ||
schemas, | ||
useOutput, | ||
}), required: Object.keys(zodRef.shape).filter((key) => { | ||
const item = zodRef.shape[key]; | ||
return (!(item.isOptional() || | ||
item instanceof zod_1.z.ZodDefault || | ||
item._def.typeName === 'ZodDefault') && | ||
!(item instanceof zod_1.z.ZodNever || item._def.typeName === 'ZodDefault')); | ||
}) }, additionalProperties), zodRef.description ? { description: zodRef.description } : {}, ...schemas); | ||
}) }, required), additionalProperties), zodRef.description ? { description: zodRef.description } : {}, ...schemas); | ||
} | ||
@@ -136,0 +140,0 @@ function parseRecord({ zodRef, schemas, useOutput, }) { |
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
34907
301