From 28651bbbadef838bd795bd8bfa1fb9c407291296 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Thu, 11 Aug 2022 09:39:59 +0300 Subject: [PATCH] If additionalProperties is basically type: string, ignore (#4274) --- packages/json-machete/src/healJSONSchema.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/json-machete/src/healJSONSchema.ts b/packages/json-machete/src/healJSONSchema.ts index 3db58a2a5f746..72d748d57f9b1 100644 --- a/packages/json-machete/src/healJSONSchema.ts +++ b/packages/json-machete/src/healJSONSchema.ts @@ -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'` );