diff --git a/src/__tests__/__snapshots__/index.spec.tsx.snap b/src/__tests__/__snapshots__/index.spec.tsx.snap index 2ff83047..5f1ef5d3 100644 --- a/src/__tests__/__snapshots__/index.spec.tsx.snap +++ b/src/__tests__/__snapshots__/index.spec.tsx.snap @@ -31,7 +31,7 @@ exports[`Expanded depth nested object static given initial level set to 0, shoul
foo
- array of objects + array[object]
@@ -128,7 +128,7 @@ exports[`Expanded depth nested object static given initial level set to 1, shoul
foo
- array of objects + array[object]
@@ -275,7 +275,7 @@ exports[`Expanded depth nested object static given initial level set to 2, shoul
foo
- array of objects + array[object]
@@ -439,7 +439,7 @@ exports[`HTML Output given array with oneOf containing items, should merge it co
- array of strings + array[string]
@@ -466,7 +466,7 @@ exports[`HTML Output given complex type that includes array and complex array su
null or - array of strings/numbers + array[string or number]
@@ -521,7 +521,7 @@ exports[`HTML Output given multiple object and string type, should process prope
ids
- array of integers + array[integer]
@@ -879,7 +879,7 @@ exports[`HTML Output should match arrays/of-allofs.json 1`] = `
array-all-objects
- array of objects + array[object]
@@ -959,7 +959,7 @@ exports[`HTML Output should match arrays/of-arrays.json 1`] = `
foo
- array of arrays + array[array]
@@ -1088,7 +1088,7 @@ exports[`HTML Output should match arrays/of-complex-objects.json 1`] = `
null or - array of strings/numbers + array[string or number]
@@ -1166,7 +1166,7 @@ exports[`HTML Output should match arrays/of-complex-objects.json 1`] = ` @@ -1255,7 +1255,7 @@ exports[`HTML Output should match arrays/of-complex-objects.json 1`] = `
ids
- array of integers + array[integer]
@@ -1355,7 +1355,7 @@ exports[`HTML Output should match arrays/of-objects.json 1`] = `
propertyIsArrayOfObjects
- array of objects + array[object]
@@ -1964,7 +1964,7 @@ exports[`HTML Output should match combiners/allOfs/complex.json 1`] = `
users
- array of objects + array[object]
@@ -2547,7 +2547,7 @@ exports[`HTML Output should match combiners/allOfs/with-type.json 1`] = `
items
- array of strings + array[string]
required
@@ -2572,7 +2572,7 @@ exports[`HTML Output should match combiners/oneof-with-array-type.json 1`] = `
- array of objects + array[object]
@@ -2627,7 +2627,7 @@ exports[`HTML Output should match combiners/oneof-within-array-item.json 1`] = `
- array of A + array[A]
@@ -2769,7 +2769,7 @@ exports[`HTML Output should match default-schema.json 1`] = `
null or - array of strings/numbers + array[string or number]
@@ -2847,7 +2847,7 @@ exports[`HTML Output should match default-schema.json 1`] = `
@@ -2936,7 +2936,7 @@ exports[`HTML Output should match default-schema.json 1`] = `
ids
- array of integers + array[integer]
@@ -3132,7 +3132,7 @@ exports[`HTML Output should match formats-schema.json 1`] = `
ids
- array of integers + array[integer]
@@ -3381,7 +3381,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
commonTicketingOptions
- array of strings + array[string]
@@ -3403,7 +3403,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
ticketingOptionChoice
- array of objects + array[object]
@@ -3459,7 +3459,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
orderItemBreakdown
- array of objects + array[object]
@@ -3497,7 +3497,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
options
- array of objects + array[object]
@@ -3613,7 +3613,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
availableDeliveryTypes
- array of strings + array[string]
@@ -3636,7 +3636,7 @@ exports[`HTML Output should match tickets.schema.json 1`] = `
ticketRecipients
- array of strings + array[string]
diff --git a/src/__tests__/index.spec.tsx b/src/__tests__/index.spec.tsx index dd27f533..2b0851a3 100644 --- a/src/__tests__/index.spec.tsx +++ b/src/__tests__/index.spec.tsx @@ -251,7 +251,7 @@ describe('Expanded depth', () => {
foo
- array of objects + array[object]
@@ -288,7 +288,7 @@ describe('Expanded depth', () => {
foo
- array of objects + array[object]
@@ -325,7 +325,7 @@ describe('Expanded depth', () => {
foo
- array of objects + array[object]
@@ -430,7 +430,7 @@ describe('Expanded depth', () => {
foo
- array of objects + array[object]
@@ -483,7 +483,7 @@ describe('Expanded depth', () => {
foo
- array of objects + array[object]
@@ -536,7 +536,7 @@ describe('Expanded depth', () => {
foo
- array of objects + array[object]
@@ -668,7 +668,7 @@ describe('Expanded depth', () => {
foo
- array of objects + array[object]
diff --git a/src/components/SchemaRow/useChoices.ts b/src/components/SchemaRow/useChoices.ts index f2c31009..12b481c5 100644 --- a/src/components/SchemaRow/useChoices.ts +++ b/src/components/SchemaRow/useChoices.ts @@ -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, diff --git a/src/components/shared/__tests__/Property.spec.tsx b/src/components/shared/__tests__/Property.spec.tsx index cc6ba696..9672a530 100644 --- a/src/components/shared/__tests__/Property.spec.tsx +++ b/src/components/shared/__tests__/Property.spec.tsx @@ -46,7 +46,7 @@ describe('Property component', () => { const wrapper = render(schema); expect(wrapper.find(Types).first().html()).toMatchInlineSnapshot( - `"array of strings"`, + `"array[string]"`, ); }); @@ -102,7 +102,7 @@ describe('Property component', () => { const wrapper = render(schema, ['properties', 'foo']); expect(wrapper.find(SchemaRow).html()).toMatchInlineSnapshot( - `"
foo
array of integers
"`, + `"
foo
array[integer]
"`, ); }); @@ -141,7 +141,7 @@ describe('Property component', () => { const wrapper = render(schema); expect(wrapper.html()).toMatchInlineSnapshot( - `"
"`, + `"
"`, ); }); @@ -164,7 +164,7 @@ describe('Property component', () => { const wrapper = render(schema); expect(wrapper.html()).toMatchInlineSnapshot( - `"
array of objects
foo
bar
baz
"`, + `"
array[object]
foo
bar
baz
"`, ); }); @@ -264,7 +264,7 @@ describe('Property component', () => { const wrapper = render(schema); expect(wrapper.find(Types).first().html()).toMatchInlineSnapshot( - `"array of User"`, + `"array[User]"`, ); }); diff --git a/src/utils/printName.ts b/src/utils/printName.ts index 22c8feeb..401fb5b8 100644 --- a/src/utils/printName.ts +++ b/src/utils/printName.ts @@ -53,19 +53,19 @@ function printArrayName( return mergedTypes; }, []) ?? null; - return val !== null && val.length > 0 ? `array of ${val.join('s/')}s` : 'array'; + return val !== null && val.length > 0 ? `array[${val.join(' or ')}]` : 'array'; } if (isComplexArray(schemaNode)) { const firstChild = schemaNode.children[0]; if (firstChild.title) { - return `array of ${firstChild.title}`; + return `array[${firstChild.title}]`; } else if (shouldUseRefNameFallback && getNodeNameFromOriginalRef(schemaNode)) { - return `array of ${getNodeNameFromOriginalRef(schemaNode)}`; + return `array[${getNodeNameFromOriginalRef(schemaNode)}]`; } else if (firstChild.primaryType) { - return `array of ${firstChild.primaryType}s`; + return `array[${firstChild.primaryType}]`; } else if (firstChild.combiners?.length) { - return `array of ${firstChild.combiners.join('/')}`; + return `array[${firstChild.combiners.join('/')}]`; } return 'array'; }