Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API sample requests send params as empty string #200

Closed
tnunes opened this issue Jan 23, 2015 · 7 comments
Closed

API sample requests send params as empty string #200

tnunes opened this issue Jan 23, 2015 · 7 comments

Comments

@tnunes
Copy link

tnunes commented Jan 23, 2015

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.

@vherilier
Copy link

+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

@tnunes
Copy link
Author

tnunes commented Jan 23, 2015

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.

@vherilier
Copy link

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

@jaime-franco
Copy link

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?

@andrefox333
Copy link

+1 Can definitely use this fix.

@tommybananas
Copy link

tommybananas commented May 18, 2017

I've created a pull request for this feature here #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.

@shahidmau
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants