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've noticed that if I have a POST endpoint with a parameter in the body that is of type object and I call that operation with the tags interface like client.apis.default.operation({param_name: {}}) (I explicitly set the Content-Type header to application/json), I get an error from my server: unexpected token o in JSON at position 1...
To get it to work, I have to serialize the value of the parameter explicitly client.apis.default.operation({param_name: JSON.stringify({})}).
Would it be reasonable to automatically convert an object to a string if the content type is application/json and it has an "in: body" parameter and the value of said parameter is an object?
Also, if an api endpoint only has one parameter, what do you think about allowing you to call the operation with the interface operation(value) instead of operation({param_name: value})? If an operation only has one parameter, you could check if the argument passed to the operation is an object with a property matching the parameter name (existing behavior) and if not then just use the passed in argument as the value for the parameter (after validating the type). Are there problems with that approach or does that make it too complicated?
The text was updated successfully, but these errors were encountered:
I've noticed that if I have a POST endpoint with a parameter in the body that is of type object and I call that operation with the tags interface like client.apis.default.operation({param_name: {}}) (I explicitly set the Content-Type header to application/json), I get an error from my server:
unexpected token o in JSON at position 1...
To get it to work, I have to serialize the value of the parameter explicitly
client.apis.default.operation({param_name: JSON.stringify({})})
.Would it be reasonable to automatically convert an object to a string if the content type is application/json and it has an "in: body" parameter and the value of said parameter is an object?
Also, if an api endpoint only has one parameter, what do you think about allowing you to call the operation with the interface
operation(value)
instead ofoperation({param_name: value})
? If an operation only has one parameter, you could check if the argument passed to the operation is an object with a property matching the parameter name (existing behavior) and if not then just use the passed in argument as the value for the parameter (after validating the type). Are there problems with that approach or does that make it too complicated?The text was updated successfully, but these errors were encountered: