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

Void argument routes should not require null #41

Closed
krieb opened this issue Jun 9, 2016 · 10 comments · Fixed by #43 or #288
Closed

Void argument routes should not require null #41

krieb opened this issue Jun 9, 2016 · 10 comments · Fixed by #43 or #288
Labels

Comments

@krieb
Copy link
Contributor

krieb commented Jun 9, 2016

When calling an endpoint that does not accept any parameters (e.g. usersGetCurrentAccount()), null must be passed as an argument. This is somewhat confusing and the error message returned when you forget to pass null doesn't help either:

> dbx.usersGetCurrentAccount()
POST https://api.dropboxapi.com/2/users/get_current_account 400 (Bad Request)
Error in call to API function "users/get_current_account": request body: could not decode input as JSON
> dbx.usersGetCurrentAccount(null)
lib$es6$promise$promise$$Promise {xot8798dunmi: 2, _state: undefined, _result: undefined, _subscribers: Array[0]}

We should default to sending null when no argument is supplied.

@braincore
Copy link
Contributor

Legit catch.

@rileytomasek
Copy link
Contributor

thanks for catching this @krieb

@bobmoff
Copy link

bobmoff commented Feb 28, 2018

The issue still remains, in the typescript definitions.

@greg-db
Copy link
Contributor

greg-db commented Mar 5, 2018

@bobmoff Apologies for the delay, and thanks for the note. We'll look into it.

@greg-db greg-db reopened this Mar 5, 2018
@pran1990
Copy link
Contributor

pran1990 commented Mar 6, 2018

@jvilk a seemingly simple fix here is to remove the arg: void from https://github.com/dropbox/dropbox-sdk-js/blob/master/generator/typescript/dropbox.d.ts#L1484 (and any other functions that don't have an input). Can you advice if that is the correct thing to do?

@jvilk
Copy link

jvilk commented Mar 6, 2018

@pran1990 Yes, that is correct.

Note that that file is auto-generated from the stone specification, which specifies that that route takes an argument of type 'void'.

You should change the TypeScript stone generator to special-case the output of routes that take a void argument.

Here's an (untested) change to the generator that should work (forgive any syntax errors / things that aren't best practice; I don't often write Python code):

        arg_data_type = fmt_type(route.arg_data_type)
        if route.arg_data_type == "void":
                self.emit('public %s(): Promise<%s>;' %
                           (function_name, fmt_type(route.result_data_type)))
        else:
                self.emit('public %s(arg: %s): Promise<%s>;' %
                          (function_name, arg_data_type, fmt_type(route.result_data_type)))

Hope that helps!

@alexandrtovmach
Copy link
Contributor

It's already fixed issue, and that's should be closed

@greg-db greg-db closed this as completed Mar 7, 2019
@greg-db
Copy link
Contributor

greg-db commented Mar 7, 2019

Apologies, the original issue was resolved, but we had this still open for the same issue in TypeScript.

@greg-db greg-db reopened this Mar 7, 2019
@rogebrd
Copy link
Contributor

rogebrd commented Sep 25, 2020

Newest version should fix the issue.

@rogebrd rogebrd linked a pull request Sep 25, 2020 that will close this issue
rogebrd added a commit to dropbox/stone that referenced this issue Oct 5, 2020
- Fix for ([JS #41](dropbox/dropbox-sdk-js#41))
- Update route to not have `arg` when there is no parameter
- Update comments to also not contain `arg` when no parameter
- Update tests for both clients
rogebrd added a commit to dropbox/stone that referenced this issue Oct 5, 2020
* Update JS and TS routes to remove null parameters

- Fix for ([JS #41](dropbox/dropbox-sdk-js#41))
- Update route to not have `arg` when there is no parameter
- Update comments to also not contain `arg` when no parameter
- Update tests for both clients
@greg-db
Copy link
Contributor

greg-db commented Oct 7, 2020

This should be fixed for TypeScript as of the latest version, v7.0.0.

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