Nested objects within schema properties #1959
Unanswered
tyler-mairose-sp
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Is it possible to use the basic ruleset builder to check recursive objects as a valid schema? I tried several things.
I've tried making a definitions section as well, and referencing from there, I've tried with an |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The Issue
I have a schema object that looks like the below json structure. I wanted to use the truthy function to make sure that each property in all parts of this object have an example.
I first tried the following rule to access properties at the first level, however when it gets to requesterIdentitySummary that field is a nested object and I want to check those properties as well.
I then thought I could add another given with the second level of properties like so, however to get all properties back to check n level deep this does not seem like the best way to go about it.
I then wrote a custom function that takes the whole schema object below and recursively checks if any objects exist in the properties and will call itself again when it finds another object. That code is below:
I get the results I expect, I am wondering if there is a better way to get what I am looking for with JSONPath. I just recently started working with spectral/JSON Path so I am looking to the community to see if what I created is what is considered best practice?
The Schema Object File that I call the linter on:
Beta Was this translation helpful? Give feedback.
All reactions