swagger-api / swagger-api/swagger-codegen
Code Generation of Enum attributes in aspnetcore server omits quotes.
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Code Generation of Enum attributes in aspnetcore server omits quotes.
Swagger-codegen version
2.3.1
Swagger declaration file content or url
https://gist.github.com/dpmartin990/d38d14b160998ce0ad780d6b3df3e1b1
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i "C:\Users\dmartin3\Documents\PE\GitHub\Sandbox\MyCode\MyCode\swagger.forservergeneration.json" -l aspnetcore -o "C:\Users\dmartin3\Documents\PE\GitHub\Sandbox\XXXCompany.API.Admin" -D"packageName"="XXXCompany.API.Admin"
(Note I replaced my real company name with this fake one.)
Steps to reproduce
Files were generated as expected, when I opened the solution in VS 2007 latest updates I had to
-
Remove the project and then re-add it, I see others have used this workaround since the project will not load
-
Do a search and replace looking for Enum attributes like the below and change them to have quotes, i.e.
[EnumMember(Value = TypeMismatch)] TypeMismatchEnum = 6
to this:
[EnumMember(Value = "TypeMismatch")]
TypeMismatchEnum = 6
Related issues/PRs
I could not find any related issues
Suggest a fix/enhancement
I think it should be a simple matter of adding quotes in the code. Not sure quite what's wrong with the project file.
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 aspnetcore server generation with the linked Swagger declaration and the documented swagger-codegen command, then inspect the templates responsible for generated enum attributes. Done means generated EnumMember Value attributes contain quoted enum names and the generated project loads without the reported workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, java
- Domain
- backend, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100