You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fix would be to handle correctly if the schema is composed.
I've tried a simple patch:
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java
index 82cebbf022..17edf00ddb 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java@@ -5517,8 +5517,11 @@ public class DefaultCodegen implements CodegenConfig {
LOGGER.debug("debugging fromRequestBodyToFormParameters= " + body);
Schema schema = ModelUtils.getSchemaFromRequestBody(body);
schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
- if (schema.getProperties() != null && !schema.getProperties().isEmpty()) {- Map<String, Schema> properties = schema.getProperties();+ List<String> allRequired = new ArrayList<String>();+ Map<String, Schema> properties = new LinkedHashMap<>();+ addProperties(properties, allRequired, schema);++ if (!properties.isEmpty()) {
for (Map.Entry<String, Schema> entry : properties.entrySet()) {
CodegenParameter codegenParameter = CodegenModelFactory.newInstance(CodegenModelType.PARAMETER);
// key => property name
After the patch, the generated code looks right:
// new code - after the patch has been appliedvoidchangeCurrentUserPassword(@FormParam(value = "password") Stringpassword,@FormParam(value = "passwordConfirmation") StringpasswordConfirmation,@FormParam(value = "oldPassword") StringoldPassword);
// old codevoidchangeCurrentUserPassword();
The text was updated successfully, but these errors were encountered:
Bug Report Checklist
Description
To define multipart content you typically do something like that:
However, if the schema is composed (using
allOf
) the inherited properties are ignored.In the provided case, it generates a method without ANY parameters:
openapi-generator version
4.3.0
OpenAPI declaration file content or url
https://gist.github.com/vvalchev/54a935c0f93c06a184a9eeb1640f96e6#file-api-yml
Command line used for generation
I'm using the following maven pom.xml file to generate the sources:
https://gist.github.com/vvalchev/54a935c0f93c06a184a9eeb1640f96e6#file-pom-xml
Steps to reproduce
mvn compile
Related issues/PRs
Suggest a fix
The fix would be to handle correctly if the schema is composed.
I've tried a simple patch:
After the patch, the generated code looks right:
The text was updated successfully, but these errors were encountered: