zod-openapi 4.2.2-beta.0 → 4.2.3

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.
@@ -852,24 +852,38 @@ const createShapeDiff = (baseObj, extendedObj) => {
852
852
  }
853
853
  return acc;
854
854
  };
855
+ const mapAdditionalProperties = ({ unknownKeys, catchAll }, state) => {
856
+ if (!isZodType(catchAll, "ZodNever")) {
857
+ return createSchemaObject(catchAll, state, ["additional properties"]);
858
+ }
859
+ if (unknownKeys === "strict") {
860
+ return false;
861
+ }
862
+ if (unknownKeys === "passthrough") {
863
+ return true;
864
+ }
865
+ return void 0;
866
+ };
855
867
  const createObjectSchemaFromShape = (shape, { unknownKeys, catchAll }, state, omitType) => {
856
868
  const properties = mapProperties(shape, state);
857
869
  const required = mapRequired(properties, shape, state);
858
- const additionalProperties = !isZodType(catchAll, "ZodNever") ? createSchemaObject(catchAll, state, ["additional properties"]) : void 0;
870
+ const additionalProperties = mapAdditionalProperties(
871
+ { catchAll, unknownKeys },
872
+ state
873
+ );
859
874
  return {
860
875
  type: "schema",
861
876
  schema: {
862
877
  ...!omitType && { type: "object" },
863
878
  ...properties && { properties: properties.properties },
864
879
  ...(required == null ? void 0 : required.required.length) && { required: required.required },
865
- ...unknownKeys === "strict" && { additionalProperties: false },
866
- ...additionalProperties && {
867
- additionalProperties: additionalProperties.schema
880
+ ...additionalProperties !== void 0 && {
881
+ additionalProperties: typeof additionalProperties === "object" ? additionalProperties.schema : additionalProperties
868
882
  }
869
883
  },
870
884
  effects: flattenEffects([
871
885
  ...(properties == null ? void 0 : properties.effects) ?? [],
872
- additionalProperties == null ? void 0 : additionalProperties.effects,
886
+ typeof additionalProperties === "object" && (additionalProperties == null ? void 0 : additionalProperties.effects),
873
887
  required == null ? void 0 : required.effects
874
888
  ])
875
889
  };
@@ -851,24 +851,38 @@ const createShapeDiff = (baseObj, extendedObj) => {
851
851
  }
852
852
  return acc;
853
853
  };
854
+ const mapAdditionalProperties = ({ unknownKeys, catchAll }, state) => {
855
+ if (!isZodType(catchAll, "ZodNever")) {
856
+ return createSchemaObject(catchAll, state, ["additional properties"]);
857
+ }
858
+ if (unknownKeys === "strict") {
859
+ return false;
860
+ }
861
+ if (unknownKeys === "passthrough") {
862
+ return true;
863
+ }
864
+ return void 0;
865
+ };
854
866
  const createObjectSchemaFromShape = (shape, { unknownKeys, catchAll }, state, omitType) => {
855
867
  const properties = mapProperties(shape, state);
856
868
  const required = mapRequired(properties, shape, state);
857
- const additionalProperties = !isZodType(catchAll, "ZodNever") ? createSchemaObject(catchAll, state, ["additional properties"]) : void 0;
869
+ const additionalProperties = mapAdditionalProperties(
870
+ { catchAll, unknownKeys },
871
+ state
872
+ );
858
873
  return {
859
874
  type: "schema",
860
875
  schema: {
861
876
  ...!omitType && { type: "object" },
862
877
  ...properties && { properties: properties.properties },
863
878
  ...(required == null ? void 0 : required.required.length) && { required: required.required },
864
- ...unknownKeys === "strict" && { additionalProperties: false },
865
- ...additionalProperties && {
866
- additionalProperties: additionalProperties.schema
879
+ ...additionalProperties !== void 0 && {
880
+ additionalProperties: typeof additionalProperties === "object" ? additionalProperties.schema : additionalProperties
867
881
  }
868
882
  },
869
883
  effects: flattenEffects([
870
884
  ...(properties == null ? void 0 : properties.effects) ?? [],
871
- additionalProperties == null ? void 0 : additionalProperties.effects,
885
+ typeof additionalProperties === "object" && (additionalProperties == null ? void 0 : additionalProperties.effects),
872
886
  required == null ? void 0 : required.effects
873
887
  ])
874
888
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod-openapi",
3
- "version": "4.2.2-beta.0",
3
+ "version": "4.2.3",
4
4
  "description": "Convert Zod Schemas to OpenAPI v3.x documentation",
5
5
  "keywords": [
6
6
  "typescript",
@@ -72,14 +72,14 @@
72
72
  "test:watch": "skuba test --watch"
73
73
  },
74
74
  "devDependencies": {
75
- "@arethetypeswrong/cli": "0.17.1",
75
+ "@arethetypeswrong/cli": "0.17.2",
76
76
  "@crackle/cli": "0.15.5",
77
- "@redocly/cli": "1.26.0",
77
+ "@redocly/cli": "1.27.0",
78
78
  "@types/node": "^20.3.0",
79
79
  "eslint-plugin-zod-openapi": "^1.0.0-beta.0",
80
80
  "openapi3-ts": "4.4.0",
81
81
  "skuba": "9.1.0",
82
- "yaml": "2.6.1",
82
+ "yaml": "2.7.0",
83
83
  "zod": "3.24.1"
84
84
  },
85
85
  "peerDependencies": {