[Groovy] Fix parameter names with {{baseName}}#5030
Merged
wing328 merged 2 commits intoswagger-api:masterfrom Mar 13, 2017
Merged
[Groovy] Fix parameter names with {{baseName}}#5030wing328 merged 2 commits intoswagger-api:masterfrom
wing328 merged 2 commits intoswagger-api:masterfrom
Conversation
fbf6309 to
f59262d
Compare
added 2 commits
March 12, 2017 20:39
This also adds some TODOs for the missing path, form and body parameters.
f59262d to
bda0eff
Compare
Contributor
|
@ePaul the fix looks good to me. I should be able to add the path parameter support. |
spr3nk3ls
pushed a commit
to spr3nk3ls/swagger-codegen
that referenced
this pull request
Mar 28, 2017
* Fix (partially) swagger-api#4898 for groovy. This also adds some TODOs for the missing path, form and body parameters. * Update Groovy samples (after partial fix for swagger-api#4898)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR checklist
./bin/to update Petstore sample so that CIs can verify the change.→ bin/groovy-petstore.sh
Description of the PR
This fixes (or hopes to fix) part of #4898 for the
groovygenerator.The problem likely occurred when a query or header parameter name (as declared in the OpenAPI definition) is of a form which doesn't match the form used in Groovy, or is a reserved word there. In this case the parameter gets renamed for use in the code, and the parameter will be sent with the sanitized name instead of the original one.
This commit changes the replacement to using
{{baseName}}(which is the original name of the parameter definition as parsed from the API definition) instead of{{paramName}}(which is the sanitized version of the parameter name).Note that it looks like the Groovy generator has no support at all for path, form or body parameters – those are accepted by the generated code, but then ignored, and not passed to the server. I didn't try to fix this, as my Groovy knowledge is too rusty for this, but added some TODOs in the template. Related issue: #4289
Our Petstore sample API definition doesn't seem to contain any query parameter which would get modified by the sanitation, so the regenerated samples just have a single difference in a header parameter (which looks better now to me).
I don't know anything about Groovy, so this needs review by Groovy experts.