You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am encountering an error where my generated library is not properly encoding query parameters. This may be an issue with the swagger/openapi spec but I'm not totally sure. Here is an example of a request generated by oazapfts:
Specifically, the failure is occurring on the filter model (FwStandardModelsFwQueryFilter):
exporttypeFwStandardModelsFwQueryFilter={/** The DataField name to filter on. */Field: string;/** Comparison operator: = (equals), <> (not equals) */Op: string;/** The value of the DataField to filter on. */Value?: string|null;};
Here is the problem:
constfilter=[{"Field": "ICode","Op": "=","Value": "11754"}];// This fails with "Bad Request" from the server// Returns: ?filter=Field,ICode,Op,%3D,Value,11754console.log(QS.query(QS.explode({filter: filter})));// This succeeds// Returns: ?filter=%5B%7B%22Field%22%3A%22ICode%22%2C%22Op%22%3A%22%3D%22%2C%22Value%22%3A%2211754%22%7D%5Dconsole.log(QS.query(QS.explode({filter: JSON.stringify(filter)})));
So it would seem that "filter" should be stringified before encoding. Unfortunately, when I actually try to do it this way in the function call, it causes a typescript warning that Type 'string' is not assignable to type 'FwStandardModelsFwQueryFilter[]' which is technically correct because the function wants to see that type of object, not a pre-stringified string.
What is the right way to work around this?
The text was updated successfully, but these errors were encountered:
In general the parameter encoding is (unfortunately) currently not fully compliant with the spec. I have this somewhere on my radar and have tried to tackle this in the past but until now wasn't able to come up with a solution better then what we currently have.
It might very well be that you're encountering an edge-case here that this library should™ handle better.
In order to bring this forward, could you share the swagger-file / oas-spec file you use to generate the code as well as an example of what you'd expect the codegen to produce?
I am encountering an error where my generated library is not properly encoding query parameters. This may be an issue with the swagger/openapi spec but I'm not totally sure. Here is an example of a request generated by oazapfts:
Specifically, the failure is occurring on the filter model (FwStandardModelsFwQueryFilter):
Here is the problem:
So it would seem that "filter" should be stringified before encoding. Unfortunately, when I actually try to do it this way in the function call, it causes a typescript warning that
Type 'string' is not assignable to type 'FwStandardModelsFwQueryFilter[]'
which is technically correct because the function wants to see that type of object, not a pre-stringified string.What is the right way to work around this?
The text was updated successfully, but these errors were encountered: