Skip to content

[BUG][aspnetcore] Duplicated enum models #4087

@yilinjuang

Description

@yilinjuang

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
  1. generate
  2. TestEnum is generated both in TestEnum.cs and TestObject.cs
Related issues/PRs

#3622, #3855

Suggest a fix

Is there any other way to tell if an enum is referenced or inlined?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions