openapi-backend icon indicating copy to clipboard operation
openapi-backend copied to clipboard

Fix query and path params not keeping the coerced types

Open Fetchinator7 opened this issue 2 years ago • 2 comments

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

Fetchinator7 avatar Dec 01 '21 01:12 Fetchinator7

~~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"?~~

Fetchinator7 avatar Dec 11 '21 19:12 Fetchinator7

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

new alerts:

  • 1 for Useless assignment to local variable

lgtm-com[bot] avatar Feb 12 '22 20:02 lgtm-com[bot]

@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?

nklisch avatar Jan 01 '23 00:01 nklisch

Superceded by #571

anttiviljami avatar Jul 09 '23 18:07 anttiviljami