-
Notifications
You must be signed in to change notification settings - Fork 122
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
Default value for optional parameters #309
Conversation
var _ = require('underscore'); | ||
|
||
module.exports = function(requestParameters, expectedParameters) { | ||
var result = _.clone(requestParameters); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this clone
necessary? If a component has a decent number of params (like TMS) this clone could use some CPU. If not necessary, I would be tempted to remove it? What do you think
module.exports = function(requestParameters, expectedParameters) { | ||
var result = _.clone(requestParameters); | ||
var optionalParametersWithDefaults = _.pick(expectedParameters, function(parameter){ | ||
return !parameter.mandatory && parameter.default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what when parameter.default is a boolean false? maybe a !_.isUndefined(parameter.default)
would be better?
🎉 🎂 |
Thanks! I updated the wiki too. |
👍 |
resolves #276
Would require change in wiki -> Getting started page:
|
oc.parameters[key].default
|*
|Default value of optional parameter - applied when value is not specified in the request|