Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing json-schema drafts #1556

Closed
yordis opened this issue Mar 23, 2021 · 1 comment · Fixed by #1584
Closed

Missing json-schema drafts #1556

yordis opened this issue Mar 23, 2021 · 1 comment · Fixed by #1584
Assignees
Labels
enhancement New feature or request

Comments

@yordis
Copy link

yordis commented Mar 23, 2021

Describe the bug

It seems that spectral doesn't support all the JSON-Schema published drafts

To Reproduce

# .spectral.yaml
rules:
  events-schemas:
    description: Must follow the Events schema
    given: '$'
    then:
      function: schema
      functionOptions:
        schema:
          $ref: ./events.json
// data file: ./events/data/events.json
{
  "$schema": "./events.json", // points to some schema locally
}
{
  "$schema": "https://json-schema.org/draft/2020-12/schema", // this is the issue, it is not recognized by ajv
  "type": "object"
}

Run

spectral lint ./events/data/events.json --ignore-unknown-format

**Expected behavior**
A clear and concise description of what you expected to happen.

```text
$ spectral lint ./events/data/events.json --ignore-unknown-format
Error: no schema with key or ref "https://json-schema.org/draft/2020-12/schema"
    at Ajv.validate (/myapp/spec/node_modules/ajv/lib/ajv.js:93:19)
    at Ajv.validateSchema (/myapp/spec/node_modules/ajv/lib/ajv.js:174:20)
    at Ajv._addSchema (/myapp/spec/node_modules/ajv/lib/ajv.js:307:10)
    at Ajv.compile (/myapp/spec/node_modules/ajv/lib/ajv.js:113:24)
    at WeakMap.get (/myapp/spec/node_modules/@stoplight/spectral/dist/functions/schema.js:70:29)
    at Object.exports.schema (/myapp/spec/node_modules/@stoplight/spectral/dist/functions/schema.js:92:87)
    at Object.exports.lintNode (/myapp/spec/node_modules/@stoplight/spectral/dist/runner/lintNode.js:30:33)
    at runRule (/myapp/spec/node_modules/@stoplight/spectral/dist/runner/runner.js:27:24)
    at Runner.run (/myapp/spec/node_modules/@stoplight/spectral/dist/runner/runner.js:98:17)
    at Spectral.runWithResolved (/myapp/spec/node_modules/@stoplight/spectral/dist/spectral.js:101:22)
No results with a severity of 'error' or higher found!

Environment (remove any that are not applicable):

  • "@stoplight/spectral": "^5.9.0"
@yordis yordis added the t/bug Something isn't working label Mar 23, 2021
@P0lip
Copy link
Contributor

P0lip commented Mar 31, 2021

Yeah, we do not support newer drafts just yet.
This will be done as a part of our OAS 3.1 support epic, we're about to start soon.
Stay tuned.

@P0lip P0lip self-assigned this Apr 22, 2021
@P0lip P0lip mentioned this issue Apr 26, 2021
4 tasks
@P0lip P0lip added enhancement New feature or request and removed t/bug Something isn't working labels Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants