to fix loop for allof with single element in normalizer (#17426)

This commit is contained in:
William Cheng
2023-12-19 11:31:25 +08:00
committed by GitHub
parent 5435b44e40
commit 473c3508ff
3 changed files with 11 additions and 2 deletions

View File

@@ -573,6 +573,10 @@ public class OpenAPINormalizer {
return;
}
if (schema.getAllOf().size() == 1) {
return;
}
for (Object item : schema.getAllOf()) {
if (!(item instanceof Schema)) {
throw new RuntimeException("Error! allOf schema is not of the type Schema: " + item);

View File

@@ -2022,7 +2022,7 @@ public class JavaClientCodegenTest {
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "true");
List<File> files = generator.opts(clientOptInput).generate();
Assert.assertEquals(files.size(), 24);
Assert.assertEquals(files.size(), 27);
validateJavaSourceFiles(files);
TestUtils.assertFileContains(

View File

@@ -96,4 +96,9 @@ components:
mum_or_dad:
type: string
required:
- isParent
- isParent
allOfWithSingleItem:
description: allOf with a single item
nullable: true
allOf:
- $ref: '#/components/schemas/AnotherParent'