-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
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.