Basic jsonpath throws exception
connorpwilliams opened this issue · comments
Connor Williams commented
Using the path $.paths.*[get,put,patch,post,delete]
to get operations in an OAS json file - jsonpath.com has no issues - this package throws below exception
(node:26116) UnhandledPromiseRejectionWarning: Error: Parse error on line 1:
$.paths.*[get,put,patch,post,d
----------^
Expecting 'STAR', 'SCRIPT_EXPRESSION', 'INTEGER', 'ARRAY_SLICE', 'FILTER_EXPRESSION', 'QQ_STRING', 'Q_STRING', got 'IDENTIFIER'
at Parser.parseError (C:\Users\sesa554024\workspace\seapim-reqs\node_modules\jsonpath\generated\parser.js:166:15)
at Parser.parser.yy.parseError (C:\Users\sesa554024\workspace\seapim-reqs\node_modules\jsonpath\lib\parser.js:13:17)
at Parser.parse (C:\Users\sesa554024\workspace\seapim-reqs\node_modules\jsonpath\generated\parser.js:224:22)
at JSONPath.nodes (C:\Users\sesa554024\workspace\seapim-reqs\node_modules\jsonpath\lib\index.js:118:26)
at JSONPath.paths (C:\Users\sesa554024\workspace\seapim-reqs\node_modules\jsonpath\lib\index.js:105:22)
at getRouteOperations (C:\Users\sesa554024\workspace\seapim-reqs\resources\specUtils.js:65:79)
at find (C:\Users\sesa554024\workspace\seapim-reqs\resources\specUtils.js:17:20)
at compare (C:\Users\sesa554024\workspace\seapim-reqs\resources\spec-compare.js:19:29)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Mo Morsi commented
The part between the brackets needs to be a valid/complete javascript statement. It won't get execute per-se but gets parsed w/ jison and evaluated by static-eval
Connor Williams commented
Ah - got it. So to do a string match I surrounded each word with quotes and that seems to have solved my issue. Thanks!