-
Notifications
You must be signed in to change notification settings - Fork 6k
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
JS client: Support for default parameter values #2027
Comments
For other API clients, we don't implement default value for parameters because the default value should be handled/added in the server side. For your case, if the default value is not provided, will the server handle it properly? |
I see, but then the problem is that the client will get confused about the arguments. For example, if I have one operation self.foo = function(bar, callback) {
...
} Now, if the user just calls However, I realize now that there will be problems when you have a mix of default and non-default parameters. E.g. this would not work: self.foo = function(p1, p2 = true, p3, p4 = false){
...
} I guess this is why the other JS client uses named parameters, like foo({ p1: 17, p3: 1, p4: true }) (this would result in the server using the default for p2 since it is not passed, whereas p4 overrides its default). |
Definitely valid point and we'll evaluate your suggestion using named parameter (which is already supported by C#, Ruby, etc) |
We can implement optional parameters like in Ruby client. I'll submit a PR for it. |
@delenius what's your view on using Ruby's style optional parameter in JS functions? |
I like it, and I have seen that style used in JS libraries before. |
This is a feature request to support default parameter values in the generated JS client. These seem to be ignored currently.
The text was updated successfully, but these errors were encountered: