mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-24 09:33:44 +03:00
Merge branch 'master' into releases
This commit is contained in:
commit
d211aaec6b
|
@ -11,7 +11,7 @@
|
|||
<table *ngIf="!schema.isTrivial" class="params-wrap" [ngClass]="{'params-array': schema._isArray}">
|
||||
<!-- <caption> {{_displayType}} </caption> -->
|
||||
<template ngFor [ngForOf]="schema.properties" #prop="$implicit" #last="last">
|
||||
<tr class="param" [ngClass]="{'last': last, 'discriminator': prop.isDiscriminator, 'complex': prop._pointer}">
|
||||
<tr class="param" [ngClass]="{'last': last, 'discriminator': prop.isDiscriminator && !derivedEmtpy, 'complex': prop._pointer}">
|
||||
<td class="param-name">
|
||||
<span class="param-name-content">{{prop._name}}</span>
|
||||
</td>
|
||||
|
@ -28,7 +28,7 @@
|
|||
</div>
|
||||
<div class="param-description" innerHtml="{{prop.description | marked}}"></div>
|
||||
<div class="discriminator-info" *ngIf="prop.isDiscriminator">
|
||||
This field value determines the exact schema:
|
||||
<span>This field value determines the exact schema:</span>
|
||||
<ul>
|
||||
<li *ngFor="#derived of schema.derived"
|
||||
(click)="selectDerived(derived)" [ngClass]="{active: derived.active}"> {{derived.name}} </li>
|
||||
|
@ -44,10 +44,10 @@
|
|||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
<tr *ngIf="schema.derived.length" class="param-wrap discriminator-wrap">
|
||||
<tr *ngIf="schema.derived.length" class="param-wrap discriminator-wrap" [ngClass]="{'empty': derivedEmtpy}">
|
||||
<td colspan="2">
|
||||
<div class="derived-schema" *ngFor="#derived of schema.derived" [ngClass]="{active: derived.active}">
|
||||
<json-schema pointer="{{derived.$ref}}" [final]="derived.final" class="discriminator-part">
|
||||
<json-schema *ngIf="!derived.empty" [childFor]="pointer" pointer="{{derived.$ref}}" [final]="derived.final" class="discriminator-part">
|
||||
</json-schema>
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
@ -11,7 +11,7 @@ import JsonPointer from '../../utils/JsonPointer';
|
|||
templateUrl: './lib/components/JsonSchema/json-schema.html',
|
||||
styleUrls: ['./lib/components/JsonSchema/json-schema.css'],
|
||||
directives: [JsonSchema, Tabs, Tab],
|
||||
inputs: ['isArray', 'final', 'nestOdd']
|
||||
inputs: ['isArray', 'final', 'nestOdd', 'childFor']
|
||||
})
|
||||
@Reflect.metadata('parameters', [[SchemaManager], [ElementRef]])
|
||||
export default class JsonSchema extends BaseComponent {
|
||||
|
@ -27,6 +27,8 @@ export default class JsonSchema extends BaseComponent {
|
|||
subSchema.active = false;
|
||||
});
|
||||
subClass.active = true;
|
||||
this.derivedEmtpy = false;
|
||||
if (subClass.empty) this.derivedEmtpy = true;
|
||||
}
|
||||
|
||||
unwrapArray(schema) {
|
||||
|
@ -54,13 +56,13 @@ export default class JsonSchema extends BaseComponent {
|
|||
runInjectors(schema, schema, schema._pointer || this.pointer);
|
||||
|
||||
schema.derived = schema.derived || [];
|
||||
if (schema.derived.length) schema.derived[0].active = true;
|
||||
|
||||
if (!schema.isTrivial) {
|
||||
this.prepareObjectPropertiesData(schema);
|
||||
}
|
||||
|
||||
this.schema = schema;
|
||||
if (schema.derived.length) this.selectDerived(schema.derived[0]);
|
||||
}
|
||||
|
||||
prepareObjectPropertiesData(schema) {
|
||||
|
@ -74,9 +76,16 @@ export default class JsonSchema extends BaseComponent {
|
|||
let propertySchema = schema.properties[prop];
|
||||
let propPointer = JsonPointer.join(schema._pointer || this.pointer, ['properties', prop]);
|
||||
propertySchema = JsonSchema.injectPropertyData(propertySchema, prop, propPointer);
|
||||
// stop endless discriminator recursion
|
||||
if (propertySchema._pointer === this.childFor) {
|
||||
propertySchema._pointer = null;
|
||||
}
|
||||
propertySchema.required = !!requiredMap[prop];
|
||||
propertySchema.isDiscriminator = (schema.discriminator === prop);
|
||||
if (propertySchema.isDiscriminator) discriminatorFieldIdx = idx;
|
||||
if (propertySchema.isDiscriminator) {
|
||||
discriminatorFieldIdx = idx;
|
||||
propertySchema.enum = null;
|
||||
}
|
||||
return propertySchema;
|
||||
});
|
||||
// Move discriminator field to the end of properties list
|
||||
|
|
|
@ -61,6 +61,12 @@ json-schema[nesteven="true"] {
|
|||
> .params-wrap > .param:first-of-type > .param-name:before, > .params-wrap > .param:last-of-type > .param-name:after {
|
||||
border-color: $side-menu-active-bg-color;
|
||||
}
|
||||
|
||||
> .params-wrap > .param:last-of-type, > .params-wrap > .param.last {
|
||||
> .param-name:after {
|
||||
border-color: $side-menu-active-bg-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.param.complex > .param-info {
|
||||
|
@ -128,9 +134,14 @@ json-schema[nesteven="true"] {
|
|||
.discriminator-info {
|
||||
font-weight: $regular;
|
||||
margin-bottom: 10px;
|
||||
|
||||
> span {
|
||||
font-size: 0.9em;
|
||||
font-weight: $light;
|
||||
}
|
||||
}
|
||||
|
||||
.discriminator-wrap > td {
|
||||
.discriminator-wrap:not(.empty) > td {
|
||||
//border-left: $line-border;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
|
|
|
@ -179,7 +179,11 @@ export default class SchemaManager {
|
|||
});
|
||||
if (idx < 0) continue;
|
||||
|
||||
res.push({name: defName, $ref: `#/definitions/${defName}`});
|
||||
let empty = false;
|
||||
if (subTypes.length === 1) {
|
||||
empty = true;
|
||||
}
|
||||
res.push({name: defName, $ref: `#/definitions/${defName}`, empty});
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "redoc",
|
||||
"description": "Swagger-generated API Reference Documentation",
|
||||
"version": "0.7.11",
|
||||
"version": "0.7.12",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/Rebilly/ReDoc"
|
||||
|
@ -15,7 +15,8 @@
|
|||
"branch-release": "git reset --hard && branch-release",
|
||||
"unit": "gulp test",
|
||||
"e2e": "gulp e2e",
|
||||
"deploy": "build/prepare_deploy.sh && deploy-to-gh-pages demo"
|
||||
"deploy": "build/prepare_deploy.sh && deploy-to-gh-pages demo",
|
||||
"github-release": "gulp github-release"
|
||||
},
|
||||
"keywords": [
|
||||
"OpenAPI",
|
||||
|
|
|
@ -238,7 +238,7 @@ describe('Utils', () => {
|
|||
let deriveDefs = schemaMgr.findDerivedDefinitions('#/definitions/Pet');
|
||||
deriveDefs.should.be.instanceof(Array);
|
||||
deriveDefs.should.not.be.empty();
|
||||
deriveDefs.should.be.deepEqual([{name: 'Cat', $ref: '#/definitions/Cat'}, {name: 'Dog', $ref: '#/definitions/Dog'}]);
|
||||
deriveDefs.should.be.deepEqual([{name: 'Cat', empty: false, $ref: '#/definitions/Cat'}, {name: 'Dog', empty: false, $ref: '#/definitions/Dog'}]);
|
||||
});
|
||||
|
||||
it('should return emtpy array for definitions that dont have discriminator', () => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user