fsbahman / apidoc-swagger

apidoc and swagger are two nice projects which are focusing on documentation of APIs. This project is a middle tier which tries to bring them together in a sense that it uses apidoc to convert inline documentation to json schema and later convert it to swagger json schmea.
Other
252 stars 131 forks source link

Doesn't work (indexOf undefined) #22

Open Uter1007 opened 8 years ago

Uter1007 commented 8 years ago

apidoc on it's own runs smoothly.

apidoc-swagger -i dist/ -o doc/ (node:10252) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version. warn: parser plugin 'param' not found in block: 0 error: Cannot read property 'indexOf' of undefined

lzerma commented 7 years ago

@Uter1007 try to use the excluding filters and remove the node_modules/ folder.

svanbelleghem commented 7 years ago

Have the exact same problem.

apidoc-swagger -o/docs warn: parser plugin 'param' not found in block: 1 error: Cannot read property 'indexOf' of undefined

Folderstructure: structuur-backend2

Any idea how to resolve this?

lzerma commented 7 years ago

@svanbelleghem @Uter1007 Here try this:

apidoc-swagger -v -e "node_modules/" -f \'.*\\.js$\' -i ./api -o ./

svanbelleghem commented 7 years ago

Btw: thanks for the reply ;)

apidoc-swagger -v -e "node_modules/" -f \'.*\\.js$\' -i ./api -o ./

verbose: apidoc-generator name: apidoc-swagger
verbose: apidoc-generator version: 0.2.2
verbose: apidoc-core version: 0.3.1
verbose: apidoc-spec version: 0.2.0
verbose: run parser
error: No files found.
{ Path: '.' }
lzerma commented 7 years ago

@svanbelleghem replace the js extension to which you are currently working with.

apidoc-swagger -v -e "node_modules/" -f \'.*\\.<replace me>$\' -i ./api -o ./

svanbelleghem commented 7 years ago

replace the js extension to which you are currently working with.

Do you mean the apidoc configfile which is written in json?

lzerma commented 7 years ago

What are the files that contain the documentation block on it? On the image that you attached I couldn't see any well-known structure for a project, so I need to know in order to help you out. vendor and apidoc doesn't mean nothing.

svanbelleghem commented 7 years ago

vendor is my composer output folder. apidoc is the output folder from a previous generated apidoc. Index.php contains the code that needs to be documented.

lzerma commented 7 years ago

@svanbelleghem ok, try this then apidoc-swagger -v -e "node_modules/" -f \'.*\\.php$\' -i ./vendor/index.php -o ./

svanbelleghem commented 7 years ago

Index.php is located on the root, not in vendor (excuses for the misunderstanding). But when I try apidoc-swagger -v -e "node_modules/" -f \'.*\\.php$\' -i ./index.php -o ./ I still got the same result:

apidoc-swagger -v -e "node_modules/" -f \'.*\\.php$\' -i ./index.php -o ./

verbose: apidoc-generator name: apidoc-swagger verbose: apidoc-generator version: 0.2.2 verbose: apidoc-core version: 0.3.1 verbose: apidoc-spec version: 0.2.0 verbose: run parser error: No files found. { Path: '.' }

lzerma commented 7 years ago

Ok, then try cd /html/ && apidoc-swagger -v -e "node_modules/" -f \'.*\\.php$\' -i ./ -o ./

If you still getting the same error, it means that it is not finding the index.php.

svanbelleghem commented 7 years ago

I'm really sorry but still getting the same error. But with cmd I can locate the file.

if exist index.php echo File Found!
File Found!

And when I run apidoc alone it runs smoothly. Do I need to specify some settings in apidoc.json or in my index.php besides the standart apidoc settings and annotations?

svanbelleghem commented 7 years ago

Ok, so for some reason this apidoc-swagger -i example/ -o doc/ works perfectly!

cyyeh commented 7 years ago

@svanbelleghem apidoc-swagger -i example/ -o doc/, what files does the 'example' directory contain?

RiceLinTW commented 6 years ago

Same problem when run apidoc-swagger

Got these output error: Cannot read property 'indexOf' of undefined debug: TypeError: Cannot read property 'indexOf' of undefined at createFieldArrayDefinitions (/usr/local/lib/node_modules/apidoc-swagger/lib/apidocToSwagger.js:188:25) at createVerbDefinitions (/usr/local/lib/node_modules/apidoc-swagger/lib/apidocToSwagger.js:134:22) at createGetDeleteOutput (/usr/local/lib/node_modules/apidoc-swagger/lib/apidocToSwagger.js:236:29) at extractPaths (/usr/local/lib/node_modules/apidoc-swagger/lib/apidocToSwagger.js:64:19) at Object.toSwagger (/usr/local/lib/node_modules/apidoc-swagger/lib/apidocToSwagger.js:13:18) at Object.createApidocSwagger (/usr/local/lib/node_modules/apidoc-swagger/lib/index.js:107:63) at Object. (/usr/local/lib/node_modules/apidoc-swagger/bin/apidocSwagger.js:143:19) at Module._compile (module.js:660:30) at Object.Module._extensions..js (module.js:671:10) at Module.load (module.js:573:32)

Any update?

Eamonnzhang commented 5 years ago

still got the same error

newsages commented 4 years ago

Same

BorisKotlyarov commented 4 years ago

Open file apidocToSwagger.js row 274 replace if (verbs.parameter && verbs.parameter.fields.Parameter) to if (verbs.parameter && verbs.parameter && verbs.parameter.fields && verbs.parameter.fields.Parameter)

image

see PR #57

18819296186 commented 4 years ago

I know why throw this error now~ Look at the photos.

var type = parameter.type; This variant need to get the type, and this type from {}. But code lack the {}

@apiParam {string} userId 用户

image

aaaaaaaaaaalex commented 7 months ago

@18819296186, you are right. In order to solve this problem: Open file apidocToSwagger.js on row 190 replace var typeIndex = type.indexOf("[]"); to var typeIndex = type === undefined ? -1 : type.indexOf("[]");