Skip to content

Commit

Permalink
fix object type, fix merge resource & action params
Browse files Browse the repository at this point in the history
  • Loading branch information
nazieb committed May 30, 2017
1 parent ab3bd07 commit 4ab0d25
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "optimusjs",
"version": "0.4.2",
"version": "0.4.3",
"description": "Transform API Blueprint into any other formats",
"main": "dist/index.js",
"bin": {
Expand Down
19 changes: 8 additions & 11 deletions src/formatters/swagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,23 +261,18 @@ function getActionParams(action) {
function mergeResourceAndActionParams(resourceParams, actionParams) {
const result = [];

if (resourceParams.length > 0) {
for (let resourceParam of resourceParams) {
result.push(resourceParam);
}
}

if (actionParams.length > 0) {
for (let actionParam of actionParams) {
if (actionParam.hasOwnProperty("in") && (actionParam.in == "body" || actionParam.in == "header")) {
result.push(actionParam);
continue;
}

for (let resourceParam of resourceParams) {
if (resourceParam.name == actionParam.name) {
actionParam["in"] = resourceParam["in"];
result.push(actionParam);
}
}
}
} else if (resourceParams.length > 0) {
for (let resourceParam of resourceParams) {
result.push(resourceParam);
}
}

Expand Down Expand Up @@ -382,6 +377,8 @@ function getDefinitions(dataStructures) {
} : {
"$ref": convertDefinitionPath(itemsType),
};
} else if (memberType == "object") {
property["type"] = memberType;
}

properties[memberName] = property;
Expand Down

0 comments on commit 4ab0d25

Please sign in to comment.