twskj / pretty-swag

Pretty UI for Swagger spec
MIT License
121 stars 20 forks source link

pretty-swag fails on call with exception #23

Closed dothebart closed 7 years ago

dothebart commented 7 years ago

I wanted to try pretty-swap with our example over at https://github.com/arangodb/arangodb/blob/devel/js/apps/system/_admin/aardvark/APP/api-docs.json?raw=true

I tried it like this:

pretty-swag -i js/apps/system/_admin/aardvark/APP/api-docs.json

Source: js/apps/system/_admin/aardvark/APP/api-docs.json
Dest: doc.html
Format:  singleFile
MarkDown:  Disable
Nav Bar:  Normal
Theme: blue
``` /usr/lib/node_modules/pretty-swag/node_modules/esprima/dist/esprima.js:3391 throw error; ^ Error: Line 12: Invalid regular expression: missing / at ErrorHandler.constructError (/usr/lib/node_modules/pretty-swag/node_modules/esprima/dist/esprima.js:3396:22) at ErrorHandler.createError (/usr/lib/node_modules/pretty-swag/node_modules/esprima/dist/esprima.js:3414:27) at ErrorHandler.throwError (/usr/lib/node_modules/pretty-swag/node_modules/esprima/dist/esprima.js:3422:21) at Scanner.throwUnexpectedToken (/usr/lib/node_modules/pretty-swag/node_modules/esprima/dist/esprima.js:3505:28) at Scanner.scanRegExpBody (/usr/lib/node_modules/pretty-swag/node_modules/esprima/dist/esprima.js:4510:19) at Scanner.scanRegExp (/usr/lib/node_modules/pretty-swag/node_modules/esprima/dist/esprima.js:4566:26) at Tokenizer.getNextToken (/usr/lib/node_modules/pretty-swag/node_modules/esprima/dist/esprima.js:6363:72) at Object.tokenize (/usr/lib/node_modules/pretty-swag/node_modules/esprima/dist/esprima.js:136:36) at computeSchema (/usr/lib/node_modules/pretty-swag/pretty-swag.js:133:26) at /usr/lib/node_modules/pretty-swag/pretty-swag.js:426:44 ```

The installation looked like this:

``` #npm install pretty-swag -g /usr/bin/pretty-swag -> /usr/lib/node_modules/pretty-swag/bin/run.js /usr/lib `-- pretty-swag@0.1.90 +-- highlight.js@9.10.0 +-- json-schema-ref-parser@3.1.2 | +-- call-me-maybe@1.0.1 | +-- debug@2.6.3 | | `-- ms@0.7.2 | +-- es6-promise@3.3.1 | +-- js-yaml@3.8.3 | | +-- argparse@1.0.9 | | | `-- sprintf-js@1.0.3 | | `-- esprima@3.1.3 | +-- ono@2.2.4 | `-- z-schema@3.18.2 | +-- commander@2.9.0 | | `-- graceful-readlink@1.0.1 | +-- lodash.get@4.4.2 | +-- lodash.isequal@4.5.0 | `-- validator@6.3.0 +-- livedoc@0.1.50 +-- marked@0.3.6 `-- pluralize@3.1.0 # node --version v5.12.0 ```
twskj commented 7 years ago

let me check in a bit

twskj commented 7 years ago

Thanks for your thorough spec. I was able to catch a few bugs from it :-)

So the current version of Pretty-Swag doesn't support embedded html yet. In case of Arango's spec, the embedded html can be replaced by a markdown.

''' json shell> curl -X PUT --data-binary @- --dump - http://localhost:8529/_api/simple/by-example <"collection" : "products", "example" : { "a" : { "j" : 1 } } } EOF HTTP/1.1 201 Created content-type: application/json; charset=utf-8 { "result" : [ { "_key" : "10598", "_id" : "products/10598", "_rev" : "UWx9mUK--", "a" : { "j" : 1 }, "i" : 1 } ], "hasMore" : false, "count" : 1, "error" : false, "code" : 201 } '''

Also you may find these params useful

pretty-swag -i spec.json -o arango.html -m -f lite -fixedNav -indent 3 -autotags false
twskj commented 7 years ago

One more thing. Pretty-Swag doesn't support mark down on schema's description yet. Try it out and let me know.