OpenAPITools / OpenAPITools/openapi-generator
[BUG][aspnetcore] Duplicated enum models
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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?
Description
The issue was fixed in #3622 based on isModel attribute. If the enum has isModel set to true, then the enum isn't generated in objects it's referenced. However, looks like how isModel is set was changed in #3855 . Now enums no longer have isModel set.
openapi-generator version
4.2.0 master
OpenAPI declaration file content or url
openapi: 3.0.2
info:
title: Test
version: 0.1.0
servers:
- url: http://localhost
paths:
/:
post:
operationId: test
responses:
200:
description: test
components:
schemas:
TestObject:
type: object
properties:
enumInObject:
$ref: "#/components/schemas/TestEnum"
TestEnum:
type: string
enum:
- value1
- value2
Command line used for generation
openapi-generator generate -g aspnetcore
Steps to reproduce
- generate
TestEnumis generated both inTestEnum.csandTestObject.cs
Related issues/PRs
#3622, #3855
Suggest a fix
Is there any other way to tell if an enum is referenced or inlined?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the duplication with the openapi-generator generate -g aspnetcore command and the YAML declaration in the issue. Review the behavior and changes described in #3622 and #3855, then verify that the generated output contains TestEnum only once, rather than in both TestEnum.cs and TestObject.cs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, openapi
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100