OpenAPITools / OpenAPITools/openapi-generator
[BUG][CSHARP-NETCORE] Type boolean with enum constraint produces incorrect code.
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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
Description
In an API, that constrains a boolean to true (via enum), it will produce invalid code when using the csharp-dotnet generator.
openapi-generator version
openapi-generator-cli-5.4.0-20220124.094022-41.jar
openapi-generator-cli-6.0.0-20220104.102705-29.jar
OpenAPI declaration file content or url
CurrencyUpdate:
type: object
properties:
default:
type: boolean
format: boolean
example: true
enum:
- true
Generation Details
Output:
[JsonConverter(typeof(StringEnumConverter))]
public enum DefaultEnum
{
/// <summary>
/// Enum True for value: true
/// </summary>
True = true //error - invalid
}
Steps to reproduce
java -jar openapi-generator-cli-5.4.0-20220124.094022-41.jar generate -i https://api-docs.firefly-iii.org/firefly-iii-1.5.4.yaml -g csharp-netcore -o ./output/
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
Start by running the csharp-netcore generator with the supplied OpenAPI declaration and reproduction command, then trace how the boolean enum is represented in the generated C# output. Done means the constrained boolean produces valid C# without the invalid enum assignment and the original reproduction no longer fails.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, java, openapi
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100