-
-
Notifications
You must be signed in to change notification settings - Fork 248
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
Copy format from allOf in JSONSchemaBridge #863
Comments
Hi @hmvp. The problem with copying all properties is that they can overwrite each other. The reason why we merge
That's a valid request. I'm not sure about it though. Maybe it'd be better to rethink the handling of these properties? I mean, this approach (accumulating properties) makes sense for |
Yeah it seems fair that My usecase involves schemas generated by pydantic: https://pydantic-docs.helpmanual.io/usage/schema/ Which afaik only uses So reading up a bit on the three keywords, some thoughts:
|
I agree with most of what you've said.
It's out of scope of uniforms. This would require to let bridge know, what is the current state of the form (e.g.
Partially, it works like this now. But you have to adjust the schema yourself. And I think it's the suggested workaround for now - either adjust the schema manually (if you can) or create a function that does exactly that, based on your needs. |
It does not have to be. I would propose to do that in a stateless way. E.g. Similar to ListField the bridge would inject an intermediary field with a toggle widget and a hidden field for each option. This would probably mess with the paths a bit for those subfields... {
"type": "object",
"properties": {
"union_field": {
"oneOf": [
{ "type": "string" },
{ "type": "int" }
]
}
}
} would lead to something like <AutoForm>
<UnionField name="union_field">
<ChooseTypeField name="union_field.$"/>
<TextField name="union_field.0" />
<NumField name="union_field.1"/>
</UnionField>
</AutoForm> where UnionField would need to do the heavy lifting to set the correct values in the model
|
Your example has one problem - how {
"type": "object",
"properties": {
"union_field": {
"oneOf": [
{ "type": "int", "min": 5 },
{ "type": "int", "max": 5 }
]
}
}
} And that's what I meant - you can create |
Another similar issue:
|
I've discussed this issue with a few more people heavily relying on JSON schema. To sum up, we all agree that the current handling of We'll update the documentation with limitations of the current implementation as well as example workarounds. For this very problem, a workaround would be to preprocess the schemas before passing them to the form, hoisting certain properties from |
The code copies properties and type from allOf refs:
uniforms/packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts
Lines 198 to 212 in be843c7
However I have a schema like this:
And my code relies on the format property to choose the right component. However it is not copied from the BFD definition. I find it odd that only a few keys are copied and not everything. If anything I would like to see format copied, but maybe everything should be copied that does not exist yet.
The text was updated successfully, but these errors were encountered: