OpenAPITools / OpenAPITools/openapi-generator
[BUG][typescript-fetch] Special characters in `paramName` are left out in generated client / interfaces
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
Generated interfaces should contain special characters to match the spec file. - [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I’m using typescript-fetch to auto-generate a client and facing an issue:
The API I’m working with returns a field called @type (including the @-sign). However, this is not correctly reflected in the generated interface.
I would like to open up a PR to fix this issue. Any suggestions to tackle the problem? Simply wrapping quotes around the props of the interface? Or is there a setting I’m missing here?
openapi-generator version
6.3.0
OpenAPI declaration file content or url
openapi: 3.0.0
info:
title: DemoAPI
termsOfService: http://swagger.io/terms/
version: 0.0.1
servers:
- url: https://sandboxapi.demo.com
description: Sandbox
paths:
/ring:
get:
tags:
- ring
summary: Get the ring
operationId: getRing
responses:
200:
description: success
content:
application/json:
schema:
$ref: '#/components/schemas/Ring'
components:
schemas:
Ring:
description: A closed loop consisting of a set of points in a two-dimensional space.
type: object
properties:
"@type":
type: string
example: Ring
type:
type: string
example: exterior
description: Specifies whether the ring is an exterior or interior boundary of a polygon.
passable:
type: boolean
description: Specifies whether the ring can be crossed or not.
Generation Details
java -jar ".../node_modules/@openapitools/openapi-generator-cli/versions/6.3.0.jar" generate --input-spec="./schema/swagger.yaml" --generator-name="typescript-fetch" --output="./.generated/" --additional-properties="supportsES6=true,withInterfaces=true"
Steps to reproduce
- Use the OpenAPI CLI to generate an API client
- Open up the generated files afterwards.
Related issues/PRs
Suggest a fix
I'd like to provide pull request that fixed the issue. However, I'm not completely sure how to tackle this.
We could escape special characters in property names by wrapping quotes around them, but I'd like to hear other opinions on this first.
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 by running the provided OpenAPI CLI command with schema/swagger.yaml and the typescript-fetch generator. Inspect the generated interfaces for the Ring schema, especially the @type property, and compare them with the OpenAPI declaration. Done means generated TypeScript interfaces preserve special-character property names while remaining valid for the specified client output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100