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

add support for JSON Schema Draft-06, Draft-07 and 2019-09 in schema function (rulesets) #573

Closed
jerzyn opened this issue Sep 19, 2019 · 2 comments · Fixed by #576
Closed
Assignees
Labels
enhancement New feature or request

Comments

@jerzyn
Copy link

jerzyn commented Sep 19, 2019

User story.
As a user I want to reference JSON Schema Draft-06, Draft-07 or 2019-09 in schema function in my rulesets.

Is your feature request related to a problem?
I want to have a possibility to use newest JSON Schema drafts for schema validation in my custom rulesets. My data models are defined using draft-07 currently and they are not being loaded.

Describe the solution you'd like
I would like to add external referenced JSON Schema files following the latest drafts

Additional context
Custom Rulesets

@P0lip P0lip self-assigned this Sep 19, 2019
@P0lip P0lip added the enhancement New feature or request label Sep 19, 2019
@philsturgeon
Copy link
Contributor

@jerzyn hey, im not sure what you mean by "not being loaded"? Do you have some example files we can play with and some expected behavior vs actual behavior?

AFAIK Spectral doesn't care about the JSON Schema draft version at all, it only cares that some sort of JSON/YAML file is being loaded and it will follow any $ref it finds along the way (including some places maybe it should not).

If you are using JSON Schema in the context of OpenAPI then that's a different thing. OpenAPI v3.0 does not support drafts of JSON Schema newer than its own "extended subset" of draft 5 and there is nothing we can do to change that other than hope my PR (OAI/OpenAPI-Specification#1977) goes through. Chatting to the OpenAPI TSC about that in 2 hours.

@jerzyn
Copy link
Author

jerzyn commented Sep 19, 2019

i was chatting about this with @P0lip - maybe check with him. As for files - using this: https://supermodel.io/adidas/api/HAL (not as a reference to this file but this exact code together with $schema) was not loading. Deleting $schema or changing it to draft-04 was fixing the issue. The rule was:

    description: All success responses MUST be of media type `application/hal+json`
    severity: error
    given: $.paths..responses[?( @property >= 200 && @property < 300 )]
    recommended: true
    severity: error
    type: "style"
    message: "Response documents MUST follow application/hal+json: {{error}}"
    then:
      field: schema
      function: schema
      functionOptions:
        schema:
          $ref: ./hal.yaml```

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