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

Ignore computed "accepts" arguments #16

Merged
merged 1 commit into from
Dec 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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