swagger-api / swagger-api/swagger-codegen
[typescript-fetch-client] can not get the property value from the response msg
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Just like the following YAML and typescript-fetch-client generated code, the property name in YALM is of Snake case,
but the property name in generated typescript code is of camel case;
the name in YALM isn't same with the name in generated code,
so the value in message can not be resolved with the property name in the generated code.
after change the name in the generated code to snake case format, the value in message can be gotten correctly.
Is there any workaround to this issue?
This is the declaration of the response message in YAML
`CardBatchGetResp:
type: object
properties:
errcode:
type: integer
errmsg:
type: string
card_id_list:
type: string
total_num:
type: integer`
`
This is the typescript-fetch-client generated code from the declaration in YAML
`
export interface CardBatchGetResp {
"errcode"?: number;
"errmsg"?: string;
"cardIdList"?: string;
"totalNum"?: number;
}`
Swagger-codegen version
I don't konw which version am I using,
I use "http://editor.swagger.io/#/" to generate code, I know that Swagger Editor version is 2.10.3
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 YAML CardBatchGetResp declaration and the typescript-fetch-client generated interface shown in the issue, reproducing the mismatch in Swagger Editor 2.10.3 if possible. Trace the generator entry point or template that converts card_id_list and total_num to camel case, then verify that response values resolve correctly and add a regression test if the project provides one.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100