fetch http client return type is wrong when `unwrapResponseData` is false
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 65/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- typescript
Research direction
Examine the fetch-http-client.ejs template file around lines 159-224. Understand how the unwrapResponseData flag affects the generated TypeScript return type. The fix involves updating the template to return Promise<HttpResponse<T, null>> when the flag is false. Test by generating a client with a sample OpenAPI spec to verify the corrected type.
Written by the indexing model from the issue text.
Description
Looking at this code: https://github.com/acacode/swagger-typescript-api/blob/master/templates/base/http-clients/fetch-http-client.ejs#L159-L224
The return type should be Promise<HttpResponse<T, null>> when unwrapResponseData is false. If the request is successful and no error is thrown, the error property will always be null.
In fact, it seems like there is no point in having the generic E as a part of custom fetch because there is no guarantee that it will be the type given this line https://github.com/acacode/swagger-typescript-api/blob/master/templates/base/http-clients/fetch-http-client.ejs#L206.
- Dominant language
- TypeScript
- Stars
- 4.1k
- Forks
- 436
- Avg merge
- 9d 7h
- Merged PRs (30d)
- 3
Contributor guide
No contributing guide indexed for this repository
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.
More from acacode/swagger-typescript-api
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
acacode/swagger-typescript-api#1821 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
acacode/swagger-typescript-api#1638 · 3 comments · 10 reactions ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
acacode/swagger-typescript-api#1237 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
acacode/swagger-typescript-api#1146 · 3 comments ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
acacode/swagger-typescript-api#988 · 1 comment · 1 reaction ·
All issues in acacode/swagger-typescript-api
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100