Skip to content

Commit adf1670

Browse files
authored
59 scc multiapi converteropenapi fix the behaviour when a simple schema is defined as an array (#67)
* First Changes. Still WIP * Update OpenApiContractConverter * Update README.md
1 parent 34a7863 commit adf1670

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/net/coru/multiapi/converter/openapi/OpenApiContractConverter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ private HashMap<String, Object> processComplexBodyAndMatchers(
389389
} else {
390390
final var subProperties = ((ArraySchema) openAPI.getComponents().getSchemas().get(ref)).getItems();
391391
final List<Object> propertyList = new ArrayList<>();
392-
propertyMap.put(property.getKey(), processArray(subProperties, propertyList, newObjectName, bodyMatchers, openAPI));
392+
propertyMap.put(property.getKey(), processArray(subProperties, propertyList, objectName, bodyMatchers, openAPI));
393393
}
394394
} else {
395395
final String type;
@@ -409,7 +409,7 @@ private List<Object> processArray(final Schema<?> arraySchema, final List<Object
409409
if (Objects.nonNull(arraySchema.get$ref())) {
410410
final String ref = OpenApiContractConverterUtils.mapRefName(arraySchema);
411411
final HashMap<String, Schema> subObject = (HashMap<String, Schema>) openAPI.getComponents().getSchemas().get(ref).getProperties();
412-
propertyList.add(processComplexBodyAndMatchers("[0]", subObject, openAPI, bodyMatchers));
412+
propertyList.add(processComplexBodyAndMatchers(objectName, subObject, openAPI, bodyMatchers));
413413
} else {
414414
final String type = arraySchema.getType();
415415
switch (type) {
@@ -441,7 +441,7 @@ private List<Object> processArray(final Schema<?> arraySchema, final List<Object
441441

442442
private void processObjectArray(final Schema<?> arraySchema, final List<Object> propertyList, final String objectName, final BodyMatchers bodyMatchers, final OpenAPI openAPI) {
443443
final HashMap<String, Schema> subObject = (HashMap<String, Schema>) arraySchema.getProperties();
444-
propertyList.add(processComplexBodyAndMatchers(objectName + "[0]", subObject, openAPI, bodyMatchers));
444+
propertyList.add(processComplexBodyAndMatchers(objectName, subObject, openAPI, bodyMatchers));
445445
}
446446

447447
private void processArrayArray(final ArraySchema arraySchema, final List<Object> propertyList, final String objectName, final BodyMatchers bodyMatchers, final OpenAPI openAPI) {
@@ -450,7 +450,7 @@ private void processArrayArray(final ArraySchema arraySchema, final List<Object>
450450
propertyList.add(subArray.getExample());
451451
} else {
452452
final List<Object> subPropertyList = new ArrayList<>();
453-
propertyList.add(processArray(subArray, subPropertyList, objectName, bodyMatchers, openAPI));
453+
propertyList.add(processArray(subArray, subPropertyList, objectName + "[0]", bodyMatchers, openAPI));
454454
}
455455
}
456456

0 commit comments

Comments
 (0)