[csharp] Generated enumerations as query parameters not compiling
Created by: rubms
Description
When specifying query parameters as enumerations, the autogenerated code uses the enumeration type, instead of making it Nullable
. This C# code fails compile when those query parameters are assigned null
because C# enumerations are not nullable (they are not objects, as Java enumerations).
The expected behavior is to generate nullable enumerations: EnumClass? varName
.
openapi-generator version
This is reproduced with openapi-generator v3.3.3 (current master).
OpenAPI declaration file content or url
openapi: 3.0.0
info:
description: "This spec is for testing the wrong generation of enumerations in query parameters"
version: 1.0.0
title: Enumerations test case
paths:
/enum_test/:
get:
tags:
- Enums
summary: Get with enumeration query params.
description: Get with enumeration query params.
operationId: getEnumTest
parameters:
- name: testEnum
in: query
schema:
$ref: "#/components/schemas/EnumClass"
responses:
'200':
description: successful operation
components:
schemas:
EnumClass:
type: string
enum:
- Value1
- Value2
- Value3
Command line used for generation
java -jar openapi-generator-cli-3.3.3.jar generate -g csharp -i test.yml -o test
Steps to reproduce
Run the openapi-generator using the csharp
generator and the attached OpenApi specification. The generated C# code will not compile because enumerations in C# are not nullable.
Suggest a fix/enhancement
Enumerations should be generated nullable instead.