Multiple schema

Hello,

I want to be able to target several schemas (Json Schema) from the same UI schema and Data.
Is this possible?

The goal is to use the same properties in different format.

Hi @dobl1,

I don’t fully understand your question. The UI Schema and JSON Schema must be compatible as the UI Schema uses JSON pointers to refer the controls to the respective (sub) JSON Schema. So as long as these can be resolved (i.e. the structure of the pointed to elements stays the same) you can exchange the JSON Schema.

Very simple example:

If you have the following UI Schema

{
  type: 'Control',
  scope: '#/properties/name'
}

then it will work with both these JSON Schemas

{
  type: 'object',
  properties: {
    name: { type: 'string' }
 }
}
{
  type: 'object',
  properties: {
    name: { type: 'number' },
    age: { type: 'number' }
 }
}

because both JSON Schemas can resolve the scope which is defined in the UI Schema.

Does this answer the question?

Hey @sdirix ,

Thanks for your response. What I’m looking for it to have several scope for the same UI Schema element.

I mean my goal / use case is to have a configuration page with two panels.
On the left you have the JSON form, on the right severals tabs to target different document formats (JSON Schemas) that uses the same UI Schema and Data.

With the following UI Schema

{
  type: 'Control',
  scope: '#/properties/name'
}

Target these schemas.

{
  type: 'object',
  properties: {
  name: { type: 'string' }
  }
}
{
type: 'object',
properties: {
  person: { 
    type: 'object',
    properties: {
      name: { type: 'string' }
    }
  }
}

Hi @dobl1,

similar to renderers we also offer a uischemas registry as a prop for the main JSON Forms component. Whenever a detail UI Schema is required, the uischemas registry will be checked.

So in your case you could register the given UI schema and it will then be used also for the second schema for the person property.

Hello,

I understand the answer, but I’m struggling to understand how to set up this behavior.

Do you have an example?