-
Notifications
You must be signed in to change notification settings - Fork 45
feat: hide examples option #134
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
Conversation
|
@P0lip adding that property was an issue requirement, is it acceptable from your side? We were considering just modifying schema object but that would require lot of additional processing. |
|
Yeah, seems okay.
Hmm, it should be quite easy actually. jsonSchemaTree.walker.on('exitNode', node => {
if (!isRegularNode(node)) return;
for (const field of ['examples', 'example', 'x-example']) {
if (Array.isArray(node.annotations[field])) {
node.validations[field] = node.annotations[field];
delete node.annotations[field];
}
});
Anyhoo, what you have here is totally fine. |
paulatulis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I pulled this down and played around with it, it worked for me, so I am going to approve, but @P0lip it might make everyone feel more secure if you also give your stamp of approval ;)
I guess my only more general question is related to the issue and understanding why this particular thing would necessitate an extra prop when other items are deemed appropriate to alter the schema. Maybe this doesn't come up very often and it looks like it was already sussed out in the issue anyway. Just curious if this is a common occurrence.
The reason is that we need to have possibility to not display example validations from Elements to not duplicate it as it already includes examples in different component. We could do it by feeding jsv with modified schema but that would need to be done from elements and require some additional computation on each schema change that might decrease performance. That is the only optional validation that might exist so we definitely won't be adding any more weird props. |
That makes sense! Thanks @mallachari :) |
|
🎉 This PR is included in version 4.0.0-beta.13 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 4.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fixes stoplightio/elements#1026
Adds
hideExamplesproperty to JSV that prevents rendering example validations.