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

Enum types are not being generated by the Typescript Generator #366

Open
gigo6000 opened this issue Feb 22, 2023 · 0 comments
Open

Enum types are not being generated by the Typescript Generator #366

gigo6000 opened this issue Feb 22, 2023 · 0 comments

Comments

@gigo6000
Copy link

gigo6000 commented Feb 22, 2023

API Platform version(s) affected: 3.0

Description
I'm using the Typescript Generator to generate some interfaces and I have some enum types in the Entity, for example:

<?php
//Enum
namespace App\Enum;

enum Gender: string
{
    case FEMALE = 'female';
    case MALE = 'male';
}
<?php
// Entity
class Person
{
    ...
    #[ORM\Column(type: "string", length: 6, nullable: true, enumType: Gender::class)]
    private $gender;
    ...

but when I generate the interfaces, they are generated as type any.

How to reproduce
Create an entity with an enum type. Use the Typescript generator to generate the corresponding interface:

npm init @api-platform/client http://localhost/api src/ -- --generator typescript

The interface generated will be of type any instead of having the proper enum type:

export interface Person {
 ...
 gender?: any;
 ...
}

Possible Solution

The generator should generate the corresponding enum and implement it in the interface:

export interface Person {
 ...
 gender?: gender;
 ...
}

export enum gender {
    FEMALE = 'female',
    MALE = 'male',
}

Additional Context

@gigo6000 gigo6000 changed the title Enum types are not being generated Enum types are not being generated by the Typescript Generator Feb 22, 2023
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

No branches or pull requests

1 participant