swagger-api / swagger-api/swagger-codegen
[aspnetcore] server generation in aspnetcore assigns wrong value to exampleJson
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Using aspnetcore code gen on the Swagger API specified below assigns wrong value to exampleJson in DefaultApi.cs. This is cut down as far as I can to show just the problem. This is a problem because I was planning to use this value in testing / demo code. (Yes, it can be hand-edited but that defeats the purpose of code gen and the real version is much larger.)
Here is the Example Value / Model output, which is correct:
{
"aa_list": [
{
"list": [
{
"aa_position": 0
},
{
"aa_position": 1
}
]
}
]
}
Here is the corresponding JSON example in the aspnetcore code:
exampleJson = "{\n \"aa_list\" : [ {\n \"list\" : [ {\n \"aa_position\" : 0\n }, {\n \"aa_position\" : 1\n } ]\n }, {\n \"list\" : [ {\n \"aa_position\" : 0\n }, {\n \"aa_position\" : 1\n } ]\n } ]\n}";
The aspnetcore code has the "list" member and its entire contents duplicated.
Swagger-codegen version
SwaggerHub (app.swaggerhub.com)
Swagger declaration file content or url
https://app.swaggerhub.com/apis/JohnBoncek/ArrayProblemRepro/1
Command line used for generation
No command line.
Steps to reproduce
In SwaggerHub at the above URL, choose Export > Server Stub > aspnetcore and examine the generated code in src\IO.Swagger\Controllers\DefaultApi.cs.
Related issues/PRs
None known.
Suggest a fix/enhancement
Generate the correct code.
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 SwaggerHub Export > Server Stub > aspnetcore result and inspect src\IO.Swagger\Controllers\DefaultApi.cs, focusing on the duplicated list in exampleJson. Compare the generated JSON with the example/model output from the linked Swagger declaration; done means the list appears once with the expected contents.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100