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

Allow creating a rule that combines other rules using OR #2381

Open
altmank opened this issue Jan 12, 2023 · 3 comments
Open

Allow creating a rule that combines other rules using OR #2381

altmank opened this issue Jan 12, 2023 · 3 comments
Labels
enhancement New feature or request triaged

Comments

@altmank
Copy link

altmank commented Jan 12, 2023

User story.
As a spectral user, I can create rules that combine other rules and evaluate them using OR, so that I can define rules where one of multiple possible approaches is valid but only 1 is required.

Is your feature request related to a problem?
I cannot create a rule currently that forces a parameter to have an example but allow the example to be in the schema or in the top level parameter object.

Example:
image

Describe the solution you'd like
I can define each of these rules individually, to look for example in the schema object, or in the parameter object, and then add a truthy function on them, but I cannot check both of these together using OR logic.

Additional context
Add any other context or screenshots about the feature request here.

@P0lip
Copy link
Contributor

P0lip commented Jan 12, 2023

Hey!
Thanks for submitting the feature request.
We already have a similar proposal over here #1276, so I'm going to close this one out.
Feel free to upvote and follow the one above

@altmank
Copy link
Author

altmank commented Jan 12, 2023

@P0lip #1276 appears to be specific to combining functions, whereas I want to combine rules. I do not believe combining functions would solve for the example I raised here.

@altmank
Copy link
Author

altmank commented Jan 12, 2023

@P0lip Is there some other approach you can think of that would solve this example? It isn't encouraging that the other item you referenced is 3 years old. I tried something like this but it did not work:

"given": [ "$.paths.*.*.parameters[?(@.example || @.schema.example)]" ], "severity": "error", "then": { "function": "defined" },

@mnaumanali94 mnaumanali94 added the enhancement New feature or request label Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triaged
Projects
None yet
Development

No branches or pull requests

3 participants