mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-11 03:16:48 +03:00
Display simple schema + update format display
This commit is contained in:
parent
f44ded1e86
commit
2eabd2b333
|
@ -1,5 +1,6 @@
|
|||
<small *ng-if="errorMessage">{{errorMessage}}</small>
|
||||
<div class="params-wrap" [ng-class]="{'params-array': isArray}">
|
||||
<span *ng-if="isTrivial" class="param-type param-type-trivial" [ng-class]="type">{{_displayType}}</span>
|
||||
<div *ng-if="!isTrivial" class="params-wrap" [ng-class]="{'params-array': isArray}">
|
||||
<div *ng-for="#prop of data.properties" class="param-wrap">
|
||||
<div class="param">
|
||||
<div class="param-name">
|
||||
|
@ -7,7 +8,7 @@
|
|||
</div>
|
||||
<div class="param-info">
|
||||
<div>
|
||||
<span class="param-type" [ng-class]="prop.type">{{prop._displayType}} {{prop.format}}</span>
|
||||
<span class="param-type" [ng-class]="prop.type">{{prop._displayType}} {{prop._displayFormat}}</span>
|
||||
<span *ng-if="prop.isRequired" class="param-required">Required</span>
|
||||
</div>
|
||||
<div class="param-description" inner-html="{{prop.description | marked}}"></div>
|
||||
|
|
|
@ -37,9 +37,9 @@ export default class JsonSchema extends BaseComponent {
|
|||
this.joinAllOf(schema);
|
||||
|
||||
if (schema.type !== 'object') {
|
||||
// TODO
|
||||
this.errorMessage = 'Non-object and non-array schemas are not implemented yet';
|
||||
console.warn(`${this.errorMessage}: ${schema.type}`);
|
||||
this.isTrivial = true;
|
||||
this._displayType = schema.type;
|
||||
if (schema.format) this._displayType = `${this.displayType} <${schema.format}>`;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,11 @@ export default class JsonSchema extends BaseComponent {
|
|||
this.schema.required.forEach(prop => this.requiredMap[prop] = true);
|
||||
}
|
||||
|
||||
if (!schema.properties) return;
|
||||
if (!schema.properties) {
|
||||
this.isTrivial = true;
|
||||
this._displayType = `${schema.type} (Custom key-value pairs)`;
|
||||
return;
|
||||
}
|
||||
let props = Object.keys(schema.properties).map(prop => {
|
||||
let propData = schema.properties[prop];
|
||||
this.injectPropData(prop, propData);
|
||||
|
@ -76,17 +80,21 @@ export default class JsonSchema extends BaseComponent {
|
|||
propData._displayType = propData.type;
|
||||
if (propData.type === 'array') {
|
||||
let itemType = propData.items.type;
|
||||
let itemFormat = propData.items.format;
|
||||
if (itemType === 'object') {
|
||||
itemType = propData.items.title || 'object';
|
||||
propData._pointer = propData.items._pointer || this.pointer + '/properties/' + prop + '/items';
|
||||
}
|
||||
propData._displayType= `array of ${itemType}`;
|
||||
propData._displayType = `array of ${itemType}`;
|
||||
propData.format = itemFormat;
|
||||
propData._isArray = true;
|
||||
}
|
||||
|
||||
if (propData.type === 'object') {
|
||||
propData._displayType = propData.title || 'object';
|
||||
}
|
||||
|
||||
if (propData.format) propData._displayFormat = `<${propData.format}>`;
|
||||
}
|
||||
|
||||
init() {
|
||||
|
|
|
@ -72,6 +72,11 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin;
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
.param-type-trivial {
|
||||
margin: 10px 10px 0;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* tree */
|
||||
|
||||
// Bullet
|
||||
|
|
Loading…
Reference in New Issue
Block a user