Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Enum wrongly generated in SDK models when used in allOf #2832

Open
kpanot opened this issue Feb 12, 2025 · 0 comments
Open

[Bug]: Enum wrongly generated in SDK models when used in allOf #2832

kpanot opened this issue Feb 12, 2025 · 0 comments
Labels
bug Something isn't working priority:high

Comments

@kpanot
Copy link
Contributor

kpanot commented Feb 12, 2025

Package name

core

Package version

11.6.3

Reproduction steps

Open API Version: 3+

When generating a specification with an object containing an enum with an allOf, the definition of the Enum is not print in the generated Typescript file.

Example of specification:

{
  "openapi": "3.0.2",
  "info": {
    "title": "Swagger Petstore - OpenAPI 3.0",
    "license": {
      "name": "Apache 2.0",
      "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
    },
    "version": "1.0.19"
  },
  "servers": [
    {
      "url": "/api/v3"
    }
  ],
  "tags": [
    {
      "name": "pet",
      "description": "Everything about your Pets",
    }
  ],
  "paths": {
    "/pet/{petId}": {
      "get": {
        "tags": [
          "pet"
        ],
        "summary": "Find pet by ID",
        "description": "Returns a single pet",
        "operationId": "getPetById",
        "parameters": [
          {
            "name": "petId",
            "in": "path",
            "description": "ID of pet to return",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Pet"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PartialPet": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          }
        }
      },
      "Pet": {
        "type": "object",
        "allOf": [
          {
            "$ref": "#/components/schemas/PartialPet"
          },
          {
            "type": "object",
            "properties": {
              "numberOfLegs": {
                "type": "string",
                "enum": [
                  "four",
                  "two"
                ]
              }
            }
          }
        ]
      }
    }
  }
}

Current result

export interface Pet {
  name?: string;
  numberOfLegs?: numberOfLegsEnum; // <- type not found
}

Expected result

export interface Pet {
  name?: string;
  numberOfLegs?: numberOfLegsEnum;
}

export type numberOfLegsEnum = 'two' | 'four';

Additional comments

No response

@kpanot kpanot added bug Something isn't working triage priority:high and removed triage labels Feb 12, 2025
@kpanot kpanot changed the title [Bug]: Enum wrongly generated when used in allOf [Bug]: Enum wrongly generated in SDK models when used in allOf Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority:high
Projects
None yet
Development

No branches or pull requests

1 participant