-
Notifications
You must be signed in to change notification settings - Fork 45
fix: array of objects with properties #17
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
|
|
||
| function getType(node: JSONSchema4) { | ||
| if (Array.isArray(node.type)) { | ||
| return node.type.length === 1 ? node.type[0] : node.type; |
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.
We return a string if there's only one, but an array if theres none or more than one? Is that correct? Just making sure
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.
We return a string if there's only one, but an array if theres none or more than one? Is that correct? Just making sure
Well, I'm not sure how to handle such a scenario. For instance, there is no way we can display both array of items and object with properties.
Our UI is just too simple.
We would need to have something more or less similar to http://jlblcc.github.io/json-schema-viewer/ to handle such a case.
@marbemac what your thought on that?
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.
Also, we should be handling not, which we don't at the moment.
Any suggestions on the UI?
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.
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.
What is not?
We don't have to handle array and object in same property. We can suggest people use oneOf if they need that, although its kind of crazy and definitely an edge case.
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.
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.
@lottamus yeah, pretty much that
{
"type": ["array", "object"],
"properties": {
"bar": {
"type": "string"
}
},
"items": [
{
"type": "number"
},
{
"type": "object",
"properties": {
"foo": {
"type": "number"
}
}
}
]
}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.
Got it, we can skip not for now - I haven't seen it used in the wild by our customers yet, and would need to support it in JSE as well. A good addition for later, but not high priority right now.
|
Do we have this fix on the v2 branch as well? |
|
🎉 This PR is included in version 1.3.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |


No description provided.