Skip to content

Commit 005a446

Browse files
committed
Migration guide for version 3.0
1 parent 2594df3 commit 005a446

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

MIGRATION.md

+69
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,72 @@
1+
# Migrating to JSON Forms 3.0 for React users
2+
3+
With version 3.0 of JSON Forms, we removed the `json-schema-ref-parser` dependency within the core package.
4+
This change only affects users of the React variant (Vue and Angular are not affected) and even for React only a few users will need to adjust their code.
5+
Problematic cases are mostly complex `$ref` setups, often in combination with `anyOf`, `allOf` or `oneOf`.
6+
To restore the previous behavior, you can use `json-schema-ref-parser` or `json-refs` to resolve references on your own before passing the schema to JSON Forms.
7+
Here is an example, how to use these libraries to resolve your refs before handing the schema to JSON Forms:
8+
9+
```ts
10+
import React, { useState } from 'react';
11+
import { JsonForms } from '@jsonforms/react';
12+
import { materialCells, materialRenderers } from '@jsonforms/material-renderers';
13+
import $RefParser from '@apidevtools/json-schema-ref-parser';
14+
import JsonRefs from 'JsonRefs';
15+
16+
const schema = {
17+
$defs: {
18+
Base: {
19+
type: 'object',
20+
properties: {
21+
width: {
22+
type: 'integer'
23+
}
24+
}
25+
},
26+
Child: {
27+
type: 'object',
28+
allOf: [
29+
{ $ref: '#/$defs/Base' },
30+
{
31+
properties: {
32+
geometry: {
33+
type: 'string'
34+
}
35+
}
36+
}
37+
]
38+
}
39+
},
40+
type: 'object',
41+
properties: {
42+
element: {
43+
$ref: '#/$defs/Child'
44+
}
45+
}
46+
};
47+
48+
const resolvedSchema = $RefParser.dereference(schema)
49+
// or
50+
const resolvedSchema = JsonRefs.resolveRefs(schema)
51+
52+
function App() {
53+
const [data, setData] = useState(initialData);
54+
55+
return (
56+
<JsonForms
57+
schema={resolvedSchema}
58+
uischema={uischema}
59+
data={data}
60+
renderers={materialRenderers}
61+
cells={materialCells}
62+
onChange={({ data, _errors }) => setData(data)}
63+
/>
64+
);
65+
}
66+
```
67+
68+
For more information have a look at our [ref-resolving](https://jsonforms.io/docs/ref-resolving) docs page.
69+
170
# Migrating to JSON Forms 2.5 for Angular users
271
The JsonFormsAngularService is not provided in the root anymore.
372
To keep the old behavior, you need to provide it manually in the module.

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ Please see the official JSON Forms website, [jsonforms.io](https://jsonforms.io)
1515
For more info about the seed app, please see the corresponding README file of the [seed repo](https://github.com/eclipsesource/jsonforms-react-seed).
1616
For a more detailed tutorial about the usage of JSON Forms, please see [this tutorial](http://jsonforms.io/docs/tutorial).
1717

18+
## Upgrading to 3.0
19+
20+
Within version 3.0 of JSON Forms we removed the `json-schema-ref-parser` dependency from the core package.
21+
This change only affects users of the React variant (Vue and Angular are not affected) and even for React only a few users will need to adjust their code.
22+
If you use ref resolving in combination with `anyOf`, `allOf` or `oneOf`, there could be problems.
23+
To avoid issues and for more information, please have a look at our [migration guide](https://github.com/eclipsesource/jsonforms/blob/master/MIGRATION.md).
24+
25+
As long as version 3.0 is in alpha stage, we will work on smoothing things out and try to avoid as many issues as possible.
26+
1827
## Feedback, Help and Support
1928

2029
If you encounter any problems feel free to [open an issue](https://github.com/eclipsesource/jsonforms/issues/new/choose) on the repo.

0 commit comments

Comments
 (0)