swagger-api / swagger-api/swagger-codegen
[typescript] Properties that are named "_" are renamed to "_u"
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When an OpenAPI model has a property with the name "_", the property in the generated model is renamed to "_u" when "modelPropertyNaming" is set to "original" and "u" when "modelPropertyNaming" is set to "camelCase".
This causes problems when deserializing a response.
This is due to the following condition :
This turns "_" to "_u". When "modelPropertyNaming" is set to "camelCase", it strips the leading underscore.
I don't understand why this property should be renamed, as there is no Typescript guideline forbidding the use of a property named this way (or a any guideline that would allow for "u" but not "").
Swagger-codegen version
3.0.41
Swagger declaration file content or url
{
"openapi": "3.1.0",
"info": {
"title": "FastAPI",
"version": "0.1.0"
},
"paths": {
"/item": {
"get": {
"summary": "Get Item",
"operationId": "get_item_item_get",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Item"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Item": {
"properties": {
"_": {
"type": "string",
"title": " "
}
},
"type": "object",
"required": [
"_"
],
"title": "Item"
}
}
}
}
Command line used for generation
swagger-codegen-cli generate -l typescript-angular -o angular -i .\openapi.json --additional-properties modelPropertyNaming=original
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.
Research direction
Start at modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractTypeScriptClientCodegen.java around line 168, using the provided OpenAPI declaration and typescript-angular generation command to reproduce the naming change. Confirm that a property named "" remains "" for both modelPropertyNaming=original and camelCase, and that the generated model can deserialize the response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100