swagger-api / swagger-api/swagger-codegen

[typescript-fetch] Generated authentication configuration file has compile error if the apikey name contains dash -

Open
#6,324 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

The generated authentication configuration file configuration.ts has compile error if the apikey name contains dash -.

https://github.com/wing328/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/TypeScript-Fetch/configuration.mustache#L5

securityDefinitions:
  APIKeyHeader:
    type: apiKey
    in: header
    name: X-API-Key

keyParamName has the same string value with swagger spec. Dash is allowed in HTTP header name but not in typescript object key name.

Swagger-codegen version

Official CLI Docker container (master branch)

Related issues/PRs

#4008

Suggest a fix/enhancement

Convert the name to TypeScript compatible identifier in the generated code.

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.

Research direction

Start with modules/swagger-codegen/src/main/resources/TypeScript-Fetch/configuration.mustache at the referenced line and inspect how keyParamName is emitted into configuration.ts. Generate a TypeScript-Fetch client using an API key named X-API-Key, then verify the generated configuration compiles and handles the header name correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.