mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-29 00:54:09 +03:00
Omit readonly properties in request schemas (part of #42)
This commit is contained in:
parent
900ecaa2cc
commit
4c923682ba
|
@ -14,7 +14,7 @@ var cache = {};
|
|||
|
||||
@Component({
|
||||
selector: 'json-schema-lazy',
|
||||
inputs: ['pointer', 'auto'],
|
||||
inputs: ['pointer', 'auto', 'skipReadOnly'],
|
||||
template: '',
|
||||
directives: [CORE_DIRECTIVES]
|
||||
})
|
||||
|
@ -38,7 +38,7 @@ export default class JsonSchemaLazy {
|
|||
if (this.loaded) return;
|
||||
if (this.pointer) {
|
||||
this.dcl.loadNextToLocation(JsonSchema, this.elementRef).then((compRef) => {
|
||||
compRef.instance.pointer = this.pointer;
|
||||
this.initComponent(compRef);
|
||||
// trigger change detection
|
||||
compRef.hostView.changeDetectorRef.detectChanges();
|
||||
});
|
||||
|
@ -58,7 +58,7 @@ export default class JsonSchemaLazy {
|
|||
// FIXME: get rid of dependency on selector
|
||||
if ($element.querySelector('.discriminator-wrap')) {
|
||||
this.dcl.loadNextToLocation(JsonSchema, this.elementRef).then((compRef) => {
|
||||
compRef.instance.pointer = this.pointer;
|
||||
this.initComponent(compRef);
|
||||
compRef.hostView.changeDetectorRef.markForCheck();
|
||||
});
|
||||
return;
|
||||
|
@ -68,13 +68,18 @@ export default class JsonSchemaLazy {
|
|||
});
|
||||
} else {
|
||||
cache[this.pointer] = this.dcl.loadNextToLocation(JsonSchema, this.elementRef).then((compRef) => {
|
||||
compRef.instance.pointer = this.pointer;
|
||||
this.initComponent(compRef);
|
||||
compRef.hostView.changeDetectorRef.markForCheck();
|
||||
return compRef;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
initComponent(compRef) {
|
||||
compRef.instance.pointer = this.pointer;
|
||||
compRef.instance.skipReadOnly = this.skipReadOnly;
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
if (!this.auto) return;
|
||||
this.loadCached();
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
</tr>
|
||||
<tr class="param-schema" [ngClass]="{'param-array': prop._isArray, 'last': last}" *ngIf="prop._pointer">
|
||||
<td colspan="2">
|
||||
<json-schema pointer="{{prop._pointer}}" [isArray]='prop._isArray'
|
||||
class="nested-schema" [nestOdd]="!nestOdd" [attr.nesteven]="!nestOdd">
|
||||
<json-schema class="nested-schema" pointer="{{prop._pointer}}" [isArray]='prop._isArray'
|
||||
[nestOdd]="!nestOdd" [skipReadOnly]="skipReadOnly" [attr.nesteven]="!nestOdd">
|
||||
</json-schema>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -47,7 +47,8 @@
|
|||
<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 *ngIf="!derived.empty" [childFor]="pointer" pointer="{{derived.$ref}}" [final]="derived.final" class="discriminator-part">
|
||||
<json-schema class="discriminator-part" *ngIf="!derived.empty" [childFor]="pointer"
|
||||
pointer="{{derived.$ref}}" [final]="derived.final" [skipReadOnly]="skipReadOnly">
|
||||
</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, DropDown],
|
||||
inputs: ['isArray', 'final', 'nestOdd', 'childFor']
|
||||
inputs: ['isArray', 'final', 'nestOdd', 'childFor', 'skipReadOnly']
|
||||
})
|
||||
@Reflect.metadata('parameters', [[SchemaManager], [ElementRef]])
|
||||
export default class JsonSchema extends BaseComponent {
|
||||
|
@ -105,6 +105,9 @@ export default class JsonSchema extends BaseComponent {
|
|||
}
|
||||
return propertySchema;
|
||||
});
|
||||
if (this.skipReadOnly) {
|
||||
props = props.filter(prop => !prop.readOnly);
|
||||
}
|
||||
// Move discriminator field to the end of properties list
|
||||
if (discriminatorFieldIdx > -1) {
|
||||
let discrProp = props.splice(discriminatorFieldIdx, 1);
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<div class="body-param-description" innerHtml="{{data.bodyParam.description | marked}}"></div>
|
||||
<div>
|
||||
<br>
|
||||
<json-schema-lazy [auto]="true" pointer="{{data.bodyParam.pointer}}/schema">
|
||||
<json-schema-lazy [skipReadOnly]="true" [auto]="true" pointer="{{data.bodyParam.pointer}}/schema">
|
||||
</json-schema-lazy>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user