From 4694b6f9ca2126f507dd4026ecfd6575c0c75640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Thu, 21 Jun 2018 12:10:10 +0200 Subject: [PATCH] fix: Use item's title in array definition (#526) --- src/components/Fields/FieldDetails.tsx | 2 +- src/services/models/Schema.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Fields/FieldDetails.tsx b/src/components/Fields/FieldDetails.tsx index 91201bef..87aebdac 100644 --- a/src/components/Fields/FieldDetails.tsx +++ b/src/components/Fields/FieldDetails.tsx @@ -28,7 +28,7 @@ export class FieldDetails extends React.PureComponent {
{schema.typePrefix} {schema.displayType} - {schema.format && <{schema.format}> } + {schema.displayFormat && <{schema.displayFormat}> } {schema.title && ({schema.title}) } {schema.nullable && Nullable } diff --git a/src/services/models/Schema.ts b/src/services/models/Schema.ts index fda95339..c1a93475 100644 --- a/src/services/models/Schema.ts +++ b/src/services/models/Schema.ts @@ -30,6 +30,7 @@ export class SchemaModel { isCircular: boolean = false; format?: string; + displayFormat?: string; nullable: boolean; deprecated: boolean; pattern?: string; @@ -102,6 +103,7 @@ export class SchemaModel { this.constraints = humanizeConstraints(schema); this.displayType = this.type; + this.displayFormat = this.format; this.isPrimitive = isPrimitiveType(schema); this.default = schema.default; this.readOnly = !!schema.readOnly; @@ -138,7 +140,9 @@ export class SchemaModel { } else if (this.type === 'array' && schema.items) { this.items = new SchemaModel(parser, schema.items, this._$ref + '/items', this.options); this.displayType = this.items.displayType; + this.displayFormat = this.items.format; this.typePrefix = this.items.typePrefix + 'Array of '; + this.title = this.title || this.items.title; this.isPrimitive = this.items.isPrimitive; if (this.example === undefined && this.items.example !== undefined) { this.example = [this.items.example];