Skip to content

Commit

Permalink
If additionalProperties is basically type: string, ignore (#4274)
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan authored and gilgardosh committed Aug 14, 2022
1 parent 90911f4 commit 28651bb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/json-machete/src/healJSONSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ export async function healJSONSchema(
if (typeof subSchema.additionalProperties === 'object') {
delete subSchema.additionalProperties.readOnly;
delete subSchema.additionalProperties.writeOnly;
if (Object.keys(subSchema.additionalProperties).length === 0) {
const additionalPropertiesKeys = Object.keys(subSchema.additionalProperties);
if (
additionalPropertiesKeys.length === 0 ||
(additionalPropertiesKeys.length === 1 && subSchema.additionalProperties.type === 'string')
) {
logger.debug(
`${path} has an empty additionalProperties object. So this is invalid. Replacing it with 'true'`
);
Expand Down

0 comments on commit 28651bb

Please sign in to comment.