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

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants