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

feat: arrayish given #799

Merged
merged 3 commits into from
Nov 22, 2019
Merged

feat: arrayish given #799

merged 3 commits into from
Nov 22, 2019

Conversation

P0lip
Copy link
Contributor

@P0lip P0lip commented Nov 21, 2019

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

Currently we only allow a single JSON path expression to be provided at a time for each rule.
That limitation may lead to a situation where a complex json path expression needs to be provided in order to match all intended properties. In most cases, those expressions could be split into 2-3 that would be much simpler.

@jerzyn
Copy link

jerzyn commented Nov 21, 2019

would this mean given could be a single value or an array? Or how do you envision that?
i.e. in JSON-Schema terms:

given:
  oneOf:
    - type: string
    - type: array
      items:
        type: string

@P0lip
Copy link
Contributor Author

P0lip commented Nov 21, 2019

@jerzyn
That's right. I even used exactly the same schema in ruleset JSON schema 😅
https://github.com/stoplightio/spectral/pull/799/files#diff-1eb67ba0248f0910e2cd0525f69731dcR69-R79

@jerzyn
Copy link

jerzyn commented Nov 21, 2019

i should do these examples professionally ;)

@P0lip P0lip marked this pull request as ready for review November 22, 2019 02:39
@P0lip P0lip added the enhancement New feature or request label Nov 22, 2019
@P0lip P0lip self-assigned this Nov 22, 2019
@P0lip P0lip merged commit 6c6d6e3 into develop Nov 22, 2019
@P0lip P0lip deleted the feat/arrayish-given branch November 22, 2019 12:29
## Given

The `given` keyword is, besides `then`, the only required property on each rule definition.
It can be any valid JSONPath expression or an array of JSONPath expressions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@P0lip Nit: From a reader's perspective, it's not very clear if, for the rule to pass, all the expressions have to satisfy the expectation or at least one of them.

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 this pull request may close these issues.

4 participants