OpenAPITools / OpenAPITools/openapi-generator

[FEATURE]

Open
#19,588 0 comments 0 reactions 1 assignee View on GitHub

@kay-schecker is already working on this.

Since Apr 28, 2023.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.