--extract-request-params behavior depends on presence of query params
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
- javascript, typescript
Research direction
The issue is in src/routes.js lines 295-302 and templates/default/procedure-call.eta lines 24-34. Start by understanding how requestParams is generated and used. The fix likely involves modifying the condition in routes.js to consider path params when extractRequestParams is true. Test by running the generator on a spec with only path params to verify the params object is created.
Written by the indexing model from the issue text.
Description
The procedure call template uses the presence of requestParams to decide whether to actually do the --extract-request-params behavior, i.e., put path and query params in a single object that is the first argument to the request function.
If requestParams is falsy, we essentially fall back to the default behavior.
The problem (for me, anyway) is that requestParams is always null for a given route if the route takes no query params:
So, for requests that only have path params but no query params, we will never generate a params object representing the path params, instead inlining them as individual arguments. I was able to confirm that commenting out if (!queryParams || !queryParams.length) return null; produces the desired behavior.
This behavior is counterintuitive given the documentation for the flag. It seems clear that both path params and query params are meant to be considered "request params", which means requestParams should not be null if there are path params.
--extract-request-params extract request params to data contract (default: false)
Also combine path params and query params into one object
If getting rid of that check would break the default extractRequestParams = false case, then maybe something like this would be appropriate:
- if (!queryParams || !queryParams.length) return null;
+ if (!extractRequestParams && (!queryParams || !queryParams.length)) return null;
- 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