[Dart] Fix parameter names with {{baseName}} #5019
Merged
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.→ ran bin/dart-petstore.sh, with no changes in the produced samples.
Description of the PR
This fixes (or hopes to fix) part of #4898 for the
dartgenerator.The problem likely occurred when a path parameter name (as declared in the OpenAPI definition) is of a form which doesn't match the form used in Dart, or is a reserved word there. In this case the parameter gets renamed for use in the code, and the algorithm for creating the actual path tries to replace the renamed parameter in the path (which will do nothing), not the original one (which would be correct).
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).Our Petstore API definition doesn't seem to contain a path parameter which would get modified by the sanitation, therefore there is no difference in the generated samples.
I don't know anything about Dart, so this needs review by Dart experts. /cc @yissachar @close2 @ircecho @hcwilhelm