apiaryio/drafter.js

parseSync return values appear to be different to drafter

Closed this issue · 2 comments

It's a little difficult to identify whats changed, but this doesnt appear to be a 1:1 API compatible library with drafter. We've been considering using drafter.js because the install time is significantly (~2 minutes) faster. Is there any documentation on the differences between this and drafter?

To give a precise example, the results content for drafter.parseSync seems to have a meta object where classes is an array, but with drafter.js this is an object.

kylef commented

drafter.js and Protagonist have the same API, providing you are using equivilent versions. drafter.js@3.0.0 and protagonist@2.0.0 should have an identical API. We provide a collection of interfaces ontop of drafter* at https://github.com/apiaryio/api-elements.js which perhaps may be of use to you instead of directly using Protagonist/drafter.js. It providers higher level abstractions to handling the parse results.

The difference between Protagonist and Drafter.js is that one is native JavaScript, transpilled from the C++ parser. Protagonist is a NodeJS binding for the C++ parser. For many uses, using drafter.js over Protagonist can be fine, when you are dealing with performance of parsing larger API Blueprints or many blueprints at once you may want to use Protagonist as it can be much faster. The drafter package at https://github.com/apiaryio/drafter-npm/#drafter-npm-package- can be used to support both.

To find differences between versions, you can look at the CHANGELOG.md file in Protagonist and drafter.js respectively, these will link to Drafter (the underlying C++ parser that is used to build drafter.js and Protagonist) changelog which show specific outputs in the parse results (https://github.com/apiaryio/drafter/blob/88e79114c40850bf28c4909ac50615e4d7122ad5/CHANGELOG.md#400-pre0 for example).

Thanks for the links Kyle, really helpful!