Skip to content
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

[BUG][KOTLIN] Generated code contains "`" instead of backtick, when using parameters with reserved kotlin names #11304

Open
4 of 6 tasks
knutjda opened this issue Jan 13, 2022 · 2 comments · Fixed by #11310

Comments

@knutjda
Copy link
Contributor

knutjda commented Jan 13, 2022

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When generating kotlin code using 'kotlin' generator, and one of the parameters is in reserved kotlin names, the generated code contains backtick "`" encoded as HTML entity: ` in the Api-class:

fun test(`value`: kotlin.String) : Unit { ... }

fun testWithHttpInfo(&#x60;value&#x60;: kotlin.String) : ApiResponse<Unit?> { ... }

fun testRequestConfig(&#x60;value&#x60;: kotlin.String) : RequestConfig<Unit> { ... }

And that will not compile very well.

openapi-generator version

5.3.1

OpenAPI declaration file content or url
openapi: 3.0.3
info:
  title: Kotlin Issue
  version: "1.0"

servers:
  - url: "http://localhost"

paths:
  /test/{value}:
    post:
      summary: test
      operationId: test
      parameters:
        - name: value
          in: path
          required: true
          schema:
            type: string
          example: something
      responses:
        '200':
          description: OK
Generation Details
openapi-generator-cli generate -i temp.yml -g kotlin
Steps to reproduce

generate code and open DefaultApi.kt

Related issues/PRs

This is related to #11148

Suggest a fix
@wing328
Copy link
Member

wing328 commented Jan 14, 2022

@knutjda thanks for the PR.

cc @jimschubert (2017/09) ❤️, @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03)

@ti8m-sil
Copy link

This issue is still present in the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants