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-spring] Escaped backticks in parameters using reserved words #18317

Closed
5 of 6 tasks
franciscobretal opened this issue Apr 7, 2024 · 0 comments · Fixed by #18318
Closed
5 of 6 tasks

[BUG] [kotlin-spring] Escaped backticks in parameters using reserved words #18317

franciscobretal opened this issue Apr 7, 2024 · 0 comments · Fixed by #18318

Comments

@franciscobretal
Copy link
Contributor

franciscobretal commented Apr 7, 2024

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 an OpenAPI definition contains parameters named with kotlin reserved-words, instead of generating code with those names between backticks (e.g. `when`), they are escaped with HMTL character ` (i.e. `is`).

openapi-generator version

7.4.0

OpenAPI declaration file content or url
openapi: "3.0.0"
info:
  version: "1.0.0"
  title: "Minimal OpenAPI example"
paths:
  /test:
    get:
      parameters: 
        - name: "when"
          in: "query"
          schema:
            type: "string"
        - name: "as"
          in: "header"
          schema:
            type: "string"
        - name: "is"
          in: "path"
          required: true
          schema:
            type: "string"
        - name: "param"
          in: "cookie"
          schema:
            type: "string"
      responses:
        '200':
          description: "Successful operation"
    post:
      requestBody:
          content:
            application/x-www-form-urlencoded:
              schema:
                type: object
                properties:
                  is:
                    type: string
      responses:
        '200':
          description: "Successful operation"
Generation Details

Use the following cli command assuming the previous definition is in a openapi.yml file:

openapi-generator-cli generate -i openapi.yml -g kotlin-spring -o out -t -p serviceImplementation=true -p interfaceOnly=true -p delegatePattern=true
Steps to reproduce

Open the generated directory in your favorite code editor and do a global search for `. You should see multiple occurrences, which make the code not compilable.

Related issues/PRs

Related to:

Suggest a fix

If {{paramName}} is changed to {{{paramName}}} in every template file, the code generates successfully.

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