moleculer-web
moleculer-web copied to clipboard
Allow for array query strings
I have a OAS 3.1 spec that has a query parameter that is an array but uses the non-exploded form such as ?type=main,secondary
. The gateway using parse
from ljharb/qs & parseQueryString
does not seem to account for these additional options and the param ends up in a couple different ways
-
?type=main,secondary
=>"type": "main,secondary"
=> fails to validate -
?type=main
=>"type": "main"
=> fails to validate -
?type=main&type=secondary
=>"type": ["main", "secondary"]
=> validates fine
My param config:
{
type: 'array',
items: { type: 'string' },
uniqueItems: true,
minItems: 1,
convert: true
}
Should parseQueryString
be smarter and respect some other OAS options?
The docs are lacking and just indicate to read up on ljharb/qs
?type[]=main&type[]=secondary
for more information, read this thread
Also: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#style-examples
@intech is there a reason we are not allowed to specify this ourselves? For example through passing qsOptions
in settings
and using it here?
@daniel-parakey, welcome for PR for this feature :)
@intech thoughts? https://github.com/moleculerjs/moleculer-web/pull/326