Skip to content

Commit

Permalink
feat: oneOf/anyOf as a dropdown, attempt no 2 (#110)
Browse files Browse the repository at this point in the history
* feat: add oneOf story

* feat: show oneOf & anyOf as a dropdown

* fix: build error

* feat: use mosaic Select

* docs: add another story

* feat: implement choice selector

* feat: rework SchemaRow header

* fix: alignment issues

* feat: handle array of anyOfs

* feat: change array name formatting

* feat: nice plural names ;)

* feat: update format styling

* chore: apply PR feedback

* chore: address PR feedback

Co-authored-by: Jakub Rożek <[email protected]>

* test: update

* test: update

Co-authored-by: Jakub Rożek <[email protected]>
  • Loading branch information
Marcell Toth and P0lip authored Mar 25, 2021
1 parent a35724b commit 854d436
Show file tree
Hide file tree
Showing 15 changed files with 2,340 additions and 2,593 deletions.
31 changes: 31 additions & 0 deletions src/__fixtures__/combiners/oneof-within-array-item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"type": "array",
"items": {
"oneOf": [
{
"type": "object",
"title": "A",
"properties": {
"foo": {
"type": "string",
"enum": [
"test"
]
}
}
},
{
"type": "object",
"title": "B",
"properties": {
"foo": {
"type": "number"
},
"bar": {
"type": "string"
}
}
}
]
}
}
8 changes: 8 additions & 0 deletions src/__stories__/JsonSchemaViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const refSchema = require('../__fixtures__/references/base.json');
const nullRefSchema = require('../__fixtures__/references/nullish.json');
const brokenRefArraySchema = require('../__fixtures__/arrays/of-refs.json');
const oneOfWithArraySchema = require('../__fixtures__/combiners/oneof-with-array-type.json');
const oneOfWithArraySchema2 = require('../__fixtures__/combiners/oneof-within-array-item.json');

subscribeTheme({ mode: 'light' });

Expand Down Expand Up @@ -83,6 +84,13 @@ storiesOf('JsonSchemaViewer', module)
onGoToRef={action('onGoToRef')}
/>
))
.add('anyOf-array-schema2', () => (
<JsonSchemaViewer
schema={oneOfWithArraySchema2 as JSONSchema4}
defaultExpandedDepth={number('defaultExpandedDepth', 2)}
onGoToRef={action('onGoToRef')}
/>
))
.add('error boundary', () => (
<JsonSchemaViewer
// @ts-ignore
Expand Down
Loading

0 comments on commit 854d436

Please sign in to comment.