mtennoe / swagger-typescript-codegen

A Swagger Codegenerator tailored for typescript.
Apache License 2.0
140 stars 52 forks source link

Path params not uri encoded. #92

Closed Shahab96 closed 4 years ago

Shahab96 commented 4 years ago

The path appended to the domain may contain strings that have special characters but are not uri encoded.

https://github.com/mtennoe/swagger-typescript-codegen/blob/fbd3d7ad90c57022c7b116a97b93a1ec9cca2ac3/templates/method.mustache#L96

An example of this could be '/someurl/{SomeParam}' evaluating to '/someurl/Some/Param' if SomeParam is 'Some/Param'

This would result in a bad request, where the backend may be expecting something like "Some/Param", for which the request should look like '/someurl/Some%2FParam'

mtennoe commented 4 years ago

Yo, and thanks for reporting!

Are you using a custom mustache template? The reason I am asking is that in method.mustache we are running URI encoding on all the queryparameters, so this should already be handled in the code generated output: image Since its in the default template though, it will not be handled automatically if using a custom template

Shahab96 commented 4 years ago

Hi! We aren't using a custom template. The issue is not that query params are not encoded but that the path params are not encoded. For example. domain.com/users/{someUser}/etc?someParam=value

someUser in this case is not url encoded.

mtennoe commented 4 years ago

Gotcha, I see what you mean now, thanks! Do you want to attempt a fix? If not I will try to get the time during this week some time

Shahab96 commented 4 years ago

I'll attempt a fix and submit a PR. Thank you!

mtennoe commented 4 years ago

Fixed in #94