Bug Report Checklist
Description
With the introduction of #21002 we get the possibility of a nullpointer when an allOf is used.
openapi-generator version
Version 7.0.12 and before it works, after not.
OpenAPI declaration file content or url
"components": {
"schemas": {
"AnOldObject": {
"allOf": [
{
"$ref": "#/components/schemas/ANewObject"
},
{
"type": "object",
"additionalProperties": false
}
]
},
"ANewObject": {
"allOf": [
{
"$ref": "#/components/schemas/AnotherObject"
},
{
"type": "object",
"description": "A dummy description.",
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"nullable": true
}
}
}
]
},
"AnotherObject": {
"type": "object",
"description": "A different description.",
"x-abstract": true,
"additionalProperties": false,
"properties": {
"context": {
"type": "string",
"nullable": true
}
}
}
}
}
Generation Details
Build with maven and protobuf-schema
Steps to reproduce
Build it with maven protobuf-schema have a allOf without additionalProperties (it set to false)
Related issues/PRs
Introduced with #21002
Suggest a fix
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java#L1102 will in this case get a Boolean object with false value and passes the nullcheck.
It later looks at getting the schema for it(that does not exists) with
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java#L1107
This will return a null. And on the line after we get a nullpointer:
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java#L1108
Probably should use the same ModelUtils in the outer if-statement.
Bug Report Checklist
Description
With the introduction of #21002 we get the possibility of a nullpointer when an allOf is used.
openapi-generator version
Version 7.0.12 and before it works, after not.
OpenAPI declaration file content or url
Generation Details
Build with maven and protobuf-schema
Steps to reproduce
Build it with maven protobuf-schema have a allOf without additionalProperties (it set to false)
Related issues/PRs
Introduced with #21002
Suggest a fix
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java#L1102 will in this case get a Boolean object with false value and passes the nullcheck.
It later looks at getting the schema for it(that does not exists) with
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java#L1107
This will return a null. And on the line after we get a nullpointer:
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ProtobufSchemaCodegen.java#L1108
Probably should use the same ModelUtils in the outer if-statement.