JSONForms Schema and UI Schema schema

Hi, I am creating a live-edit component for JSONForms with a preview of the user-created schema.

The live render breaks when the schema is invalid, so I’d like to conditionally render the preview form based on the validity of both the Schema and UI Schema (if provided).

Is there a JSON schema for both the Schema and UI Schema I can use?

I am almost certain this has been asked before, but it is a very difficult query to search for.

Hi @ben,

JSON Schema is an open standard, and yes they have a JSON Schema describing JSON Schema itself, see here.

We don’t have an official JSON Schema for the UI Schema. However the UI Schema is so simple that it should be straightforward to create one if you need it. In our own (currently not maintained) JSON Forms editor we used a draft-7 meta schema for JSON Schema and a JSON Schema for the rule-part of JSON Forms, see here.

If you create a full JSON Schema for the UI Schema, then let me know. I would be happy to make it available officially if you want us to.

Hi @sdirix

Thanks for your links but I’m not able to find what I need, for example this is an invalid JSONForms schema that succesfully validates against all schemata on the linked pages*:

{
    "myField": {
        "type": "string",
        "array": [],
        "foo": "bar"
    }
}

*With the exception of the example output schema, but neither do valid JSONForms schema either.

Thanks for your help!

That is a valid JSON Schema. It’s just empty as it does not specify a single relevant keyword. JSON Forms could even show a UI for it in case that you register a renderer which can handle this “custom” schema.

If you want to restrict the JSON Schema to cases in which your (or off-the-shelf) renderer set shows some UI, then you need to use a much more restricted JSON Schema than the official spec.

That is a valid JSON Schema. It’s just empty as it does not specify a single relevant keyword.

I understand it is valid JSON, but it isn’t valid JSONForms JSON. I am looking for a JSONForms meta-schema against which to validate user-entered JSONForms schema.

If you want to restrict the JSON Schema to cases in which your (or off-the-shelf) renderer set shows some UI, then you need to use a much more restricted JSON Schema than the official spec.

I am not using any custom renderers and rarely any UI Schema, just the defaults in the Vue package.

I’m a little confused here because JSONForms cannot render any JSON schema, it must be a valid JSONForms schema. I am simply looking for that meta-schema.

Hi @ben,

Technically JSON Forms can support any kind of schema, it all depends on the renderer set. Each renderer set consists of pairs of testers and renderers. Our off-the-shelf renderer sets are geared towards JSON Schema. But even there we have different levels of support, depending on the renderer set. However nothing prevents a custom renderer to support arbitrary constructs in the handed over JSON Schema. In fact this is actually often done for non-standard use cases.

So if you want to allow only JSON Schemas which produce a sensible UI for the renderer set you are using, you should use the generic JSON Schema schema, but add additional constraints. For example to force the JSON Schema to describe an object with at least one property.

However I’m pretty sure that JSON Schema itself is not powerful enough to fully decide whether a given JSON Schema will be rendered by JSON Forms in a sensible way.