OpenAPITools / OpenAPITools/openapi-generator
[BUG] aspnetcore enum generation
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Openapi Generator 4.3.0 using latest master branch as 20/02/2020.
I have setup the enum in openapi as:
TestEnum:
type: integer
enum:
- 1
- 2
- 4
- 5
x-enum-varnames:
- testa
- testb
- testc
- testd
However, upon generation it still sets it as string type and does not assign the numeric values to the relative name
[TypeConverter(typeof(CustomEnumConverter<TestEnum>))]
[JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
public enum TestEnum
{
[EnumMember(Value = "1")]
testa= 1,
[EnumMember(Value = "2")]
testb = 2,
[EnumMember(Value = "4")]
testc = 3,
[EnumMember(Value = "5")]
testd = 4
}
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 reproducing the supplied OpenAPI enum schema with the aspnetcore generator and inspect the enum-generation path. Compare the generated TestEnum with the expected numeric assignments; done means numeric values 1, 2, 4, and 5 are preserved and the enum is not treated as a string.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100