这是indexloc提供的服务,不要输入任何密码
Skip to content

Allow excluding inlined enum from type generation #1307

@KiwiKilian

Description

@KiwiKilian

Description

Consider this schema:

{
  "components": {
    "schemas": {
      "SegmentFeature": {
        "required": ["type"],
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": ["Feature"]
          }
        }
      }
    }
  }
}

Which Generates this code intypes.gen.ts:

export type type = 'Feature';

export const type = {
  FEATURE: 'Feature',
} as const;

export type SegmentFeature = {
  type: 'Feature';
};

While the name type is problematic (see #1281), I would also like disable generation of the first two types of such inline enums (enums, which are not themself schema).

It is currently not possible to exclude this generation. input.include isn't even called on the inline enum by itself.

So either have some configuration for such inline enums or this could be also part of a generalized approach?

Preferred output in this case would be to have the two first type declarations removed:

- export type type = 'Feature';

- export const type = {
-   FEATURE: 'Feature',
- } as const;

export type SegmentFeature = {
  type: 'Feature';
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature 🚀New feature or requestprioritized 🚚This issue has been prioritized and will be worked on soon

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions