mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-05 04:20:33 +03:00
Isolated each component schemas
This commit is contained in:
parent
dce75ccd92
commit
c2e712b039
|
@ -15,6 +15,22 @@ function safeConcat(a, b) {
|
||||||
return res.concat(b);
|
return res.concat(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function snapshot(obj) {
|
||||||
|
if(obj == null || typeof(obj) != 'object') {
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
var temp = new obj.constructor();
|
||||||
|
|
||||||
|
for(var key in obj) {
|
||||||
|
if (obj.hasOwnProperty(key)) {
|
||||||
|
temp[key] = snapshot(obj[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class decorator
|
* Class decorator
|
||||||
* Simplifies setup of component metainfo
|
* Simplifies setup of component metainfo
|
||||||
|
@ -72,7 +88,7 @@ export class BaseComponent {
|
||||||
* onInit method is run by angular2 after all component inputs are resolved
|
* onInit method is run by angular2 after all component inputs are resolved
|
||||||
*/
|
*/
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.componentSchema = this.schemaMgr.byPointer(this.pointer || '');
|
this.componentSchema = snapshot(this.schemaMgr.byPointer(this.pointer || ''));
|
||||||
this.prepareModel();
|
this.prepareModel();
|
||||||
this.init();
|
this.init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ describe('Redoc components', () => {
|
||||||
it('should set componentSchema based on pointer on ngOnInit', () => {
|
it('should set componentSchema based on pointer on ngOnInit', () => {
|
||||||
component.pointer = '/tags';
|
component.pointer = '/tags';
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
component.componentSchema.should.be.equal(schemaMgr._schema.tags);
|
component.componentSchema.should.be.deepEqual(schemaMgr._schema.tags);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call prepareModel and init virtual methods after init', () => {
|
it('should call prepareModel and init virtual methods after init', () => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user