Skip to content
This repository has been archived by the owner on Jan 31, 2025. It is now read-only.

Support for query params array #206

Closed
thebrownfox opened this issue Nov 22, 2021 · 2 comments
Closed

Support for query params array #206

thebrownfox opened this issue Nov 22, 2021 · 2 comments

Comments

@thebrownfox
Copy link

When I try to use array in query parameters, I get this validation error. I think it's because it doesn't check against "search_fields[index]" (search_fields only).

ValidationError: "search_fields[0]" is not allowed

"search_fields": {
    "name": "search_fields",
    "in": "query",
    "schema": {
        "items": {
            "type": "string"
        },
        "type": "array"
    }
}

value:

{
  search: "",
  "search_fields[0]": "id",
  results: "10",
  page: "1",
  "sort[0]": "id",
  "sort[1]": "asc",
}

This might be related:
#199

@thebrownfox
Copy link
Author

Ok, my bad. For anyone who cannot find out why it's not working, you need to parse the params beforehand.

const server = new Hapi.Server({
    query: {
        parser: (query) => qs.parse(query),
    },
});

@dcharbonnier
Copy link
Contributor

Maybe we should do somethig similat to this #211

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

No branches or pull requests

2 participants