Skip to content

[BUG][Typescript] Invalid type for the enum array #14892

Open
@wtrocki

Description

@wtrocki

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Array of enums causes compilation error:

        index:
          type: array
          items:
              type: string
              enum:
                - "1"
                - "1"
                - "-1"

error:

public property ''index'' of exported class has or is using private name 'InnerEnum'.

31     'index'?: Array<{ [key: InnerEnum]: InnerEnum; }>;
openapi-generator version

both master and latest release.

OpenAPI declaration file content or url
Generation Details

Generator typescript.

Steps to reproduce

Run generator for schema above.

Related issues/PRs
Suggest a fix

datatypeWithEnum is not set properly in model:
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/typescript/model/model.mustache#L22

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