-
Notifications
You must be signed in to change notification settings - Fork 37
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
Kotlin support of Square Bracket on variable name causing an issue with query parameters' kotlin variable names with square brackets as syntax error #31
Comments
@yudhir Thanks for the report. Can you also post the spec that you used to generate the code you posted? |
Basically, this parameter with datePosted[before], square brackets, the variable names could use dateposted_before_ and so on . No other errors. |
Yup we could do that. The problem I envision is that those two properties will then clash:
The underscore approach sounds reasonable, although the parameter name won't look great :/ |
It generates
for category-newsarticle to solve a similar problem with "-" as variable name |
@cortinico : I think that we might tweak https://github.com/Yelp/swagger-gradle-codegen/blob/master/plugin/src/main/java/com/yelp/codegen/utils/KotlinLangUtils.kt#L160 or https://github.com/Yelp/swagger-gradle-codegen/blob/master/plugin/src/main/java/com/yelp/codegen/KotlinGenerator.kt#L147 to achieve the desired objective. NOTE: Modifying the sanitisation method would solve the edce case presented on this issue but it might open-up ways to have parameter name clashing (ie. @yudhir : In the issue description you listed you cases where the generated code "mis-behave". Could you please post the specs of the second example as well? My feeling is that in the second case the specs are weird as you could have multiple |
|
@yudhir as mentioned in the comment above we might have name clashing for parameter names like By checking the last snippet of the specs I see an anti-pattern with the ...
paths:
/api/cities:
get:
parameters:
- name: id
in: query
required: false
type: array
items:
type: integer
collectionFormat: multi
... The definition of the
Defining In the next days we, me or @cortinico, might be trying to put some effort on the sanitisation process. If you bandwidth and you could publish a PR doing that it would be really appreciated. |
Names with square brackets and other reserved keywords must be read. Swaggergencli does this
|
The generator is broken for operations with parameters that have square brackets in the name. Apparently the version of Swagger Codegen that we're using is not excluding `[` and `]` when doing the camelization of the parameter name. Fixes #31
A type annotation is required on the value parameter.
Another Example
The text was updated successfully, but these errors were encountered: