Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix query and path params not keeping the coerced types #262

Closed

Conversation

Fetchinator7
Copy link
Contributor

@Fetchinator7 Fetchinator7 commented Dec 1, 2021

This is to fix requests not saving with the correct types.
NOTE: This is only for query parameters, to my understanding path parameters are not being serialized at all. See line 307 in src/router.ts
typescript
{
name: queryParam,
in: 'query',
},

Update: I realized coercing query parameters and path parameters use the exact same logic so I changed this to coerce both types.
#144

src/router.ts Outdated Show resolved Hide resolved
src/router.ts Outdated Show resolved Hide resolved
@Fetchinator7
Copy link
Contributor Author

Fetchinator7 commented Dec 11, 2021

I'm thinking we need a more robust way to parse booleans from strings
Ok, I guess my question is; "If the input parameter string is not a boolean, how should we handle that in the parser?" For example, parseJSON(input.toLowerCase()) would return the appropriate boolean or undefined if the input is anything besides those strings, but if the input isn't a boolean what would we do? Would we throw an error here in the parser? From my understanding, validating request inputs happens elsewhere with ajv (or whatever is implemented) and this is only for parsing the requests.
So, if the input is invalid/not a boolean is it the responsibility of this parser to throw an error? This works correctly for the happy cases, so what should happen in the unhappy cases that would allow us to implement "a more robust way to parse booleans"?

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Feb 12, 2022

This pull request introduces 1 alert when merging 1ab18a7 into 2d7a470 - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

@Fetchinator7 Fetchinator7 changed the title Fix queryParams not keeping the coerced types (only query parameters) Fix query and path params not keeping the coerced types Feb 12, 2022
@nklisch
Copy link

nklisch commented Jan 1, 2023

@anttiviljami Do we expect a fix, like this PR is suppose to address, likely to happen? Does this PR need to be updated? As I see it is a year old?

@anttiviljami
Copy link
Member

Superceded by #571

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants