-
Notifications
You must be signed in to change notification settings - Fork 45
feat: primary type #18
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
src/utils/walk.ts
Outdated
| annotations: getAnnotations(node), | ||
| enum: node.enum, | ||
| }; | ||
| function getPrimaryType(node: JSONSchema4) { |
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 if type is ["object", "array"]
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.
Really the user should be using a oneOf like below, but if having both in type is valid json-schema we definitely need to support it
{
"oneOf": [
{"$ref": "#/definitions/singleObject"}, // plain object
{
"type": "array", // array of plain objects
"items": {"$ref": "#/definitions/singleObject"}
}
],
"definitions": {
"singleObject": {...}
}
}
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.
This also means that if type is ["object", "array"] we need to infer that its a combiner type oneOf so it renders properly in 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.
Yeah, shared the same concern here #17 (comment).
I'm not sure if displaying oneOf is safe though. To me, it sounds like a nice idea, but we'll need to make it reliable (transform the data correctly).
@marbemac, what's your take on this?
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.
I think we don't worry about this use case until a customer complains about it.
|
🎉 This PR is included in version 1.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
No description provided.