diff --git a/library/src/components/Schema.tsx b/library/src/components/Schema.tsx index 2a48f764..e677374a 100644 --- a/library/src/components/Schema.tsx +++ b/library/src/components/Schema.tsx @@ -280,7 +280,12 @@ export const Schema: React.FunctionComponent = ({ ))} {schema.anyOf() && @@ -290,7 +295,12 @@ export const Schema: React.FunctionComponent = ({ ))} {schema.allOf() && @@ -300,7 +310,12 @@ export const Schema: React.FunctionComponent = ({ ))} {schema.not() && ( diff --git a/library/src/helpers/schema.ts b/library/src/helpers/schema.ts index efc39f1a..d0f08f7b 100644 --- a/library/src/helpers/schema.ts +++ b/library/src/helpers/schema.ts @@ -101,6 +101,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 bc371e5e..519aa26d 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