'Using doctrine, apiplatform and openapi generator leads to duplcate id field in the frontend side, how to solve this?

I m using Symfony 4 with Doctrine and API Platform to build the backend of my application. I generated entities using php bin/console make:entity. Each class has an id field like this one

/**
 * @ApiResource()
 * @ORM\Entity(repositoryClass=CategoryRepository::class)
 */
class Category
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;
    ...

I generated the api doc file php bin/console api:openapi:export --output=swagger.json Then I use OpenAPI Generator to generate the client part for the frontend npx openapi-generator-cli generate -i swagger.json -g typescript-angular --enable-post-process-file -o build The resulting model file categoryJsonld.ts containes 2 id fields

export interface CategoryJsonld { 
    readonly context?: string | any | null;
    readonly id?: string;
    readonly type?: string;
    readonly id?: number;
    ...

The field idis duplicated and the frontend doesn't compile. I guess the first id stands for @id defined in jsons+ld format. Any idea to solve/prevent the duplication of id ?

Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source