fix: Use item's title in array definition (#526)

This commit is contained in:
Jérémy Derussé 2018-06-21 12:10:10 +02:00 committed by Roman Hotsiy
parent 52adc9378e
commit 4694b6f9ca
2 changed files with 5 additions and 1 deletions

View File

@ -28,7 +28,7 @@ export class FieldDetails extends React.PureComponent<FieldProps> {
<div> <div>
<TypePrefix>{schema.typePrefix}</TypePrefix> <TypePrefix>{schema.typePrefix}</TypePrefix>
<TypeName>{schema.displayType}</TypeName> <TypeName>{schema.displayType}</TypeName>
{schema.format && <TypeFormat> &lt;{schema.format}&gt; </TypeFormat>} {schema.displayFormat && <TypeFormat> &lt;{schema.displayFormat}&gt; </TypeFormat>}
{schema.title && <TypeTitle> ({schema.title}) </TypeTitle>} {schema.title && <TypeTitle> ({schema.title}) </TypeTitle>}
<ConstraintsView constraints={schema.constraints} /> <ConstraintsView constraints={schema.constraints} />
{schema.nullable && <NullableLabel> Nullable </NullableLabel>} {schema.nullable && <NullableLabel> Nullable </NullableLabel>}

View File

@ -30,6 +30,7 @@ export class SchemaModel {
isCircular: boolean = false; isCircular: boolean = false;
format?: string; format?: string;
displayFormat?: string;
nullable: boolean; nullable: boolean;
deprecated: boolean; deprecated: boolean;
pattern?: string; pattern?: string;
@ -102,6 +103,7 @@ export class SchemaModel {
this.constraints = humanizeConstraints(schema); this.constraints = humanizeConstraints(schema);
this.displayType = this.type; this.displayType = this.type;
this.displayFormat = this.format;
this.isPrimitive = isPrimitiveType(schema); this.isPrimitive = isPrimitiveType(schema);
this.default = schema.default; this.default = schema.default;
this.readOnly = !!schema.readOnly; this.readOnly = !!schema.readOnly;
@ -138,7 +140,9 @@ export class SchemaModel {
} else if (this.type === 'array' && schema.items) { } else if (this.type === 'array' && schema.items) {
this.items = new SchemaModel(parser, schema.items, this._$ref + '/items', this.options); this.items = new SchemaModel(parser, schema.items, this._$ref + '/items', this.options);
this.displayType = this.items.displayType; this.displayType = this.items.displayType;
this.displayFormat = this.items.format;
this.typePrefix = this.items.typePrefix + 'Array of '; this.typePrefix = this.items.typePrefix + 'Array of ';
this.title = this.title || this.items.title;
this.isPrimitive = this.items.isPrimitive; this.isPrimitive = this.items.isPrimitive;
if (this.example === undefined && this.items.example !== undefined) { if (this.example === undefined && this.items.example !== undefined) {
this.example = [this.items.example]; this.example = [this.items.example];