OpenAPITools / OpenAPITools/openapi-generator
[FEATURE]
@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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.