Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #11447
Closed
Open
Issue created Jan 29, 2022 by Administrator@rootContributor5 of 5 checklist items completed5/5 checklist items

[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

Suggest a fix
Assignee
Assign to
Time tracking