Apidoc: API sample requests send params as empty string

Created on 23 Jan 2015  路  7Comments  路  Source: apidoc/apidoc

When using sampleUrl to generate forms to test API methods, apidoc pages send all parameters of the currently selected parameter group to API endpoints, even if the user did not fill in any value.

For example, if I have a method with 3 parameters, a, b and c, all optional, and I only fill a value into a, upon clicking Send apidoc sends a request with the value I entered for a and empty strings as values for b and c.

This is not desirable and breaks APIs that do not accept empty strings as values for those parameters. These sample forms should only send params that the user specificaly provided.

todo

Most helpful comment

I've created a pull request for this feature here https://github.com/apidoc/apidoc/pull/647, although I personally think that we should include a checkbox of some kind next to optional parameters that indicate a blank string should be sent for sample requests in the case that you actually want to send a blank string.

All 7 comments

+1

I submitted a PR #193 that will hopefully deal with this issue (params and headers too).
Maybe you could have a look at it, and give your feedbacks in case I forgot something.

Thanks

Vincent

I don't think your pull request fixes this issue, since it does not prevent sending empty strings for optional params.

Moreover, it makes it impossible to provide user-defined values for required fields, since you are overriding the values to the default, when it exists, without verifying if the used supplied a custom value.

I also don't think apidoc should send a default value for any param. IMO, when you document an API param with a default value, you are describing what the API call will assume for that value when you do not provide one. The client should not send that value, it will be implied.

Sorry I missed something in your issue, and I do not fix your issue. That's right, my apologies...

Hi, is any advance on this?, i'm trying to define a PUT request and don't want to update fields with empty string, is there a way to tell Apidoc to only send parameters filled?

+1 Can definitely use this fix.

I've created a pull request for this feature here https://github.com/apidoc/apidoc/pull/647, although I personally think that we should include a checkbox of some kind next to optional parameters that indicate a blank string should be sent for sample requests in the case that you actually want to send a blank string.

+1

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ivan-kleshnin picture ivan-kleshnin  路  5Comments

brandonhamilton picture brandonhamilton  路  4Comments

whitelujx picture whitelujx  路  3Comments

ameliariely picture ameliariely  路  7Comments

kingmayko picture kingmayko  路  3Comments