swagger-api / swagger-api/swagger-codegen
[C#] Warning CS0472 for "required" enum parameters
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When marking an enum parameter as required, i am getting the following warning:
warning CS0472: The result of the expression is always 'false' since a value of type 'Order.IdEnum' is never equal to 'null' of type 'Order.IdEnum?'
Swagger-codegen version
It is happening with latest master branch (dbd0a4bb535de0d587c9ccec1465a25c8288ee96).
Swagger declaration file content or url
Here is a simplified code to reproduce the issue:
definitions:
Order:
type: "object"
required:
- id
properties:
id:
type: "string"
enum:
- Value
Command line used for generation
java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i c:\temp\cs_warning.yaml -l csharp -o c:\temp\out
Steps to reproduce
Generate C# code with the above yaml code and compile the generated 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
Start with the simplified YAML definition and run the documented swagger-codegen CLI command with the csharp generator. Inspect the generated C# for the required enum parameter and the nullable comparison that produces CS0472. Done means the generated code compiles without that warning for the reproduction case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100