Open codebykyle opened 3 years ago
I have a solution for this but it may not be ideal.
Following this: https://github.com/axios/axios/issues/738#issuecomment-412905574
I added the following:
api.init().then((client) => {
client.interceptors.request.use(
function(config) {
config.paramsSerializer = (params) => {
return qs.stringify(params, {
arrayFormat: "brackets",
encode: false
});
}
return config;
},
function(error) {
return Promise.reject(error);
}
);
return client;
});
and I was able to get this to work.
This expects, by default, to have a filter[filter_name] style URL parameter for searching.
Strange expectation of third-party library.
OA3 specs says that by default style for query
params is form
(see style
field desc):
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#parameter-object
form
style also should support object:
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#style-values
But in your example you and your library expected value is style: deepObject
and it's not described in parameter style
in the example that you provided. (!)
Another problem that openapi-client-axios
is currently is not support another values than form
for parameter style
, but allow you to pass to axiosConfigDefaults
an paramsSerializer
to handle different cases.
I tried to fix it but couldn't find a graceful way to realize it fast in current library architecture, it passes parameters for serialization on shoulders of 'axios' itself and styles can be mixed for between methods and params also.
So possible better you can change expected params style on your library config.
@anttiviljami, looks like it should be marked as enchantment
.
Hello, I am struggling a bit to get this to work. I am using the following PHP package to make filters: https://github.com/spatie/laravel-query-builder
This expects, by default, to have a
filter[filter_name]
style URL parameter for searching.I have the following specs:
Endpoint:
Filter:
I have the following action:
Where the
filter
parameter is equal to:This produces the following URL: http://api.my-url.local/api/integration-contacts?filter=%5Bobject%20Object%5D
The expected url is: http://api.my-url.local/api/integration-contacts?filter[user_integration_settings_id]=someuuid
Any advice on how to get this to work?