Skip to content

v0.8.6 fails to show proper error on invalid schema #234

@dlouzan

Description

@dlouzan

Detailed description

The latest 0.8.6 version fails to print proper advice on invalid specs:

> speccy lint swagger.json

./node_modules/speccy/lint.js:83
        const { context, lintResults } = _options;
                ^

TypeError: Cannot destructure property `context` of 'undefined' or 'null'.
    at validator.validate (./node_modules/speccy/lint.js:83:42)
    at ./node_modules/call-me-maybe/index.js:13:28
    at process._tickCallback (internal/process/next_tick.js:61:11)

whereas version 0.8.5 properly hints at the underlying issue:

> speccy lint swagger.json

Specification schema is invalid.

#/paths/~1api<hidden>/post/parameters/0
path parameters must appear in the path

Context

I'm working on linting both v2 (using swagger2openapi) and v3 files from an older project. Some of the existing v2 files had not been linted before, and seems they are not even spec compliant.

The nodejs exception does not help finding out where the error actually lies, it looks to a user as if speccy is having an issue, instead of parsing an invalid spec.

Your environment

  • Node Version: Both latest v8 & v10 via nvm
  • Operating system and version: Debian 9.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions