-
Notifications
You must be signed in to change notification settings - Fork 6k
[Swift3] Fix bug where non-camel-case path params didn't work. #5267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Swift3] Fix bug where non-camel-case path params didn't work. #5267
Conversation
|
@GriffinSchneider I'm wondering what cases that code was originally added to solve - I think it would be worth adding in some tests for your cases and the original cases this code was meant to add to make sure we cover everything here. |
|
Here's what I think happened: The problem area in the swift3 templates is here: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/swift3/api.mustache#L107-L108 Before #4916, we used to be calling Then, to fix #4898, So, my fix is simply to remove I will attempt to add a test that would have caught this issue, by including a non-camel-case path parameter in the petstore specs. |
… integration tests now pass.
|
While trying to create a test for my original bug, I noticed a separate unrelated bug that was already breaking the swift3 tests. For enums of integer and long, that template was generating code that would work for integers or longs, but did not compile for enums of integer or long. c61f0cc fixes it. The swift3 tests now pass. |
…dpoints-models-for-testing. This would have caused the Swift3 tests to be broken before 7387e49.
|
@jaz-ah OK, I've changed the tests so that they would have failed due to path parameter issues before this pull request. |
|
@GriffinSchneider thx for the extra effort here! @wing328 +1 |
|
@GriffinSchneider thanks for fixing the tests. @jaz-ah thanks for reviewing the change. |
…er-api#5267) * [Swift3] Fix bug where non-camel-case path params didn't work. * [Swift3] Fix bug where int enums generated non-compiling code. Swift3 integration tests now pass. * [Swift3] Add a non-camel-case path parameter to petstore-with-fake-endpoints-models-for-testing. This would have caused the Swift3 tests to be broken before 7387e49.
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)2.3.0branch for breaking (non-backward compatible) changes.Description of the PR
Since #4916, path parameters that aren't in camel case have been broken.
When there are path parameters, code is generated like this:
note that the path contains
{accountId}, but we're trying to replace{account_id}, so it will never work. This is because thenormalizePathfunction was camel-casing path parameters in the path.This pullreq removes
normalizePath, so the generated code now looks like this:and the replacement will work.