swagger-api / swagger-api/swagger-codegen
Enum set with specific int is ignored
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
My csharp enum which starts with Regular = 1 becomes Regular = 0 after code is generated.
Swagger-codegen version 2.2.1
csharp class:
public enum UserType
{
Regular = 1,
Admin,
Ad
}
swagger.json:
"enum":["Regular","Admin","Ad"],"type":"string"
Generated code by swagger-codegen-cli:
[JsonConverter(typeof(StringEnumConverter))]
public enum TypeEnum
{
[EnumMember(Value = "Regular")]
Regular,
[EnumMember(Value = "Admin")]
Admin,
[EnumMember(Value = "Ad")]
Ad
}
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i http://localhost:61387/swagger/v1/swagger.json -l csharp -o samples/client/
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
Reproduce the issue with the supplied swagger.json and the Java CLI command, then compare the generated C# enum with the source declaration. Search the C# generator and its templates for enum handling and check whether existing tests cover explicit enum values. Done means the generated enum preserves the intended values, with a regression test documenting the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, java, openapi
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100