Open Spencatro opened 8 years ago
@shawkinsl thanks for reporting the issue. Please open a PR and we'll review the change.
@shawkinsl may I know if you need any help submitting a PR?
@shawkinsl thanks for the PR and details in reporting the issue.
I think your fix will partially resolve the issue. For parameter name with special characters (e.g. created-at
), I believe it will cause issue as the parameter name is not sanitized to conform to Python variable naming rule.
I believe we need a mapping similar to what we've done in https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/python/petstore_api/apis/pet_api.py#L754
Description
When using swagger-codegen to generate a flask server, connexion and swagger-codegen do not agree on how to represent parameter names, which leads to connexion making requests to endpoints with variable names that do not match the output of swagger-codegen.
Swagger-codegen version
Using swagger-codegen built from source off of master at time of issue being opened (2e402da3efdc63c1fb6ae2238b171c7f488be80b is latest commit)
Swagger declaration file content or url
simpletest.yaml :
This command generates controllers/default_controller.py with the following contents:
But it should generate these contents instead:
Command line used for generation
swagger-codegen generate -i simpletest.yaml -l python-flask -o simple_out_before_fix
Steps to reproduce
1: Generate this server 2: Start the flask server 3: Attempt to make the get request 4: Flask 500 errors
Related issues
Appears to be related to https://github.com/swagger-api/swagger-codegen/issues/1938 , but I don't believe the fix implemented there goes far enough to fix the underlying issue (parameter names should not be modified at all, or rather, should be modified in the same way connexion expects them i.e. not at all).
Suggest a Fix
Suggested fix: changes in commit https://github.com/shawkinsl/swagger-codegen/commit/756f0ed64e60a5a3fe2c70ebee4a34d7a7b68abe . If changes are acceptable, I will open a PR.
It's worth noting that there are likely other edge cases that this fix does not resolve, but this is what I am able and willing to implement at the moment.