swagger-api / swagger-api/swagger-codegen
[C#] Invalid C# enum generated when allOf is used
@HugoMario is already working on this.
Since May 12, 2020.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
We're composing a model with allOf. It has a string enum as one of the properties. The C# code generated by swagger-codegen does not compile. If I remove allOf and explicitly describe the data model, the enum is generated correctly.
Swagger-codegen version
2.3.1
Swagger declaration file content or url
For this json definition, which uses allOf, the generated enum for ActivityType in the Models namespace is not valid C#.
This json file, without allOf, will generate the correct enum.
Command line used for generation
swagger-codegen generate -i ./bad_enum.json -l csharp -o ./output_bad/
Steps to reproduce
- Run the example command against the bad_enum.json from the gist linked above.
- Observe that the
ActivityType.csfile defines an invalid enum with circular references. - Run the example command agains the good_enum.json from the other gist linked above.
- Observe the correctly defined enum in
ActivityType.csfor this output.
Related issues/PRs
Similar to #3338, although in my case the generator is able to output code, but the code will not compile.
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.
Assessment
This issue has not been assessed yet.