riboseinc / ribose-api

API for Ribose
0 stars 0 forks source link

Blueprints validator #34

Closed skalee closed 6 years ago

skalee commented 6 years ago

This is an initial version of Drafter-based validator. Comments are welcome.

  1. I had troubles with compiling a C-based variant of Drafter, therefore I've decided to use Drafter.js, its Emscripten-powered JavaScript counterpart.
  2. Validator reports plenty of errors for our current blueprints. Maybe it's worth to ignore some error types. Here is the output: https://gist.github.com/skalee/a66ab5953373022d1a41e32060816df1.
  3. All reusable component (like https://github.com/riboseinc/ribose-api/blob/master/sections/profile/profile.apib) do not pass because they aren't meant to be complete documents. Perhaps we should skip them when validating.
  4. In order to run the validator, install Node.js and do following:
    $ npm install colors drafter.js glob
    $ node validator.js

Fixes #33.

ribose-jeffreylau commented 6 years ago

Nice!

I think we should make it only check the final APIB output file, i.e. apiary.apib, because all other files can only be considered as inputs and thus are not representational.

The other thing is, I haven't found a way yet to specify empty strings as sample values in APIB, which is why you'd see warnings about having no specified values.

skalee commented 6 years ago

I suppose checking sections/*.apib may be useful as well. Output is more useful than for the aggregated document because it tells you issue location precisely.

skalee commented 6 years ago

OK, got your point.

skalee commented 6 years ago

@ribose-jeffreylau Why not:

+ `s`: `""` (string) - pagination synchronization string

or

+ `s` (string) - pagination synchronization string

instead of:

+ `s`:  (string) - pagination synchronization string

Both do pass in my validator.

skalee commented 6 years ago

@ronaldtse Might be a good idea to enable Travis for this repository.

skalee commented 6 years ago

Regarding the aggregated document validity, the current result is as follows:

Checking apiary.apib… FAIL
  warning code 5 in line 195 - ignorning unrecognized block:
    [comment]: <> (REFERENCE section)
  warning code 6 in line 2667 - no value(s) specified:
    `body`:  (string) - Body of invitation message to the invitees
  warning code 6 in line 2705 - no value(s) specified:
    `s`:  (string) - pagination synchronization string
  warning code 6 in line 2800 - no value(s) specified:
    `s`:  (string) - pagination synchronization string
  warning code 6 in line 2843 - no value(s) specified:
    `body`:  (string) - Body of invitation message to the invitees
  warning code 6 in line 2941 - no value(s) specified:
    `s`:  (string) - pagination synchronization string
  warning code 2 in line 3032 - action with method 'PUT' already defined for resource '/invitations/join_space_request/{invitation_id}':
    #### Updating pre-assigned role [PUT]
  warning code 6 in line 3067 - no value(s) specified:
    `s`:  (string) - pagination synchronization string

So we got three kinds of warnings.

ronaldtse commented 6 years ago

@skalee enabled Travis. Let's merge this for now and keep the warnings to separate issues. Thanks!

skalee commented 6 years ago

Created #35, #36, and #37.