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
  • #1531
Closed
Open
Issue created Nov 23, 2018 by Administrator@rootContributor

[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.

Assignee
Assign to
Time tracking