dyne / restroom-mw

🛠 Easy REST API builder executing Zencode
https://restroom.dyne.org
GNU Affero General Public License v3.0
3 stars 11 forks source link

Crash with scenario parser in @restroom-mw/zencode #173

Closed andrea-dintino closed 2 years ago

andrea-dintino commented 2 years ago

This script:

Scenario ecdh
Scenario ethereum
Scenario reflow
Scenario schnorr

Given nothing

# Here we are creating the keys
When I create the ecdh key
When I create the ethereum key 
When I create the reflow key
When I create the schnorr key
When I create the bitcoin key

Then print data

when opening Swagger, it makes restroom/apiroom crash:


/home/bario/Desktop/apiroom/node_modules/@restroom-mw/zencode/dist/index.js:89
        return this.__parseDescription((words) => words[1].trim());
                                                           ^

TypeError: Cannot read properties of undefined (reading 'trim')
    at /home/bario/Desktop/apiroom/node_modules/@restroom-mw/zencode/dist/index.js:89:60
    at Zencode.__parseDescription (/home/bario/Desktop/apiroom/node_modules/@restroom-mw/zencode/dist/index.js:79:24)
    at Zencode.get summary [as summary] (/home/bario/Desktop/apiroom/node_modules/@restroom-mw/zencode/dist/index.js:89:21)
    at generate (file:///home/bario/Desktop/apiroom/packages/nodejs/ui/openapi.js:107:35)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async file:///home/bario/Desktop/apiroom/packages/nodejs/ui/index.js:13:24
error Command failed with exit code 1.

Or like this in apiroom: https://gyazo.com/1f27e4141324e0157ffea5f3f4dfa09e

puria commented 2 years ago

Yep the gherkin syntax for the Scenario: is wrong as per: https://docs.behat.org/en/v2.5/guides/1.gherkin.html#scenarios needs always a colon.

I'll make a more meaningful error message, that would help ;)

jaromil commented 2 years ago

In the Zencode dialect the scenario : colon comes after the single-word naming the scenario and is followed by a free form description.

This is one of many subtle differences from gherkin: scenario can be followed by any number of strings until a colon is found, the first of such strings will be taken as name of scenario.

Source: src/lua/zencode.lua line 288

puria commented 2 years ago

Yep that is already supported as in Scenario outlines but in any case the colon is mandatory.