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

[FEATURE] #703

Open
PierreTraversFamileo opened this issue Apr 28, 2023 · 0 comments
Open

[FEATURE] #703

PierreTraversFamileo opened this issue Apr 28, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@PierreTraversFamileo
Copy link

hi, everyone, i'm using openapi-generator-cli for generate TS services and models

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 use a json file which contain @id and id for arttribute in object

          "@id": {
            "readOnly": true,
            "type": "string"
          },
          "@type": {
            "readOnly": true,
            "type": "string"
          },
          "id": {
            "readOnly": true,
            "type": "integer",
            "nullable": true
          },

i use this commande to generate code :
openapi-generator-cli generate -i ./json.json -g typescript-angular -o src/app/generated-api/

here i obtain :

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

I found why

because of the sanitazer in AbstractTypeScriptClientCodegen.java

name = sanitizeName(name, "[^\\w$]");

Solution ?

i we can add a parameter to bypass this sanitize or to override it that would be great !

example :

--additional-properties=notSanitize =true

output

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

i found a topic related !#13999
best regard,
Pierre

@PierreTraversFamileo PierreTraversFamileo added the bug Something isn't working label Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants