[BUG][C#] Not possible to generate nullable enum in an API model
Created by: DavidJeppesen-Seges
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I am implementing a REST API for an international standard on dairy data. The standard is expressed in JSON Schema and we use the Open API Generator to generate the model. Unfortunately - no matter what I do, I can't get the generator to generate a nullable enum on the model. I have tried adding the "nullable": true property, adding null to the list of enum values, changed the type on the property to an array with null included as a type and finally I tried changing the reference to the type on the parent to be "oneOf" and adding null. Nothing works. According to other definitions and bugs I've seen, it should be enough that the enum is not required in the specs to make it nullable. Under the assumption that it should be possible to generate a nullable enum, I would like to know how it is done and if it is not possible, then I think it is a bug.
openapi-generator version
5.1.0
OpenAPI declaration file content or url
Generation Details
PowerShell command: npx openapi-generator-cli generate -i exampleUrlScheme.json -g aspnetcore -o c:\temp\generated
Steps to reproduce
Clone the above GIT repo, navigate to the folder where the exampleUrlScheme.json file resides and run the above command. Try also the changes I mentioned in the description on any enum type. I expect a nullable enum on enum types that are not required or at least when the type in any of the above mentioned ways is defined as nullable.
Related issues/PRs
I found a couple of open issues that might be related to this bug: #4816 #9022
Suggest a fix
Sorry - my Java is very rusty!