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