diff --git a/library/src/components/Schema.tsx b/library/src/components/Schema.tsx index 1994c5af9..51aec67d1 100644 --- a/library/src/components/Schema.tsx +++ b/library/src/components/Schema.tsx @@ -309,7 +309,12 @@ export const Schema: React.FunctionComponent = ({ ))} {schema.anyOf() && @@ -319,7 +324,12 @@ export const Schema: React.FunctionComponent = ({ ))} {schema.allOf() && @@ -329,7 +339,12 @@ export const Schema: React.FunctionComponent = ({ ))} {schema.not() && ( diff --git a/library/src/helpers/schema.ts b/library/src/helpers/schema.ts index d85dc763a..bdc778a1c 100644 --- a/library/src/helpers/schema.ts +++ b/library/src/helpers/schema.ts @@ -97,6 +97,20 @@ export class SchemaHelpers { return type; } + static applicatorSchemaName( + idx: number, + firstCase: string, + otherCases: string, + title?: string, + ) { + const suffix = (title != null && ` ${title}:`) || `:`; + if (idx === 0) { + return `${firstCase}${suffix}`; + } else { + return `${otherCases}${suffix}`; + } + } + static prettifyValue(value: any, strict = true): string { const typeOf = typeof value; if (typeOf === 'string') { diff --git a/playground/src/specs/streetlights.ts b/playground/src/specs/streetlights.ts index bc371e5e2..519aa26d2 100644 --- a/playground/src/specs/streetlights.ts +++ b/playground/src/specs/streetlights.ts @@ -400,6 +400,7 @@ components: union: type: [string, number] objectWithKey: + title: objectWithKey type: object propertyNames: format: email