diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java index 733cb69ef87c..0b3c0f245c20 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/OpenAPINormalizer.java @@ -691,7 +691,7 @@ private Schema processSimplifyOneOf(Schema schema) { // if only one element left, simplify to just the element (schema) if (schema.getOneOf().size() == 1) { - if (schema.getNullable()) { // retain nullable setting + if (Boolean.TRUE.equals(schema.getNullable())) { // retain nullable setting ((Schema) schema.getOneOf().get(0)).setNullable(true); } return (Schema) schema.getOneOf().get(0); diff --git a/modules/openapi-generator/src/test/resources/3_0/simplifyOneOfAnyOf_test.yaml b/modules/openapi-generator/src/test/resources/3_0/simplifyOneOfAnyOf_test.yaml index df1cef40b769..7130fa9ba9a3 100644 --- a/modules/openapi-generator/src/test/resources/3_0/simplifyOneOfAnyOf_test.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/simplifyOneOfAnyOf_test.yaml @@ -55,9 +55,27 @@ components: number: anyOf: - $ref: '#/components/schemas/Number' + ParentWithOneOfProperty: + type: object + properties: + number: + oneOf: + - $ref: '#/components/schemas/Number' + ParentWithPluralOneOfProperty: + type: object + properties: + number: + oneOf: + - $ref: '#/components/schemas/Number' + - $ref: '#/components/schemas/Number2' Number: enum: - one - two - three + type: string + Number2: + enum: + - one + - two type: string \ No newline at end of file