Skip to content

Commit

Permalink
feat: change syntax of displaying arrays (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Podlasin authored Aug 27, 2021
1 parent ddc09d8 commit d9a67b4
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 44 deletions.
52 changes: 26 additions & 26 deletions src/__tests__/__snapshots__/index.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exports[`Expanded depth nested object static given initial level set to 0, shoul
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>foo</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -128,7 +128,7 @@ exports[`Expanded depth nested object static given initial level set to 1, shoul
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>foo</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -275,7 +275,7 @@ exports[`Expanded depth nested object static given initial level set to 2, shoul
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>foo</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -439,7 +439,7 @@ exports[`HTML Output given array with oneOf containing items, should merge it co
<div style=\\"margin-left: -25px\\">
<div>
<div aria-label=\\"Pick a type\\" aria-haspopup=\\"true\\" aria-expanded=\\"false\\" id=\\"react-aria-0-2\\">
array of strings
array[string]
<div></div>
</div>
</div>
Expand All @@ -466,7 +466,7 @@ exports[`HTML Output given complex type that includes array and complex array su
<div>
<span>null</span>
<span>or</span>
<span>array of strings/numbers</span>
<span>array[string or number]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -521,7 +521,7 @@ exports[`HTML Output given multiple object and string type, should process prope
<div>
<div>
<div>ids</div>
<span>array of integers</span>
<span>array[integer]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -879,7 +879,7 @@ exports[`HTML Output should match arrays/of-allofs.json 1`] = `
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>array-all-objects</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -959,7 +959,7 @@ exports[`HTML Output should match arrays/of-arrays.json 1`] = `
<div>
<div>
<div>foo</div>
<span>array of arrays</span>
<span>array[array]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -1088,7 +1088,7 @@ exports[`HTML Output should match arrays/of-complex-objects.json 1`] = `
<div>
<span>null</span>
<span>or</span>
<span>array of strings/numbers</span>
<span>array[string or number]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -1166,7 +1166,7 @@ exports[`HTML Output should match arrays/of-complex-objects.json 1`] = `
<select size=\\"2\\">
<option></option>
<option value=\\"0\\">object</option>
<option value=\\"1\\">array of integers</option>
<option value=\\"1\\">array[integer]</option>
</select>
</label>
</div>
Expand Down Expand Up @@ -1255,7 +1255,7 @@ exports[`HTML Output should match arrays/of-complex-objects.json 1`] = `
<div>
<div>
<div>ids</div>
<span>array of integers</span>
<span>array[integer]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -1355,7 +1355,7 @@ exports[`HTML Output should match arrays/of-objects.json 1`] = `
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>propertyIsArrayOfObjects</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -1964,7 +1964,7 @@ exports[`HTML Output should match combiners/allOfs/complex.json 1`] = `
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>users</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -2547,7 +2547,7 @@ exports[`HTML Output should match combiners/allOfs/with-type.json 1`] = `
<div>
<div>
<div>items</div>
<span>array of strings</span>
<span>array[string]</span>
</div>
<span>required</span>
</div>
Expand All @@ -2572,7 +2572,7 @@ exports[`HTML Output should match combiners/oneof-with-array-type.json 1`] = `
<div style=\\"margin-left: -25px\\">
<div>
<div aria-label=\\"Pick a type\\" aria-haspopup=\\"true\\" aria-expanded=\\"false\\" id=\\"react-aria-0-2\\">
array of objects
array[object]
<div></div>
</div>
<div style=\\"padding-left: 25px\\">
Expand Down Expand Up @@ -2627,7 +2627,7 @@ exports[`HTML Output should match combiners/oneof-within-array-item.json 1`] = `
<div style=\\"margin-left: -25px\\">
<div>
<div aria-label=\\"Pick a type\\" aria-haspopup=\\"true\\" aria-expanded=\\"false\\" id=\\"react-aria-0-2\\">
array of A
array[A]
<div></div>
</div>
<div style=\\"padding-left: 25px\\">
Expand Down Expand Up @@ -2769,7 +2769,7 @@ exports[`HTML Output should match default-schema.json 1`] = `
<div>
<span>null</span>
<span>or</span>
<span>array of strings/numbers</span>
<span>array[string or number]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -2847,7 +2847,7 @@ exports[`HTML Output should match default-schema.json 1`] = `
<select size=\\"2\\">
<option></option>
<option value=\\"0\\">object</option>
<option value=\\"1\\">array of integers</option>
<option value=\\"1\\">array[integer]</option>
</select>
</label>
</div>
Expand Down Expand Up @@ -2936,7 +2936,7 @@ exports[`HTML Output should match default-schema.json 1`] = `
<div>
<div>
<div>ids</div>
<span>array of integers</span>
<span>array[integer]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -3132,7 +3132,7 @@ exports[`HTML Output should match formats-schema.json 1`] = `
<div>
<div>
<div>ids</div>
<span>array of integers</span>
<span>array[integer]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -3381,7 +3381,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
<div>
<div>
<div>commonTicketingOptions</div>
<span>array of strings</span>
<span>array[string]</span>
</div>
</div>
<div>
Expand All @@ -3403,7 +3403,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>ticketingOptionChoice</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
<div>
Expand Down Expand Up @@ -3459,7 +3459,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>orderItemBreakdown</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
<div>
Expand Down Expand Up @@ -3497,7 +3497,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>options</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
<div>
Expand Down Expand Up @@ -3613,7 +3613,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
<div>
<div>
<div>availableDeliveryTypes</div>
<span>array of strings</span>
<span>array[string]</span>
</div>
</div>
</div>
Expand All @@ -3636,7 +3636,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
<div>
<div>
<div>ticketRecipients</div>
<span>array of strings</span>
<span>array[string]</span>
</div>
</div>
</div>
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ describe('Expanded depth', () => {
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>foo</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -288,7 +288,7 @@ describe('Expanded depth', () => {
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>foo</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -325,7 +325,7 @@ describe('Expanded depth', () => {
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>foo</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -430,7 +430,7 @@ describe('Expanded depth', () => {
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>foo</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -483,7 +483,7 @@ describe('Expanded depth', () => {
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>foo</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -536,7 +536,7 @@ describe('Expanded depth', () => {
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>foo</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -668,7 +668,7 @@ describe('Expanded depth', () => {
<div style=\\"height: 12px; margin-top: 2px; left: -25px\\" role=\\"button\\"></div>
<div>
<div>foo</div>
<span>array of objects</span>
<span>array[object]</span>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/SchemaRow/useChoices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function makeChoice(node: SchemaNode): Choice {

function makeArrayChoice(node: SchemaNode): Choice {
const itemTitle = calculateChoiceTitle(node, true);
const title = itemTitle !== 'any' ? `array of ${itemTitle}` : 'array';
const title = itemTitle !== 'any' ? `array[${itemTitle}]` : 'array';
return {
type: node,
title,
Expand Down
Loading

0 comments on commit d9a67b4

Please sign in to comment.