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] [Nim] Generated code does not compile if one schema contains a keyword 'enum' and one of the enum values is not a valid Nim identifier #20779

Open
1 task
sandwoodK opened this issue Mar 3, 2025 · 0 comments

Comments

@sandwoodK
Copy link
Contributor

sandwoodK commented Mar 3, 2025

Bug Report Checklist

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

[Nim] Generated code does not compile if one schema constains a keyword 'enum' and one of the enum values is not a valid Nim identifier.
Identifier validity of Nim is not respected, code can not compile.

openapi-generator version

7.11, master.

OpenAPI declaration file content or url
{
    "openapi": "3.0.0",
    "info": {
      "title" : "mre",
      "version": "1.0.0"
    },
    "servers": [{
        "url": "/"
      }],
    "paths": {
        "/foo": {
            "description" : "foopath",
            "get": {
                "operationId" : "GetFoo",
          "description" : "get operation",
          "parameters": [
            {
              "name": "param1",
              "in": "query",
              "schema": {
                  "type": "string"
              }
            }
          ],
          "responses": {
            "200": {
              "description" : "someresponse",
              "content": {
                "application/json": {
                  "schema": {
                      "type": "object",
                      "properties": {
                          "the_resp" : {
                              "type" : "string",
                              "enum" : ["a!a", "b?b", "c%c"]
                          }
                      }
                  }
                }
              }
            }
          }
        }
      }
    }
}
Generation Details

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g nim -i ~/mre.json -o ~/mre_client

Steps to reproduce

cd ~/mre_client
nim compile sample_client.nim

Related issues/PRs

None

Suggest a fix
@sandwoodK sandwoodK changed the title [BUG] [Nim] Generated code does not compile if one schema constains a keyword 'enum' and one of the enum values is not a valid Nim identifier [BUG] [Nim] Generated code does not compile if one schema contains a keyword 'enum' and one of the enum values is not a valid Nim identifier Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant