-
-
Notifications
You must be signed in to change notification settings - Fork 575
Closed
Labels
PRs welcomePRs are welcome to solve this issue!PRs are welcome to solve this issue!bugSomething isn't workingSomething isn't workinggood first issueStraightforward problem, solvable for first-time contributors without deep knowledge of the projectStraightforward problem, solvable for first-time contributors without deep knowledge of the projectopenapi-fetchRelevant to the openapi-fetch libraryRelevant to the openapi-fetch library
Description
Discussed in #1934
Originally posted by BlakeSzabo October 1, 2024
Hi,
I've been using openapi-fetch
and have been enjoying it so far but I have noticed a strange behaviour with arrays being passed in query params
here's a basic implementation of a client that will call the /posts
endpoint and pass in four separate query params, each an empty array just to be a bit dramatic:
import createClient from 'openapi-fetch';
import type { paths } from '../types/api';
const client = createClient<paths>({ baseUrl: 'http://localhost:3001' });
export const getPosts = () => {
client.GET('/posts', {
params: {
query: {
first_array: [],
second_array: [],
third_array: [],
fourth_array: [],
},
},
});
};
Given all these arrays are empty, I wouldn't expect them to impact the query params; similar to how undefined
or null
would behave. However, the resulting request URL is http://localhost:3001/posts?&&&
I assume this behaviour isn't intended but wanted to check before raising an issue. I'm also willing to contribute to help solve this if I can. Thanks.
Metadata
Metadata
Assignees
Labels
PRs welcomePRs are welcome to solve this issue!PRs are welcome to solve this issue!bugSomething isn't workingSomething isn't workinggood first issueStraightforward problem, solvable for first-time contributors without deep knowledge of the projectStraightforward problem, solvable for first-time contributors without deep knowledge of the projectopenapi-fetchRelevant to the openapi-fetch libraryRelevant to the openapi-fetch library