Handle parameter types without type (fixes #8)

This commit is contained in:
Roman Hotsiy 2016-01-23 16:01:10 +02:00
parent 38f642dbb8
commit 6ebca9d46c
3 changed files with 24 additions and 4 deletions

View File

@ -1,4 +1,7 @@
<span *ngIf="isTrivial" class="param-type param-type-trivial" [ngClass]="type">{{_displayType}}</span> <span *ngIf="isTrivial" class="param-wrap">
<span class="param-type param-type-trivial {{type}}"
[ngClass]="{'with-hint': _displayTypeHint}" title="{{_displayTypeHint}}">{{_displayType}}</span>
</span>
<div *ngIf="!isTrivial" class="params-wrap" [ngClass]="{'params-array': isArray}"> <div *ngIf="!isTrivial" class="params-wrap" [ngClass]="{'params-array': isArray}">
<div *ngFor="#prop of data.properties" class="param-wrap"> <div *ngFor="#prop of data.properties" class="param-wrap">
<div class="param" [ngClass]="{'discriminator': prop.isDiscriminator}"> <div class="param" [ngClass]="{'discriminator': prop.isDiscriminator}">
@ -7,7 +10,8 @@
</div> </div>
<div class="param-info"> <div class="param-info">
<div> <div>
<span class="param-type" [ngClass]="prop.type">{{prop._displayType}} {{prop._displayFormat}}</span> <span class="param-type {{prop.type}}" [ngClass]="{'with-hint': prop._displayTypeHint}"
title="{{prop._displayTypeHint}}"> {{prop._displayType}} {{prop._displayFormat}}</span>
<span *ngIf="prop.isRequired" class="param-required">Required</span> <span *ngIf="prop.isRequired" class="param-required">Required</span>
</div> </div>
<div class="param-description" innerHtml="{{prop.description | marked}}"></div> <div class="param-description" innerHtml="{{prop.description | marked}}"></div>

View File

@ -63,7 +63,8 @@ export default class JsonSchema extends BaseComponent {
if (!schema.properties) { if (!schema.properties) {
this.isTrivial = true; this.isTrivial = true;
this._displayType = `${schema.type} (Custom key-value pairs)`; this._displayType = schema.type;
this._displayTypeHint = 'This field may contain data of any type';
return; return;
} }
@ -117,6 +118,11 @@ export default class JsonSchema extends BaseComponent {
propData._displayType = propData.title || 'object'; propData._displayType = propData.title || 'object';
} }
if (!propData.type) {
propData._displayType = '< * >';
propData._displayTypeHint = 'This field may contain data of any type';
}
if (propData.format) propData._displayFormat = `<${propData.format}>`; if (propData.format) propData._displayFormat = `<${propData.format}>`;
} }

View File

@ -60,7 +60,6 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin;
} }
.param-type { .param-type {
text-transform: capitalize;
color: #999; color: #999;
font-size: 12px; font-size: 12px;
line-height: $param-name-height; line-height: $param-name-height;
@ -68,6 +67,17 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin;
font-weight: bold; font-weight: bold;
} }
.param-type.with-hint {
&:before, &:after {
content: "\\00a0";
}
background-color: rgba(0, 50, 159, 0.1);
padding: 0.2em 0;
font-size: 0.85em;
border-radius: 3px;
cursor: help;
}
.param-type-trivial { .param-type-trivial {
margin: 10px 10px 0; margin: 10px 10px 0;
display: inline-block; display: inline-block;