OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.33k stars 6.46k forks source link

[BUG][Kotlin] Query params are converted from snake_case to camelCase #4819

Open facundomedica opened 4 years ago

facundomedica commented 4 years ago
Description

A query param that is in snake case is converted to camelCase in the generated code, so the requests do myendpoint?deviceId=AAAAA instead of myendpoint?device_id=AAAAA

        - name: device_id
          in: query
          description: device external ID
          type: string
openapi-generator version
openapi-generator-gradle-plugin:4.2.2
OpenAPI declaration file content or url
        - name: device_id
          in: query
          description: device external ID
          type: string
oharaandrew314 commented 4 years ago

This is also an issue for Python form-data in https://github.com/OpenAPITools/openapi-generator/issues/4796

I wonder if this issue is universal, and not language specific.

UPDATE: Confirmed this is a language specific issue. Until someone is brave enough to sort out that mess, an acceptable workaround would be to use the java generator.

I debugged a bit and found where the client template uses the parameter: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/kotlin-client/api.mustache#L41

But I'm not sure where that parameter is generated and added to the mustache json.

varunupadhyay28 commented 4 years ago

@wing328 I am also facing this issue. Is the #2976 a fix for this?