From 5e017453627d8fff3e700644bbb9bf264dbd7873 Mon Sep 17 00:00:00 2001 From: Madalin Ilie Date: Sun, 6 Dec 2020 23:12:16 +0200 Subject: [PATCH] Fix issue when additionalProperties had a chain of additionalProperties with object schema --- .../com/endava/cats/generator/simple/PayloadGenerator.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/endava/cats/generator/simple/PayloadGenerator.java b/src/main/java/com/endava/cats/generator/simple/PayloadGenerator.java index 1eec0ba9e..38e43de36 100644 --- a/src/main/java/com/endava/cats/generator/simple/PayloadGenerator.java +++ b/src/main/java/com/endava/cats/generator/simple/PayloadGenerator.java @@ -180,6 +180,10 @@ private Object getExampleFromAdditionalPropertiesSchema(String propertyName, Str if (property.getName() != null) { mp.put(property.getName(), resolvePropertyToExample(propertyName, mediaType, (Schema) property.getAdditionalProperties())); + } else if (((Schema) property.getAdditionalProperties()).get$ref() != null) { + Schema innerSchema = (Schema) property.getAdditionalProperties(); + Schema addPropSchema = this.schemaMap.get(innerSchema.get$ref().substring(innerSchema.get$ref().lastIndexOf('/') + 1)); + mp.put("key", resolvePropertyToExample(propertyName, mediaType, addPropSchema)); } else { mp.put("key", resolvePropertyToExample(propertyName, mediaType, (Schema) property.getAdditionalProperties()));