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

Cover the cases where parameter type is undefined and verb type is up… #53

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
21 changes: 12 additions & 9 deletions lib/apidocToSwagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function extractPaths(apidocJson){

for(var j = 0; j < verbs.length; j++) {
var verb = verbs[j];
verb.type = verb.type.toLowerCase();
var type = verb.type;

var obj = paths[url] = paths[url] || {};
Expand Down Expand Up @@ -186,12 +187,14 @@ function createFieldArrayDefinitions(fieldArray, definitions, topLevelRef, defau
prop.$ref = "#/definitions/" + parameter.field;
}

var typeIndex = type.indexOf("[]");
if(typeIndex !== -1 && typeIndex === (type.length - 2)) {
prop.type = "array";
prop.items = {
type: type.slice(0, type.length-2)
};
if (type !== undefined) {
var typeIndex = type.indexOf("[]");
if(typeIndex !== -1 && typeIndex === (type.length - 2)) {
prop.type = "array";
prop.items = {
type: type.slice(0, type.length-2)
};
}
}

definitions[objectName]['properties'][nestedName.propertyName] = prop;
Expand Down Expand Up @@ -276,12 +279,12 @@ function createPathParameters(verbs, pathKeys) {
for (var i = 0; i < verbs.parameter.fields.Parameter.length; i++) {
var param = verbs.parameter.fields.Parameter[i];
var field = param.field;
var type = param.type;
var type = param.type !== undefined ? param.type : '';
pathItemObject.push({
name: field,
in: type === "file" ? "formData" : "path",
required: !param.optional,
type: param.type.toLowerCase(),
type: type.toLowerCase(),
description: removeTags(param.description)
});

Expand All @@ -302,4 +305,4 @@ function groupByUrl(apidocJson) {

module.exports = {
toSwagger: toSwagger
};
};