You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All notable changes to this project will be documented in this file.
3
+
4
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+
## [Unreleased]
8
+
9
+
## [2.1.0] - 2019-05-01
10
+
### Added
11
+
- exporting helper function `getFieldValueArrayFromSchemaGroup()`
12
+
- exporting helper function `getCommonFieldValuesFromSchemaGroup()`
13
+
- exporting helper function `getMaximumFieldValueFromSchemaGroup()`
14
+
- exporting helper function `getMinimumFieldValueFromSchemaGroup()`
15
+
16
+
### Changed
17
+
- not including `anyOf` or `oneOf` in `<Inspector>` prop `parserConfig` no longer hides the respective schema parts (always including everything)
18
+
19
+
### Removed
20
+
- "type" property in `<Inspector>` prop `parserConfig.anyOf`/`parserConfig.oneOf` (i.e. always "asAdditionalColumn" behaviour from now on)
21
+
- undocumented export of helper function `getFieldValueFromSchemaGroup()`, one of the four new helper functions should be used instead
22
+
23
+
## [2.0.1] - 2019-04-24
24
+
### Changed
25
+
- values displayed in (default) Details Form now respect the validation logic behind `allOf` by not simply listing all values for the same field, but rather semantically combining/merging them
26
+
-`"type"` contains only those common/intersecting values if it appears multiple times
27
+
-`"minimum"`/`"minLength"`/`"minItems"` show the maximum value if there are multiple occurrences of the respective field
28
+
-`"maximum"`/`"maxLength"`/`"maxItems"` show the minimum value if there are multiple occurrences of the respective field
29
+
-`"const"`/`"enum"` are used interchangeably for either a single or multiple allowed values
30
+
31
+
## [2.0.0] - 2019-04-12
32
+
### Added
33
+
- general support for `anyOf` and `oneOf`
34
+
-`anyOf`/`oneOf` may be included or excluded depending on the respective fields with the same name in the `parserConfig` prop
35
+
- can determine the way of inclusion for `anyOf`/`oneOf` via the respective `type` field of value `likeAllOf` or `asAdditionalColumn` in the `parserConfig` prop
36
+
- introduction of explicit (configurable/customisable) column for accessing an array's items and/or other properties
37
+
38
+
### Changed
39
+
- named export of `<Inspector>` component (instead of default export)
40
+
41
+
### Removed
42
+
- default export of main component
43
+
44
+
## [1.2.1] - 2019-03-18
45
+
### Changed
46
+
- configuration of npm bundle; thereby reducing size of release package
47
+
48
+
## [1.2.0] - 2019-03-09
49
+
### Added
50
+
- allow to mutate the name of a selected item when including it in breadcrumbs (e.g. to sanitise it)
51
+
- allow skipping a breadcrumb (e.g. omitting the root schema selection)
52
+
- include breadcrumbs as array parameter in `onSelect` call-back
53
+
54
+
## [1.1.0] - 2019-03-08
55
+
### Added
56
+
- offering free-text search input in the top right corner
57
+
- allow defining custom search function (based on a single raw schema – handling of sub-schemas is transparent)
58
+
- allow alternative configuration of field names to search in, e.g. `["title", "description"]`
Copy file name to clipboardExpand all lines: README.md
+28-13Lines changed: 28 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ Or try it out and [![Edit on CodeSandbox][codesandbox-image]][codesandbox-url]
27
27
npm i react-jsonschema-inspector
28
28
```
29
29
30
-
### React Component Props
30
+
### React Component Props of `<Inspector>`
31
31
32
32
| Prop | Description |
33
33
| --- | --- |
@@ -37,19 +37,17 @@ npm i react-jsonschema-inspector
37
37
|`onSelect`| Function: call-back being invoked after the selection changed. Receives two parameters: (1) the selection - as per the `defaultSelectedItems`, (2) an object containing the "columnData" - the full render information for all visible columns |
38
38
|`buildArrayProperties`| Function: accepting a `JsonSchema` instance representing an array's declared type of items and returning an object listing the available properties to offer with either `JsonSchema` or raw JSON Schemas as values. The default, providing access to the array's items, is: `arrayItemSchema => ({ "[0]": arrayItemSchema })`|
39
39
|`parserConfig`| Object: enabling the inclusion/exclusion of optional parts of a JSON Schema – both for the inclusion of properties and their attributes as well as in the search. |
40
-
|`parserConfig.anyOf`| Object: enabling the inclusion/exclusion of JSON Schema parts wrapped in `anyOf`. |
41
-
|`parserConfig.anyOf.type`| String: can be `"likeAllOf"` or `"asAdditionalColumn"` (the latter being the default if no `parserConfig` is provided). |
42
-
|`parserConfig.anyOf.groupTitle`| String: alternative title to show in option selection column (only relevant if `type: "asAdditionalColumn"`) – defaults to `"any of"`|
43
-
|`parserConfig.anyOf.optionNameForIndex`| Function: providing the name/label to show for a single option (only relevant if `type: "asAdditionalColumn"`) – defaults to ``(optionIndexes) => `Option ${optionIndexes.map(index => index + 1).join("-")}` ``, resulting in e.g. "Option 1", "Option 2-1", "Option 3" |
44
-
|`parserConfig.oneOf`| Object: enabling the inclusion/exclusion of JSON Schema parts wrapped in `oneOf`. |
45
-
|`parserConfig.oneOf.type`| String: can be `"likeAllOf"` or `"asAdditionalColumn"` (the latter being the default if no `parserConfig` is provided). |
46
-
|`parserConfig.oneOf.groupTitle`| String: alternative title to show in option selection column (only relevant if `type: "asAdditionalColumn"`) – defaults to `"one of"`|
47
-
|`parserConfig.oneOf.optionNameForIndex`| Function: providing the name/label to show for a single option (only relevant if `type: "asAdditionalColumn"`) – defaults to ``(optionIndexes) => `Option ${optionIndexes.map(index => index + 1).join("-")}` ``, resulting in e.g. "Option 1", "Option 2-1", "Option 3" |
40
+
|`parserConfig.anyOf`| Object: specifying details of the inclusion of JSON Schema parts wrapped in `anyOf`. |
41
+
|`parserConfig.anyOf.groupTitle`| String: alternative title to show in option selection column – defaults to `"any of"`|
42
+
|`parserConfig.anyOf.optionNameForIndex`| Function: providing the name/label to show for a single option – defaults to ``(optionIndexes) => `Option ${optionIndexes.map(index => index + 1).join("-")}` ``, resulting in e.g. "Option 1", "Option 2-1", "Option 3" |
43
+
|`parserConfig.oneOf`| Object: specifying details of the inclusion of JSON Schema parts wrapped in `oneOf`. |
44
+
|`parserConfig.oneOf.groupTitle`| String: alternative title to show in option selection column – defaults to `"one of"`|
45
+
|`parserConfig.oneOf.optionNameForIndex`| Function: providing the name/label to show for a single option – defaults to ``(optionIndexes) => `Option ${optionIndexes.map(index => index + 1).join("-")}` ``, resulting in e.g. "Option 1", "Option 2-1", "Option 3" |
48
46
|`breadcrumbs`| Object: enabling the definition of options for the breadcrumbs feature in the footer (can be disabled by setting to `null`) |
49
47
|`breadcrumbs.prefix`| String: to be shown in front of the root selection (e.g. "//" or "./") – defaults to `""`|
50
48
|`breadcrumbs.separator`| String: to be shown in front of any non-root selection (e.g. "/") – defaults to `"."`|
51
49
|`breadcrumbs.skipSeparator`| Function: expecting a `JsonSchema` as input and should return an object containing `JsonSchema` or raw JSON Schemas as values – defaults to excluding `"[0]"`|
52
-
|`breadcrumbs.mutateName`| Function: expecting two inputs: (1) the selected item's name, (2) the full information for the respective column and (3) the index of the respective column; a column's breadcrumb can be skipped by returning `null`|
50
+
|`breadcrumbs.mutateName`| Function: expecting the following inputs: (1) the selected item's name, (2) the full information for the respective column and (3) the index of the respective column; a column's breadcrumb can be skipped by returning `null`|
53
51
|`breadcrumbs.preventNavigation`| Boolean: set to `true` in order to turn-off the default behaviour of discarding any following selections when double-clicking on a breadcrumbs item |
54
52
|`searchOptions`| Object: enabling the definition of options for the search/filter feature in the header (is disabled by default) – either `searchOptions.fields` or `searchOptions.filterBy` needs to be specified to enable it. the component itself will take care of looking-up sub-schemas (e.g. in `properties`) and also respects `$ref`-erences and has no problem with circular references. |
55
53
|`searchOptions.fields`| Array of strings: each referring to the name of a text field in a JSON Schema (e.g. `["title", "description"]`) in which to search/filter – this applies a case-insensitive contains() check on each of the given fields |
@@ -58,9 +56,26 @@ npm i react-jsonschema-inspector
58
56
|`searchOptions.debounceWait`| Number indicating the delay in milliseconds between the last change to the search term being entered and it actually being applied. This defaults to `200` but may be increased when used with exceptionally large schemas and you experience performance issues. Please refer to the documentation on [`lodash.debounce`](https://lodash.com/docs/4.17.11#debounce). |
59
57
|`searchOptions.debounceMaxWait`| Number indicating the maximum delay in milliseconds after the search term was changed. This defaults to `500`. Please refer to the documentation on [`lodash.debounce`](https://lodash.com/docs/4.17.11#debounce). |
60
58
|`renderItemContent`| Function: custom render function for name of single property/sub-schema in a column. Receives one parameter: object with the following properties: "name", "hasNestedItems", "selected", "schemaGroup" |
61
-
|`renderSelectionDetails`| Function: custom render function for the "Details" block on the right for the single property/sub-schema being selected. Receives one parameter: object with the following properties: "itemSchemaGroup", "columnData", "selectionColumnIndex" |
59
+
|`renderSelectionDetails`| Function: custom render function for the "Details" block on the right for the single property/sub-schema being selected. Receives one parameter: object with the following properties: "itemSchemaGroup", "columnData", "selectionColumnIndex", "optionIndexes"|
62
60
| `renderEmptyDetails` | Function: custom render function for the "Details" block on the right if nothing is selected yet. Receives one parameter, which is an object with the "rootColumnSchemas" property, which holds the array of top-level schemas (as derived from the `schemas` prop and augmented by any given `referenceSchemas`)
63
61
62
+
### Additional Helper Functions
63
+
64
+
Besides the main `<Inspector>` component, there are additional named helper functions being provided in the scope of this library:
65
+
-`getFieldValueArrayFromSchemaGroup()` – listing all values of the targeted field in an array (skipping `undefined` and `null` values)
66
+
-`getCommonFieldValuesFromSchemaGroup()` – listing only those values of the targeted field in an array that are included in all occurrences of the field not being `undefined` or `null`
67
+
-`getMinimumFieldValueFromSchemaGroup()` – expecting numeric values in the targeted field and returning the single lowest value (ignoring `undefined` and `null` values)
68
+
-`getMaximumFieldValueFromSchemaGroup()` – expecting numeric values in the targeted field and returning the single highest value (ignoring `undefined` and `null` values)
69
+
70
+
All four of these are intended to be used within props enabling the customisation of an `<Inspector>` instance, e.g. in `onSelect`, `buildArrayProperties`, `breadcrumbs.mutateName`, `renderItemContent`, `renderSelectionDetails`, `renderEmptyDetails`.
71
+
All four helper functions expect the same input parameters:
72
+
1.`schemaGroup` – a group object representing a single schema with all its parts, as provided to the various call-back functions mentioned above
73
+
2.`fieldName` – textual name of the targeted field in the schema (group), e.g. `"title"`, `"maximum"`, `"minLength"`
74
+
3.`defaultValue` – value to return if there is no value for the targeted field; or as initial/base value for the `Array.reduce()` being performed for the encountered values
75
+
4.`optionIndexes` – only provided if the `schemaGroup` contains optional parts (i.e. `anyOf`/`oneOf`); used to identify the particular optional path within the `anyOf`/`oneOf` part(s) – this is also provided in one way or another in those call-back functions listed above
76
+
77
+
As output, the respective helper functions either return a single value or – in case of multiple values – an array.
78
+
64
79
65
80
## Compatibility
66
81
@@ -83,8 +98,8 @@ It is also backwards-compatible with Drafts 4 and 6.
83
98
|`items`| Partially | used to look-up `properties` of single kind of items in an array; however if `items` is an array of multiple sub-schemas they are being *ignored*|
84
99
|`additionalItems`| Yes | used to look-up `properties` of kind of items in an array if `items` is not present or defined as an array (which is not supported itself), otherwise `additionalItems` are being *ignored*|
85
100
|`allOf`| Yes | used to combine sub-schemas transparently |
86
-
|`anyOf`| Yes | used to combine sub-schemas (transparently via `parserConfig.anyOf.type === "likeAllOf"` or explicitly via `parserConfig.anyOf.type === "asAdditionalColumn"`) |
87
-
|`oneOf`| Yes | used to combine sub-schemas (transparently via `parserConfig.oneOf.type === "likeAllOf"` or explicitly via `parserConfig.oneOf.type === "asAdditionalColumn"`) |
0 commit comments