OpenAPITools / OpenAPITools/openapi-generator
[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
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the supplied OpenAPI generation command with the minimal JSON declaration, then compile the generated sample_client.nim to reproduce the failure. Trace the Nim generator's enum handling and identifier validation; done means generated code compiles when enum values such as "a!a", "b?b", and "c%c" are present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nim
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100