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

defaultQuerySerializer does not handle empty array correctly #1403

Closed
1 task
stefanprobst opened this issue Oct 21, 2023 · 2 comments · Fixed by #1404
Closed
1 task

defaultQuerySerializer does not handle empty array correctly #1403

stefanprobst opened this issue Oct 21, 2023 · 2 comments · Fixed by #1404
Labels
bug Something isn't working openapi-fetch Relevant to the openapi-fetch library

Comments

@stefanprobst
Copy link

Description

the default query serializer (v0.8.0) seems to not handle empty arrays correctly.

Reproduction

import { defaultQuerySerializer } from "openapi-fetch";

console.log(
  defaultQuerySerializer({
    q: "term",
    categories: [],
    search: [],
    limit: 10,
    offset: 0,
  })
);

// logs:
// q=term&&&limit=10&offset=0
//       ^^^

Checklist

@stefanprobst stefanprobst added bug Something isn't working openapi-fetch Relevant to the openapi-fetch library labels Oct 21, 2023
@drwpow
Copy link
Contributor

drwpow commented Oct 21, 2023

Thanks for filing. What would be expected behavior here? Would it be specifying the key but set to nothing?

Edit: besides the extra ampersands

@stefanprobst
Copy link
Author

i think i'd expect an empty array to match the behavior for null and undefined (which currently is to skip the param)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi-fetch Relevant to the openapi-fetch library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants