Skip to content

[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
@sandwoodK

Description

@sandwoodK

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions