OpenAPITools / OpenAPITools/openapi-generator
Line 7115 Bug fixed from "“modules/openapi- generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java” route.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
// CORRECT CODE
if (mostInnerItem == null) { // If "mostInnerItem" is null, then we throw an exception with an error message.
throw new RuntimeException("mostInnerItem (codegen property of array item) cannot be null. " + arraySchema); // We throw a "RunTimeException" with an error message that indicates that "mostInnerItem" cannot be null. The message also includes the value of "arraySchema".
// "ArraySchema" has been imported via "import org.openapitools.codegen.utils.ModelUtils;" at the beginning of the project; it's an external library from OpenAPI Tools, from which OpenAPI Generator originates.
}
if (bodyParameterName != null && !bodyParameterName.isEmpty()) { // If "bodyParameterName" is not null and not empty... --- THIS LINE HAS BEEN MODIFIED ---
if (StringUtils.isEmpty(mostInnerItem.complexType)) { // If the "mostInnerItem" object has an empty "complexType" property...
codegenParameter.baseName = "request_body"; // We set the value of the "codegenParameter.baseName" property to "request_body".
} else {
codegenParameter.baseName = mostInnerItem.complexType; // Otherwise, we set the value of the "codegenParameter.baseName" property to the value of the "complexType" property of "mostInnerItem".
}
} else {
codegenParameter.baseName = "request_body"; // If "bodyParameterName" is null or empty, we set the default value "request_body" for "codegenParameter.baseName". --- THIS LINE HAS BEEN MODIFIED ---
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java around line 7115 and the supplied conditional changes. Trace how bodyParameterName, mostInnerItem, arraySchema, and codegenParameter.baseName are used, then identify a reproducible generator case and an appropriate regression test; done means the reported route behavior is corrected and covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100