Skip to content

Commit 854d436

Browse files
Marcell TothP0lip
andauthored
feat: oneOf/anyOf as a dropdown, attempt no 2 (#110)
* 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 <jakub@stoplight.io> * test: update * test: update Co-authored-by: Jakub Rożek <jakub@stoplight.io>
1 parent a35724b commit 854d436

File tree

15 files changed

+2340
-2593
lines changed

15 files changed

+2340
-2593
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"type": "array",
3+
"items": {
4+
"oneOf": [
5+
{
6+
"type": "object",
7+
"title": "A",
8+
"properties": {
9+
"foo": {
10+
"type": "string",
11+
"enum": [
12+
"test"
13+
]
14+
}
15+
}
16+
},
17+
{
18+
"type": "object",
19+
"title": "B",
20+
"properties": {
21+
"foo": {
22+
"type": "number"
23+
},
24+
"bar": {
25+
"type": "string"
26+
}
27+
}
28+
}
29+
]
30+
}
31+
}

src/__stories__/JsonSchemaViewer.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const refSchema = require('../__fixtures__/references/base.json');
1515
const nullRefSchema = require('../__fixtures__/references/nullish.json');
1616
const brokenRefArraySchema = require('../__fixtures__/arrays/of-refs.json');
1717
const oneOfWithArraySchema = require('../__fixtures__/combiners/oneof-with-array-type.json');
18+
const oneOfWithArraySchema2 = require('../__fixtures__/combiners/oneof-within-array-item.json');
1819

1920
subscribeTheme({ mode: 'light' });
2021

@@ -83,6 +84,13 @@ storiesOf('JsonSchemaViewer', module)
8384
onGoToRef={action('onGoToRef')}
8485
/>
8586
))
87+
.add('anyOf-array-schema2', () => (
88+
<JsonSchemaViewer
89+
schema={oneOfWithArraySchema2 as JSONSchema4}
90+
defaultExpandedDepth={number('defaultExpandedDepth', 2)}
91+
onGoToRef={action('onGoToRef')}
92+
/>
93+
))
8694
.add('error boundary', () => (
8795
<JsonSchemaViewer
8896
// @ts-ignore

0 commit comments

Comments
 (0)