Skip to content

Commit

Permalink
Merge pull request #16 from strongloop/fix/computed-arguments
Browse files Browse the repository at this point in the history
Ignore computed "accepts" arguments
  • Loading branch information
bajtos authored Dec 22, 2016
2 parents 8af22bf + a8a1f33 commit b110a2f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions lib/objc-codegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ function addObjCMethodInfo(meta, method, modelName, skipOptionalArguments) {
var paramAssignments;
var bodyParamAssignments;
method.accepts.forEach(function (param) {
// Skip arguments derived by a server-side code
if (isServerComputedArg(param)) {
return;
}

var paramRequired = param.required || (param.http && param.http.source === 'body');
if (!paramRequired && skipOptionalArguments) {
return;
Expand Down Expand Up @@ -376,6 +381,9 @@ function addObjCMethodInfo(meta, method, modelName, skipOptionalArguments) {
function hasOptionalArguments(method) {
for (var idx in method.accepts) {
var param = method.accepts[idx];
if (isServerComputedArg(param)) {
continue;
}
var paramRequired = param.required || (param.http && param.http.source === 'body');
if (!paramRequired) {
return true;
Expand All @@ -384,6 +392,17 @@ function hasOptionalArguments(method) {
return false;
}

function isServerComputedArg(param) {
if (typeof param.http === 'function') {
return true;
}

var httpSource = param.http && param.http.source;
return httpSource === 'req' ||
httpSource === 'res' ||
httpSource === 'context';
}

function convertToObjCPropType(type) {
if (Array.isArray(type)) {
return propTypeConversionTable['<array>'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
9A86B9E429A6B7474DC3F9C1 /* [CP] Embed Pods Frameworks */ = {
Expand Down Expand Up @@ -370,7 +370,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
F1E01B4ABA5E5A9760F3CC39 /* [CP] Embed Pods Frameworks */ = {
Expand Down

0 comments on commit b110a2f

Please sign in to comment.