Skip to content

Ensure the body parameter name is preserved - #967

Merged
gracekarina merged 4 commits into
swagger-api:masterfrom
OpenAPITools:preserve-body-parameter-name
Sep 10, 2019
Merged

gracekarina merged 4 commits into
swagger-api:masterfrom
OpenAPITools:preserve-body-parameter-name

Conversation

@wing328

@wing328 wing328 commented Dec 18, 2018 •

Copy link
Copy Markdown
Contributor

For #966

Related: #748

@jmini

jmini commented Dec 20, 2018

Copy link
Copy Markdown
Contributor

Is there any feedback on this PR?

Are you rejecting the proposition?
Or have you any concerns about this?

A while ago I did open a similar issue about preserving the name of the body parameter from the v2 Spec as extension in v3: #748
Back then I proposed an other approach (an other name, an other position of the extension), but the idea is the same and for me this would also be OK.

Please let us know if we can do anything to help this feature to moving forward (this PR can be rewritten if an other design decision is considered)

jmini added a commit to OpenAPITools/swagger-parser that referenced this pull request Dec 20, 2018
@advance512

Copy link
Copy Markdown

Please move forward with this. It has been a month and still no response - this causes major issues in dependent projects. Thank you

@JonathanParrilla

Copy link
Copy Markdown
Contributor

please build

formParams.add(param);
} else if ("body".equals(param.getIn())) {
operation.setRequestBody(convertParameterToRequestBody(param, v2Operation.getConsumes()));
operation.addExtension("x-codegen-request-body-name", param.getName());

@blast-hardcheese blast-hardcheese Apr 24, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems as though the name field's intent has been replaced by title, as evidenced by how the string "body" gets resolved in the converter:

String modelName = resolveModelName(model.getTitle(), "body");

where
private String resolveModelName(String title, String key) {
if (title == null) {
return uniqueName(key);
} else {
return uniqueName(title);
}
}

I would propose a different direction, instead of adding a vendor extension, to just setTitle(param.getName()) and let the rest of the infrastructure wire the parameter through.

This will seamlessly resolve the issue for those who have migrated to the new title infrastructure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gracekarina Out of curiosity, any thoughts on the direction of this comment? I still suspect adding a vendor extension that duplicates in-built behavior is causing a needless fork in functionality, but maybe I've misunderstood an aspect about the semantics between name and title here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @blast-hardcheese I'll review the comment you made, if what you say is right I'll revert the PR. thanks for pointing us to that.

@gracekarina
gracekarina merged commit 56751fa into swagger-api:master Sep 10, 2019
@wing328
wing328 deleted the preserve-body-parameter-name branch October 21, 2019 13:49
@DrSatyr

DrSatyr commented Feb 17, 2021

Copy link
Copy Markdown

@wing328 could you please describe the purposes of this "x-codegen-request-body-name" extension. I am trying to figure out it and decide is it needed in my case or not. Am I right that it's needed for code generation in some languages?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants