swagger-api / swagger-api/swagger-codegen
Special character is removed from property name in generated Typescript interface
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
When using the following schema:
"schemas": {
"fooDto": {
"required": ["$type"],
"type": "object",
"properties": {
"$type": {
"type": "string"
}
},
"discriminator": {
"propertyName": "$type",
"mapping": {
"SomeDto": "#/components/schemas/someDto",
"OtherDto": "#/components/schemas/otherDto",
}
}
},
The interface that gets created is:
export interface ContentDto {
type: string;
}
In this interface the dollar sign is removed.
Is there a way to prevent this from happening?
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 with the supplied OpenAPI schema and the TypeScript interface-generation entry point; compare the $type property in the input with the emitted type property. Confirm the expected preserved property name and add or run a focused regression case for this schema, then verify that generated output keeps $type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100