Description
If a query parameter contains a colon, the generated code is broken since they are interpreted as type information by the typescript compiler.
Swagger-codegen version
2.2.1 - This is not a regression
Swagger declaration file content or url
{
"swaggerVersion": "1.2",
"basePath": "http://localhost:8000/greetings",
"apis": [
{
"path": "/hello/{subject:main}",
"operations": [
{
"method": "GET",
"type": "string",
"parameters": [
{
"name": "subject:main",
"type": "string",
"paramType": "path"
}
]
}
]
}
],
"models": {}
}
Command line used for generation
swagger-codegen generate -i hello.json -l typescript-fetch -o generated
Steps to reproduce
Grep for subject:main in the generated code.
Suggest a Fix
- escape all usage of the dot notation to refer to parameters in
api.mustache. So replacing params.{{paramName}} by params["{{paramName}}"]
- Also replace the param names when they are referred to as interface keys:
{paramName: xxx} becomes {"paramName": xxx}
Description
If a query parameter contains a colon, the generated code is broken since they are interpreted as type information by the typescript compiler.
Swagger-codegen version
2.2.1 - This is not a regression
Swagger declaration file content or url
{ "swaggerVersion": "1.2", "basePath": "http://localhost:8000/greetings", "apis": [ { "path": "/hello/{subject:main}", "operations": [ { "method": "GET", "type": "string", "parameters": [ { "name": "subject:main", "type": "string", "paramType": "path" } ] } ] } ], "models": {} }Command line used for generation
swagger-codegen generate -i hello.json -l typescript-fetch -o generated
Steps to reproduce
Grep for
subject:mainin the generated code.Suggest a Fix
api.mustache. So replacingparams.{{paramName}}byparams["{{paramName}}"]{paramName: xxx}becomes{"paramName": xxx}