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

Default value for optional parameters #309

Merged
merged 4 commits into from
Oct 18, 2016
Merged

Default value for optional parameters #309

merged 4 commits into from
Oct 18, 2016

Conversation

jankowiakmaria
Copy link
Collaborator

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|

var _ = require('underscore');

module.exports = function(requestParameters, expectedParameters) {
var result = _.clone(requestParameters);
Copy link
Member

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;
Copy link
Member

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?

@matteofigus matteofigus merged commit f21d135 into master Oct 18, 2016
@matteofigus matteofigus deleted the defaultParams branch October 18, 2016 18:50
@matteofigus
Copy link
Member

🎉 🎂

@matteofigus
Copy link
Member

Thanks! I updated the wiki too.

@jankowiakmaria
Copy link
Collaborator Author

👍

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

Successfully merging this pull request may close these issues.

Default value for optional params
2 participants