Skip to content

Fixes #1636 Fixes "blank" enums by providing the fallback name#1829

Open
lesha-co wants to merge 1 commit intoferdikoomen:mainfrom
lesha-co:fix-blank-enums
Open

Fixes #1636 Fixes "blank" enums by providing the fallback name#1829
lesha-co wants to merge 1 commit intoferdikoomen:mainfrom
lesha-co:fix-blank-enums

Conversation

@lesha-co
Copy link

@lesha-co lesha-co commented Oct 12, 2023

Fixes issue #1636

Some frameworks (e.g. django rest framework, I guess) generate following schema:

openapi: 3.0.3
info:
    version: 1.0.0
components:
    schemas:
        BlankEnum:
            enum:
                - ''

right now this library generates invalid typescript:

export enum BlankEnum {
     = '',
}

This happens in getEnum functions that don't check for invalid input (getEnum([''])) in our case.

I decided to give such enum values BLANK name so that generated files are correct

export enum BlankEnum {
    BLANK = '',
}

Not sure if it would be a better idea to just omit these values (I mean, the name says BlankEnum) but everything's better than broken syntax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant