OpenAPITools / OpenAPITools/openapi-generator
[BUG][typescript-node] components.securitySchemes props keys are used with dot instead of bracket notation
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?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When a property of components.securitySchemes is a string which has special characters, the typescript-node generator produces some invalid code (look at the access-token property):
set accessToken(accessToken: string | (() => string)) {
this.authentications.access-token.accessToken = accessToken;
}
It should have been something like:
set accessToken(accessToken: string | (() => string)) {
this.authentications["access-token"].accessToken = accessToken;
}
openapi-generator version
6.1.0
OpenAPI declaration file content or url
Reproducible example
openapi: 3.0.3
info:
title: Title
version: "1"
paths:
/test:
get:
responses:
200:
description: Success
content:
application/json:
schema:
type: string
security:
- access-token: []
components:
securitySchemes:
access-token:
scheme: bearer
bearerFormat: JWT
type: http
Generation Details
I've only used the typescript-node generator with no special configuration.
Steps to reproduce
Copy the schema in a new file (/local/modules/openapi-generator/src/test/resources/bugs/issue_XXXXX.yaml in my example), then run:
docker run --rm \
-v $PWD:/local openapitools/openapi-generator-cli generate \
-i /local/modules/openapi-generator/src/test/resources/bugs/issue_XXXXX.yaml \
-g typescript-node \
-o /local/out/typescript-node
Related issues/PRs
Nothing found yet
Suggest a fix
I've made a quickfix here: https://github.com/bbenoist/openapi-generator/commit/6a0eb8b0772fb3dfe45c42c365036120479e90be
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
Reproduce the issue with the OpenAPI YAML example using the typescript-node generator and inspect the generated authentication access. The regression fixture can live under modules/openapi-generator/src/test/resources/bugs/; done means generated access for names such as access-token uses bracket notation and produces valid TypeScript.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, openapi, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100