[BUG] [csharp-netcore] Parameter of type Enum will not use EnumMember attribute but rather serialise Enum.Tostring()
Created by: jafin
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?
Description
A Get query that takes an enum string type as a parameter, is not serializing into the correct value. Instead, it is being serialized to the Enum name
not the EnumMember value
In the below example, PetStatusFilter will return title case Available
or Pending
or Sold
. whereas it should return available
or pending
or sold
/pet/findByStatusWithFilter:
get:
tags:
- pet
summary: Finds Pets by status
description: Multiple status values can be provided with comma separated strings
operationId: findPetsByStatusWithFilter
parameters:
- name: status
in: query
description: Status values that need to be considered for filter
required: true
schema:
type: array
items:
$ref: '#/components/schemas/PetStatusFilter'
PetStatusFilter:
type: string
enum:
- available
- pending
- sold
openapi-generator version
- 5.4
- main
Generation Details
The method in ClientUtils , ParameterToString does not check if obj is an Enum, and will default return obj.ToString(). Instead, it should be looking at the Enum's EnumMember attribute fo the value to return.
Steps to reproduce
Run generator ./bin/generate-sample.sh ./bin/configs/csharp
with a modified version of the petstore.yaml including the above changes.
Related issues/PRs
None found