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
  • #5024
Closed
Open
Issue created Jan 17, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] Duplicate Enums are being generated rather than enum type being referenced in model

Created by: binaryunary

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

An enum type is generated twice instead of being generated once and then referenced from client code.

openapi-generator version

4.2.3-SNAPSHOT

OpenAPI declaration file content or url
openapi: '3.0.0'
info:
  version: 1.0.0
  title: API with Default Values
servers:
  - url: http://localhost:8080
paths:
  /test:
    post:
      operationId: testDefaults
      requestBody:
        required: true
        content:
          application/json:
            schema:
              '$ref': '#/components/schemas/Payload'
      responses:
        '200':
          description: Ok
components:
  schemas:
    Payload:
      type: object
      properties:
        stringProp:
          type: string
          default: foo
        doubleProp:
          type: number
          format: double
          default: 1.234
        enumProp:
          $ref: '#/components/schemas/EnumProp'
    EnumProp:
          type: string
          enum: [One, Two, Three]
          default: Two
Command line used for generation
docker run --rm --user "$(id -u):$(id -g)" -v ${PWD}:/local openapitools/openapi-generator-cli generate -i /local/enum.yml -g aspnetcore -o /local/out -p aspnetVersion=3.0 -Dmodels
Steps to reproduce

Save the YAML as enum.yml and run the above command.

Related issues/PRs

https://github.com/OpenAPITools/openapi-generator/issues/3582

Suggest a fix

This seems to work as expected with -g csharp.

Assignee
Assign to
Time tracking