mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 18:14:07 +03:00
Migrate to angular rc.5
This commit is contained in:
parent
fc0b6230db
commit
379870a1b3
|
@ -115,7 +115,7 @@ gulp.task('bundle', ['injectVersionFile'], function bundle(done) {
|
||||||
builder
|
builder
|
||||||
.buildStatic(path.join(paths.tmp, paths.sourceEntryPoint),
|
.buildStatic(path.join(paths.tmp, paths.sourceEntryPoint),
|
||||||
outputFileName,
|
outputFileName,
|
||||||
{ format:'umd', sourceMaps: !argv.prod, lowResSourceMaps: true, minify: argv.prod }
|
{ format:'umd', sourceMaps: !argv.prod, lowResSourceMaps: true, minify: argv.prod, globalName: 'Redoc' }
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// wait some time to allow flush
|
// wait some time to allow flush
|
||||||
|
|
|
@ -40,6 +40,8 @@ module.exports = function (config) {
|
||||||
files: [
|
files: [
|
||||||
'node_modules/zone.js/dist/zone.js',
|
'node_modules/zone.js/dist/zone.js',
|
||||||
'node_modules/zone.js/dist/async-test.js',
|
'node_modules/zone.js/dist/async-test.js',
|
||||||
|
'node_modules/zone.js/dist/sync-test.js',
|
||||||
|
'node_modules/zone.js/dist/proxy-zone.js',
|
||||||
'node_modules/zone.js/dist/jasmine-patch.js',
|
'node_modules/zone.js/dist/jasmine-patch.js',
|
||||||
'node_modules/zone.js/dist/long-stack-trace-zone.js',
|
'node_modules/zone.js/dist/long-stack-trace-zone.js',
|
||||||
'node_modules/babel-polyfill/dist/polyfill.js',
|
'node_modules/babel-polyfill/dist/polyfill.js',
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||||
import { SpecManager, RedocComponent, BaseComponent } from '../base';
|
import { SpecManager, BaseComponent } from '../base';
|
||||||
import { OptionsService, MenuService } from '../../services/index';
|
import { OptionsService, MenuService } from '../../services/index';
|
||||||
|
|
||||||
@RedocComponent({
|
@Component({
|
||||||
selector: 'api-info',
|
selector: 'api-info',
|
||||||
styleUrls: ['./api-info.css'],
|
styleUrls: ['./api-info.css'],
|
||||||
templateUrl: './api-info.html'
|
templateUrl: './api-info.html',
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
})
|
})
|
||||||
export class ApiInfo extends BaseComponent {
|
export class ApiInfo extends BaseComponent {
|
||||||
info: any;
|
info: any;
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||||
|
import { BaseComponent, SpecManager } from '../base';
|
||||||
|
|
||||||
import {RedocComponent, BaseComponent, SpecManager} from '../base';
|
@Component({
|
||||||
|
|
||||||
@RedocComponent({
|
|
||||||
selector: 'api-logo',
|
selector: 'api-logo',
|
||||||
styleUrls: ['./api-logo.css'],
|
styleUrls: ['./api-logo.css'],
|
||||||
templateUrl: './api-logo.html'
|
templateUrl: './api-logo.html',
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
})
|
})
|
||||||
export class ApiLogo extends BaseComponent {
|
export class ApiLogo extends BaseComponent {
|
||||||
logo:any = {};
|
logo:any = {};
|
||||||
|
|
|
@ -23,15 +23,11 @@ describe('Redoc components', () => {
|
||||||
fixture = builder.createSync(TestAppComponent);
|
fixture = builder.createSync(TestAppComponent);
|
||||||
let debugEl = getChildDebugElement(fixture.debugElement, 'json-schema-lazy');
|
let debugEl = getChildDebugElement(fixture.debugElement, 'json-schema-lazy');
|
||||||
component = <JsonSchemaLazy>debugEl.componentInstance;
|
component = <JsonSchemaLazy>debugEl.componentInstance;
|
||||||
spyOn(component, '_loadAfterSelf').and.callThrough();
|
spyOn(component, '_loadAfterSelf').and.stub();
|
||||||
spyOn(component.resolver, 'resolveComponent').and.returnValue({ then: () => {
|
|
||||||
return { catch: () => {/**/} };
|
|
||||||
}});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
component._loadAfterSelf.and.callThrough();
|
component._loadAfterSelf.and.callThrough();
|
||||||
component.resolver.resolveComponent.and.callThrough();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should init component', () => {
|
it('should init component', () => {
|
||||||
|
@ -44,14 +40,6 @@ describe('Redoc components', () => {
|
||||||
component.load();
|
component.load();
|
||||||
expect(component._loadAfterSelf).toHaveBeenCalled();
|
expect(component._loadAfterSelf).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not run loadNextToLocation if already loaded', () => {
|
|
||||||
component.pointer = '#/def';
|
|
||||||
fixture.detectChanges();
|
|
||||||
component.load();
|
|
||||||
component.load();
|
|
||||||
expect(component._loadAfterSelf.calls.count()).toEqual(1);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { Component, ElementRef, ViewContainerRef, OnDestroy, Input,
|
import { Component, ElementRef, ViewContainerRef, OnDestroy, Input,
|
||||||
AfterViewInit, ComponentResolver, Renderer } from '@angular/core';
|
AfterViewInit, ComponentFactoryResolver, Renderer } from '@angular/core';
|
||||||
import { CORE_DIRECTIVES } from '@angular/common';
|
|
||||||
|
|
||||||
import { JsonSchema } from './json-schema';
|
import { JsonSchema } from './json-schema';
|
||||||
import { OptionsService } from '../../services/options.service';
|
import { OptionsService } from '../../services/options.service';
|
||||||
|
@ -12,8 +11,8 @@ var cache = {};
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'json-schema-lazy',
|
selector: 'json-schema-lazy',
|
||||||
template: '',
|
entryComponents: [ JsonSchema ],
|
||||||
directives: [CORE_DIRECTIVES]
|
template: ''
|
||||||
})
|
})
|
||||||
export class JsonSchemaLazy implements OnDestroy, AfterViewInit {
|
export class JsonSchemaLazy implements OnDestroy, AfterViewInit {
|
||||||
@Input() pointer: string;
|
@Input() pointer: string;
|
||||||
|
@ -26,7 +25,7 @@ export class JsonSchemaLazy implements OnDestroy, AfterViewInit {
|
||||||
disableLazy: boolean = false;
|
disableLazy: boolean = false;
|
||||||
loaded: boolean = false;
|
loaded: boolean = false;
|
||||||
constructor(private specMgr:SpecManager, private location:ViewContainerRef, private elementRef:ElementRef,
|
constructor(private specMgr:SpecManager, private location:ViewContainerRef, private elementRef:ElementRef,
|
||||||
private resolver:ComponentResolver, private optionsService:OptionsService, private _renderer: Renderer) {
|
private resolver:ComponentFactoryResolver, private optionsService:OptionsService, private _renderer: Renderer) {
|
||||||
this.disableLazy = this.optionsService.options.disableLazySchemas;
|
this.disableLazy = this.optionsService.options.disableLazySchemas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,19 +35,14 @@ export class JsonSchemaLazy implements OnDestroy, AfterViewInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadAfterSelf() {
|
_loadAfterSelf() {
|
||||||
this.loaded = true;
|
var componentFactory = this.resolver.resolveComponentFactory(JsonSchema);
|
||||||
return this.resolver.resolveComponent(JsonSchema).then(componentFactory => {
|
|
||||||
let contextInjector = this.location.parentInjector;
|
let contextInjector = this.location.parentInjector;
|
||||||
let compRef = this.location.createComponent(
|
let compRef = this.location.createComponent(componentFactory, null, contextInjector, null);
|
||||||
componentFactory, null, contextInjector, null);
|
|
||||||
this.initComponent(compRef.instance);
|
this.initComponent(compRef.instance);
|
||||||
this._renderer.setElementAttribute(compRef.location.nativeElement, 'class', this.location.element.nativeElement.className);
|
this._renderer.setElementAttribute(compRef.location.nativeElement, 'class', this.location.element.nativeElement.className);
|
||||||
compRef.changeDetectorRef.detectChanges();
|
compRef.changeDetectorRef.detectChanges();
|
||||||
|
this.loaded = true;
|
||||||
return compRef;
|
return compRef;
|
||||||
}).catch(err => {
|
|
||||||
console.log(err);
|
|
||||||
throw err;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
load() {
|
load() {
|
||||||
|
@ -63,11 +57,11 @@ export class JsonSchemaLazy implements OnDestroy, AfterViewInit {
|
||||||
loadCached() {
|
loadCached() {
|
||||||
this.pointer = this.normalizePointer();
|
this.pointer = this.normalizePointer();
|
||||||
if (cache[this.pointer]) {
|
if (cache[this.pointer]) {
|
||||||
cache[this.pointer].then((compRef) => {
|
let compRef = cache[this.pointer];
|
||||||
setTimeout( ()=> {
|
setTimeout( ()=> {
|
||||||
let $element = compRef.location.nativeElement;
|
let $element = compRef.location.nativeElement;
|
||||||
|
|
||||||
// skip caching view with tabs inside (discriminator)
|
// skip caching view with descendant schemas
|
||||||
// as it needs attached controller
|
// as it needs attached controller
|
||||||
if (!this.disableLazy && (compRef.instance.hasDescendants || compRef.instance._hasSubSchemas)) {
|
if (!this.disableLazy && (compRef.instance.hasDescendants || compRef.instance._hasSubSchemas)) {
|
||||||
this._loadAfterSelf();
|
this._loadAfterSelf();
|
||||||
|
@ -76,7 +70,6 @@ export class JsonSchemaLazy implements OnDestroy, AfterViewInit {
|
||||||
insertAfter($element.cloneNode(true), this.elementRef.nativeElement);
|
insertAfter($element.cloneNode(true), this.elementRef.nativeElement);
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
});
|
});
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
cache[this.pointer] = this._loadAfterSelf();
|
cache[this.pointer] = this._loadAfterSelf();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template ngSwitchCase="array">
|
<template ngSwitchCase="array">
|
||||||
<json-schema class="nested-schema" [pointer]="schema._pointer" [isArray]='true'
|
<json-schema class="nested-schema" [pointer]="schema._pointer"
|
||||||
[nestOdd]="!nestOdd" [isRequestSchema]="isRequestSchema"> </json-schema>
|
[nestOdd]="!nestOdd" [isRequestSchema]="isRequestSchema"> </json-schema>
|
||||||
</template>
|
</template>
|
||||||
<template ngSwitchCase="object">
|
<template ngSwitchCase="object">
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe('Redoc components', () => {
|
||||||
|
|
||||||
it('should init component', () => {
|
it('should init component', () => {
|
||||||
component.pointer = '';
|
component.pointer = '';
|
||||||
(<any>specMgr)._schema = {type: 'object'};
|
(<SpecManager>specMgr)._schema = {type: 'object'};
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(component).not.toBeNull();
|
expect(component).not.toBeNull();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,31 +1,28 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { Input, Renderer, ElementRef, forwardRef } from '@angular/core';
|
import { Component, Input, Renderer, ElementRef } from '@angular/core';
|
||||||
|
|
||||||
import { RedocComponent, BaseComponent, SpecManager } from '../base';
|
import { BaseComponent, SpecManager } from '../base';
|
||||||
import { DropDown } from '../../shared/components/index';
|
|
||||||
import { SchemaNormalizer, SchemaHelper } from '../../services/index';
|
import { SchemaNormalizer, SchemaHelper } from '../../services/index';
|
||||||
import { JsonSchemaLazy } from './json-schema-lazy';
|
|
||||||
import { Zippy } from '../../shared/components/Zippy/zippy';
|
|
||||||
|
|
||||||
@RedocComponent({
|
@Component({
|
||||||
selector: 'json-schema',
|
selector: 'json-schema',
|
||||||
templateUrl: './json-schema.html',
|
templateUrl: './json-schema.html',
|
||||||
styleUrls: ['./json-schema.css'],
|
styleUrls: ['./json-schema.css']
|
||||||
directives: [JsonSchema, DropDown, forwardRef(() => JsonSchemaLazy), Zippy],
|
|
||||||
detect: true
|
|
||||||
})
|
})
|
||||||
export class JsonSchema extends BaseComponent {
|
export class JsonSchema extends BaseComponent {
|
||||||
|
@Input() pointer: string;
|
||||||
|
@Input() final: boolean = false;
|
||||||
|
@Input() nestOdd: boolean;
|
||||||
|
@Input() childFor: string;
|
||||||
|
@Input() isRequestSchema: boolean;
|
||||||
|
|
||||||
schema: any = {};
|
schema: any = {};
|
||||||
activeDescendant:any = {};
|
activeDescendant:any = {};
|
||||||
hasDescendants: boolean = false;
|
hasDescendants: boolean = false;
|
||||||
_hasSubSchemas: boolean = false;
|
_hasSubSchemas: boolean = false;
|
||||||
properties: any;
|
properties: any;
|
||||||
_isArray: boolean;
|
_isArray: boolean;
|
||||||
@Input() final: boolean = false;
|
|
||||||
@Input() nestOdd: boolean;
|
|
||||||
@Input() childFor: string;
|
|
||||||
@Input() isRequestSchema: boolean;
|
|
||||||
normalizer: SchemaNormalizer;
|
normalizer: SchemaNormalizer;
|
||||||
autoExpand = false;
|
autoExpand = false;
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,20 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
import { Input } from '@angular/core';
|
import { Input, Component } from '@angular/core';
|
||||||
import JsonPointer from '../../utils/JsonPointer';
|
import JsonPointer from '../../utils/JsonPointer';
|
||||||
import { RedocComponent, BaseComponent, SpecManager} from '../base';
|
import { BaseComponent, SpecManager } from '../base';
|
||||||
|
|
||||||
import { SelectOnClick } from '../../shared/components/SelectOnClick/select-on-click.directive';
|
|
||||||
|
|
||||||
import { ParamsList } from '../ParamsList/params-list';
|
|
||||||
import { ResponsesList } from '../ResponsesList/responses-list';
|
|
||||||
import { ResponsesSamples } from '../ResponsesSamples/responses-samples';
|
|
||||||
import { SchemaSample } from '../SchemaSample/schema-sample';
|
|
||||||
import { RequestSamples } from '../RequestSamples/request-samples';
|
|
||||||
import { SchemaHelper } from '../../services/schema-helper.service';
|
import { SchemaHelper } from '../../services/schema-helper.service';
|
||||||
|
|
||||||
@RedocComponent({
|
@Component({
|
||||||
selector: 'method',
|
selector: 'method',
|
||||||
templateUrl: './method.html',
|
templateUrl: './method.html',
|
||||||
styleUrls: ['./method.css'],
|
styleUrls: ['./method.css'],
|
||||||
directives: [ ParamsList, ResponsesList, ResponsesSamples, SchemaSample, RequestSamples, SelectOnClick ],
|
|
||||||
detect: true
|
|
||||||
})
|
})
|
||||||
export class Method extends BaseComponent {
|
export class Method extends BaseComponent {
|
||||||
method:any;
|
@Input() pointer:string;
|
||||||
@Input() tag:string;
|
@Input() tag:string;
|
||||||
|
|
||||||
|
method:any;
|
||||||
|
|
||||||
constructor(specMgr:SpecManager) {
|
constructor(specMgr:SpecManager) {
|
||||||
super(specMgr);
|
super(specMgr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,18 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
import { Component, Input } from '@angular/core';
|
||||||
import { forwardRef } from '@angular/core';
|
import { BaseComponent, SpecManager } from '../base';
|
||||||
import { RedocComponent, BaseComponent, SpecManager } from '../base';
|
|
||||||
import { Method } from '../Method/method';
|
|
||||||
import { EncodeURIComponentPipe } from '../../utils/pipes';
|
|
||||||
import { SchemaHelper } from '../../services/index';
|
import { SchemaHelper } from '../../services/index';
|
||||||
|
|
||||||
@RedocComponent({
|
@Component({
|
||||||
selector: 'methods-list',
|
selector: 'methods-list',
|
||||||
templateUrl: './methods-list.html',
|
templateUrl: './methods-list.html',
|
||||||
styleUrls: ['./methods-list.css'],
|
styleUrls: ['./methods-list.css']
|
||||||
directives: [ forwardRef(() => Method) ],
|
|
||||||
pipes: [ EncodeURIComponentPipe ],
|
|
||||||
detect: true
|
|
||||||
})
|
})
|
||||||
export class MethodsList extends BaseComponent {
|
export class MethodsList extends BaseComponent {
|
||||||
|
@Input() pointer:string;
|
||||||
|
|
||||||
tags:Array<any> = [];
|
tags:Array<any> = [];
|
||||||
|
|
||||||
constructor(specMgr:SpecManager) {
|
constructor(specMgr:SpecManager) {
|
||||||
super(specMgr);
|
super(specMgr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
|
||||||
import { RedocComponent, BaseComponent, SpecManager } from '../base';
|
import { BaseComponent, SpecManager } from '../base';
|
||||||
import { JsonSchema } from '../JsonSchema/json-schema';
|
|
||||||
import { JsonSchemaLazy } from '../JsonSchema/json-schema-lazy';
|
|
||||||
import { SchemaHelper } from '../../services/schema-helper.service';
|
import { SchemaHelper } from '../../services/schema-helper.service';
|
||||||
|
|
||||||
function safePush(obj, prop, item) {
|
function safePush(obj, prop, item) {
|
||||||
|
@ -10,13 +8,14 @@ function safePush(obj, prop, item) {
|
||||||
obj[prop].push(item);
|
obj[prop].push(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RedocComponent({
|
@Component({
|
||||||
selector: 'params-list',
|
selector: 'params-list',
|
||||||
templateUrl: './params-list.html',
|
templateUrl: './params-list.html',
|
||||||
styleUrls: ['./params-list.css'],
|
styleUrls: ['./params-list.css'],
|
||||||
directives: [JsonSchema, JsonSchemaLazy]
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
})
|
})
|
||||||
export class ParamsList extends BaseComponent {
|
export class ParamsList extends BaseComponent {
|
||||||
|
@Input() pointer:string;
|
||||||
|
|
||||||
params: Array<any>;
|
params: Array<any>;
|
||||||
empty: boolean;
|
empty: boolean;
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { getChildDebugElement } from '../../../tests/helpers';
|
import { getChildDebugElement } from '../../../tests/helpers';
|
||||||
import { Component, ComponentRef } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
inject,
|
inject,
|
||||||
async
|
async
|
||||||
} from '@angular/core/testing';
|
} from '@angular/core/testing';
|
||||||
|
|
||||||
import { TestComponentBuilder } from '@angular/compiler/testing';
|
import { TestComponentBuilder } from '@angular/core/testing';
|
||||||
|
|
||||||
import { Redoc } from './redoc';
|
import { Redoc } from './redoc';
|
||||||
import { SpecManager } from '../../utils/SpecManager';
|
import { SpecManager } from '../../utils/SpecManager';
|
||||||
|
@ -45,122 +44,122 @@ describe('Redoc components', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Redoc init', () => {
|
// describe('Redoc init', () => {
|
||||||
let dom = new BrowserDomAdapter();
|
// let dom = new BrowserDomAdapter();
|
||||||
let elem;
|
// let elem;
|
||||||
beforeEach(() => {
|
// beforeEach(() => {
|
||||||
elem = dom.createElement('redoc');
|
// elem = dom.createElement('redoc');
|
||||||
dom.defaultDoc().body.appendChild(elem);
|
// dom.defaultDoc().body.appendChild(elem);
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
afterEach(() => {
|
// afterEach(() => {
|
||||||
dom.defaultDoc().body.removeChild(elem);
|
// dom.defaultDoc().body.removeChild(elem);
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
it('should return promise', () => {
|
// it('should return promise', () => {
|
||||||
let res = Redoc.init().catch(() => {/**/});
|
// let res = Redoc.init().catch(() => {/**/});
|
||||||
res.should.be.instanceof(Promise);
|
// res.should.be.instanceof(Promise);
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
it('should hide loading animation and display message in case of error', async(() => {
|
// it('should hide loading animation and display message in case of error', async(() => {
|
||||||
spyOn(Redoc, 'hideLoadingAnimation').and.callThrough();
|
// spyOn(Redoc, 'hideLoadingAnimation').and.callThrough();
|
||||||
spyOn(Redoc, 'displayError').and.callThrough();
|
// spyOn(Redoc, 'displayError').and.callThrough();
|
||||||
let res = Redoc.init();
|
// let res = Redoc.init();
|
||||||
return res.catch(() => {
|
// return res.catch(() => {
|
||||||
expect(Redoc.hideLoadingAnimation).toHaveBeenCalled();
|
// expect(Redoc.hideLoadingAnimation).toHaveBeenCalled();
|
||||||
expect(Redoc.displayError).toHaveBeenCalled();
|
// expect(Redoc.displayError).toHaveBeenCalled();
|
||||||
});
|
// });
|
||||||
}));
|
// }));
|
||||||
|
//
|
||||||
//skip because of PhantomJS crashes on this testcase
|
// //skip because of PhantomJS crashes on this testcase
|
||||||
xit('should init redoc', (done) => {
|
// xit('should init redoc', (done) => {
|
||||||
var node = document.createElement('redoc');
|
// var node = document.createElement('redoc');
|
||||||
document.body.appendChild(node);
|
// document.body.appendChild(node);
|
||||||
let res = Redoc.init('/tests/schemas/extended-petstore.yml');
|
// let res = Redoc.init('/tests/schemas/extended-petstore.yml');
|
||||||
res.then(() => { done(); }, () => {
|
// res.then(() => { done(); }, () => {
|
||||||
done.fail('Error handler should not been called');
|
// done.fail('Error handler should not been called');
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
describe('Redoc destroy', () => {
|
// describe('Redoc destroy', () => {
|
||||||
let builder;
|
// let builder;
|
||||||
let fixture;
|
// let fixture;
|
||||||
let element;
|
// let element;
|
||||||
let dom;
|
// let dom;
|
||||||
let destroySpy;
|
// let destroySpy;
|
||||||
|
//
|
||||||
beforeEach(async(inject([TestComponentBuilder, SpecManager, OptionsService, BrowserDomAdapter],
|
// beforeEach(async(inject([TestComponentBuilder, SpecManager, OptionsService, BrowserDomAdapter],
|
||||||
(tcb, specMgr, opts, _dom) => {
|
// (tcb, specMgr, opts, _dom) => {
|
||||||
builder = tcb;
|
// builder = tcb;
|
||||||
optsMgr = opts;
|
// optsMgr = opts;
|
||||||
dom = _dom;
|
// dom = _dom;
|
||||||
return specMgr.load('/tests/schemas/extended-petstore.yml');
|
// return specMgr.load('/tests/schemas/extended-petstore.yml');
|
||||||
})));
|
// })));
|
||||||
|
//
|
||||||
beforeEach(() => {
|
// beforeEach(() => {
|
||||||
fixture = builder.createSync(TestAppComponent);
|
// fixture = builder.createSync(TestAppComponent);
|
||||||
element = getChildDebugElement(fixture.debugElement, 'methods-list').nativeElement;
|
// element = getChildDebugElement(fixture.debugElement, 'methods-list').nativeElement;
|
||||||
destroySpy = jasmine.createSpy('spy');
|
// destroySpy = jasmine.createSpy('spy');
|
||||||
Redoc.appRef = <ComponentRef<any>>{
|
// Redoc.appRef = <ComponentRef<any>>{
|
||||||
destroy: destroySpy
|
// destroy: destroySpy
|
||||||
};
|
// };
|
||||||
fixture.detectChanges();
|
// fixture.detectChanges();
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
afterEach(()=> {
|
// afterEach(()=> {
|
||||||
fixture.destroy();
|
// fixture.destroy();
|
||||||
Redoc.appRef = null;
|
// Redoc.appRef = null;
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
it('should call componentRef.destroy', () => {
|
// it('should call componentRef.destroy', () => {
|
||||||
Redoc.destroy();
|
// Redoc.destroy();
|
||||||
expect(destroySpy).toHaveBeenCalled();
|
// expect(destroySpy).toHaveBeenCalled();
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
it('should create new host element', () => {
|
// it('should create new host element', () => {
|
||||||
element.parentElement.removeChild(element);
|
// element.parentElement.removeChild(element);
|
||||||
Redoc.destroy();
|
// Redoc.destroy();
|
||||||
expect(dom.query('redoc')).not.toBeNull();
|
// expect(dom.query('redoc')).not.toBeNull();
|
||||||
dom.query('redoc').should.not.be.equal(element);
|
// dom.query('redoc').should.not.be.equal(element);
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
it('should set to null appRef', () => {
|
// it('should set to null appRef', () => {
|
||||||
Redoc.destroy();
|
// Redoc.destroy();
|
||||||
expect(Redoc.appRef).toBeNull();
|
// expect(Redoc.appRef).toBeNull();
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
describe('Redoc autoInit', () => {
|
// describe('Redoc autoInit', () => {
|
||||||
const testURL = 'testurl';
|
// const testURL = 'testurl';
|
||||||
let dom = new BrowserDomAdapter();
|
// let dom = new BrowserDomAdapter();
|
||||||
//let redocInitSpy;
|
// //let redocInitSpy;
|
||||||
let elem: HTMLElement;
|
// let elem: HTMLElement;
|
||||||
|
//
|
||||||
beforeEach(() => {
|
// beforeEach(() => {
|
||||||
spyOn(Redoc, 'init').and.stub();
|
// spyOn(Redoc, 'init').and.stub();
|
||||||
elem = dom.createElement('redoc');
|
// elem = dom.createElement('redoc');
|
||||||
dom.defaultDoc().body.appendChild(elem);
|
// dom.defaultDoc().body.appendChild(elem);
|
||||||
dom.setAttribute(elem, 'spec-url', testURL);
|
// dom.setAttribute(elem, 'spec-url', testURL);
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
it('should call Redoc.init with url from param spec-url', () => {
|
// it('should call Redoc.init with url from param spec-url', () => {
|
||||||
Redoc.autoInit();
|
// Redoc.autoInit();
|
||||||
expect(Redoc.init).toHaveBeenCalled();
|
// expect(Redoc.init).toHaveBeenCalled();
|
||||||
expect((<jasmine.Spy>Redoc.init).calls.argsFor(0)).toEqual([testURL]);
|
// expect((<jasmine.Spy>Redoc.init).calls.argsFor(0)).toEqual([testURL]);
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
it('should not call Redoc.init when spec-url param is not provided', () => {
|
// it('should not call Redoc.init when spec-url param is not provided', () => {
|
||||||
dom.removeAttribute(elem, 'spec-url');
|
// dom.removeAttribute(elem, 'spec-url');
|
||||||
Redoc.autoInit();
|
// Redoc.autoInit();
|
||||||
expect(Redoc.init).not.toHaveBeenCalled();
|
// expect(Redoc.init).not.toHaveBeenCalled();
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
afterEach(() => {
|
// afterEach(() => {
|
||||||
(<jasmine.Spy>Redoc.init).and.callThrough();
|
// (<jasmine.Spy>Redoc.init).and.callThrough();
|
||||||
dom.defaultDoc().body.removeChild(elem);
|
// dom.defaultDoc().body.removeChild(elem);
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Test component that contains a Redoc. */
|
/** Test component that contains a Redoc. */
|
||||||
|
|
|
@ -1,43 +1,21 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { provide, enableProdMode, ElementRef,
|
import { ElementRef, ComponentRef, AfterViewInit, Component } from '@angular/core';
|
||||||
ComponentRef, AfterViewInit } from '@angular/core';
|
|
||||||
import { bootstrap } from '@angular/platform-browser-dynamic';
|
|
||||||
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
|
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
|
||||||
import { RedocComponent, BaseComponent } from '../base';
|
import { BaseComponent } from '../base';
|
||||||
|
|
||||||
import detectScollParent from 'scrollparent';
|
import detectScollParent from 'scrollparent';
|
||||||
|
|
||||||
import { ApiInfo } from '../ApiInfo/api-info';
|
import { SpecManager } from '../../utils/SpecManager';
|
||||||
import { ApiLogo } from '../ApiLogo/api-logo';
|
import { OptionsService, RedocEventsService } from '../../services/index';
|
||||||
import { MethodsList } from '../MethodsList/methods-list';
|
|
||||||
import { SideMenu } from '../SideMenu/side-menu';
|
|
||||||
import { Warnings } from '../Warnings/warnings';
|
|
||||||
|
|
||||||
import { StickySidebar } from '../../shared/components/index';
|
|
||||||
import {SpecManager} from '../../utils/SpecManager';
|
|
||||||
import { OptionsService, RedocEventsService, MenuService,
|
|
||||||
ScrollService, Hash, WarningsService } from '../../services/index';
|
|
||||||
|
|
||||||
var dom = new BrowserDomAdapter();
|
var dom = new BrowserDomAdapter();
|
||||||
var _modeLocked = false;
|
|
||||||
|
|
||||||
@RedocComponent({
|
@Component({
|
||||||
selector: 'redoc',
|
selector: 'redoc',
|
||||||
providers: [
|
|
||||||
SpecManager,
|
|
||||||
BrowserDomAdapter,
|
|
||||||
RedocEventsService,
|
|
||||||
ScrollService,
|
|
||||||
Hash,
|
|
||||||
MenuService,
|
|
||||||
WarningsService
|
|
||||||
],
|
|
||||||
templateUrl: './redoc.html',
|
templateUrl: './redoc.html',
|
||||||
styleUrls: ['./redoc.css'],
|
styleUrls: ['./redoc.css'],
|
||||||
directives: [ ApiInfo, ApiLogo, MethodsList, SideMenu, StickySidebar, Warnings ],
|
|
||||||
detect: true,
|
|
||||||
onPushOnly: false
|
|
||||||
})
|
})
|
||||||
export class Redoc extends BaseComponent implements AfterViewInit {
|
export class Redoc extends BaseComponent implements AfterViewInit {
|
||||||
static appRef: ComponentRef<any>;
|
static appRef: ComponentRef<any>;
|
||||||
|
@ -61,47 +39,6 @@ export class Redoc extends BaseComponent implements AfterViewInit {
|
||||||
}, 400);
|
}, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
static init(specUrl?, options?) {
|
|
||||||
var optionsService = new OptionsService(dom);
|
|
||||||
optionsService.options = options;
|
|
||||||
optionsService.options.specUrl = optionsService.options.specUrl || specUrl;
|
|
||||||
var providers = [
|
|
||||||
provide(OptionsService, {useValue: optionsService})
|
|
||||||
];
|
|
||||||
|
|
||||||
if (Redoc.appRef) {
|
|
||||||
Redoc.destroy();
|
|
||||||
}
|
|
||||||
Redoc.showLoadingAnimation();
|
|
||||||
return SpecManager.instance().load(specUrl)
|
|
||||||
.then(() => {
|
|
||||||
if (!_modeLocked && !optionsService.options.debugMode) {
|
|
||||||
enableProdMode();
|
|
||||||
_modeLocked = true;
|
|
||||||
}
|
|
||||||
return bootstrap(Redoc, providers);
|
|
||||||
})
|
|
||||||
.then(appRef => {
|
|
||||||
Redoc.hideLoadingAnimation();
|
|
||||||
Redoc.appRef = appRef;
|
|
||||||
console.log('ReDoc bootstrapped!');
|
|
||||||
}).catch(err => {
|
|
||||||
Redoc.hideLoadingAnimation();
|
|
||||||
Redoc.displayError(err);
|
|
||||||
throw err;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
static autoInit() {
|
|
||||||
const specUrlAttributeName = 'spec-url';
|
|
||||||
let redocEl = dom.query('redoc');
|
|
||||||
if (!redocEl) return;
|
|
||||||
if (dom.hasAttribute(redocEl, specUrlAttributeName)) {
|
|
||||||
let url = dom.getAttribute(redocEl, specUrlAttributeName);
|
|
||||||
Redoc.init(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static displayError(err) {
|
static displayError(err) {
|
||||||
let redocEl = dom.query('redoc');
|
let redocEl = dom.query('redoc');
|
||||||
if (!redocEl) return;
|
if (!redocEl) return;
|
||||||
|
@ -113,28 +50,6 @@ export class Redoc extends BaseComponent implements AfterViewInit {
|
||||||
redocEl.innerHTML = erroHtml;
|
redocEl.innerHTML = erroHtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
static destroy() {
|
|
||||||
let el = dom.query('redoc');
|
|
||||||
let elClone;
|
|
||||||
let parent;
|
|
||||||
let nextSibling;
|
|
||||||
if (el) {
|
|
||||||
parent = el.parentElement;
|
|
||||||
nextSibling = el.nextElementSibling;
|
|
||||||
}
|
|
||||||
|
|
||||||
elClone = el.cloneNode(false);
|
|
||||||
|
|
||||||
if (Redoc.appRef) {
|
|
||||||
Redoc.appRef.destroy();
|
|
||||||
Redoc.appRef = null;
|
|
||||||
|
|
||||||
// Redoc destroy removes host element, so need to restore it
|
|
||||||
elClone.innerHTML = 'Loading...';
|
|
||||||
if (parent) parent.insertBefore(elClone, nextSibling);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(specMgr: SpecManager, optionsMgr:OptionsService, elementRef:ElementRef,
|
constructor(specMgr: SpecManager, optionsMgr:OptionsService, elementRef:ElementRef,
|
||||||
public events:RedocEventsService) {
|
public events:RedocEventsService) {
|
||||||
super(specMgr);
|
super(specMgr);
|
||||||
|
|
|
@ -1,34 +1,28 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { ViewChildren, QueryList, EventEmitter, Input} from '@angular/core';
|
import { Component, ViewChildren, QueryList, EventEmitter, Input,
|
||||||
|
ChangeDetectionStrategy } from '@angular/core';
|
||||||
|
|
||||||
import { RedocComponent, BaseComponent, SpecManager } from '../base';
|
import { BaseComponent, SpecManager } from '../base';
|
||||||
import JsonPointer from '../../utils/JsonPointer';
|
import JsonPointer from '../../utils/JsonPointer';
|
||||||
import { Tabs, Tab } from '../../shared/components/index';
|
import { Tabs } from '../../shared/components/index';
|
||||||
import { SchemaSample } from '../SchemaSample/schema-sample';
|
|
||||||
import { PrismPipe } from '../../utils/pipes';
|
|
||||||
import { RedocEventsService } from '../../services/index';
|
import { RedocEventsService } from '../../services/index';
|
||||||
|
|
||||||
import { CopyButton } from '../../shared/components/CopyButton/copy-button.directive';
|
@Component({
|
||||||
|
|
||||||
@RedocComponent({
|
|
||||||
selector: 'request-samples',
|
selector: 'request-samples',
|
||||||
templateUrl: './request-samples.html',
|
templateUrl: './request-samples.html',
|
||||||
styleUrls: ['./request-samples.css'],
|
styleUrls: ['./request-samples.css'],
|
||||||
directives: [SchemaSample, Tabs, Tab, CopyButton],
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
inputs: ['schemaPointer'],
|
|
||||||
pipes: [PrismPipe],
|
|
||||||
detect: true,
|
|
||||||
onPushOnly: false
|
|
||||||
})
|
})
|
||||||
export class RequestSamples extends BaseComponent {
|
export class RequestSamples extends BaseComponent {
|
||||||
childTabs: Tabs;
|
@Input() pointer:string;
|
||||||
selectedLang: EventEmitter<any>;
|
|
||||||
|
|
||||||
samples: Array<any>;
|
|
||||||
|
|
||||||
@Input() schemaPointer:string;
|
@Input() schemaPointer:string;
|
||||||
@ViewChildren(Tabs) childQuery:QueryList<Tabs>;
|
@ViewChildren(Tabs) childQuery:QueryList<Tabs>;
|
||||||
|
|
||||||
|
childTabs: Tabs;
|
||||||
|
selectedLang: EventEmitter<any>;
|
||||||
|
samples: Array<any>;
|
||||||
|
|
||||||
constructor(specMgr:SpecManager, public events:RedocEventsService) {
|
constructor(specMgr:SpecManager, public events:RedocEventsService) {
|
||||||
super(specMgr);
|
super(specMgr);
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import {RedocComponent, BaseComponent, SpecManager} from '../base';
|
import { Component, Input } from '@angular/core';
|
||||||
|
import { BaseComponent, SpecManager } from '../base';
|
||||||
import JsonPointer from '../../utils/JsonPointer';
|
import JsonPointer from '../../utils/JsonPointer';
|
||||||
import { JsonSchema } from '../JsonSchema/json-schema';
|
|
||||||
import { JsonSchemaLazy } from '../JsonSchema/json-schema-lazy';
|
|
||||||
import { Zippy } from '../../shared/components/index';
|
|
||||||
import { statusCodeType } from '../../utils/helpers';
|
import { statusCodeType } from '../../utils/helpers';
|
||||||
import { OptionsService } from '../../services/index';
|
import { OptionsService } from '../../services/index';
|
||||||
import { SchemaHelper } from '../../services/schema-helper.service';
|
import { SchemaHelper } from '../../services/schema-helper.service';
|
||||||
|
@ -13,16 +11,17 @@ function isNumeric(n) {
|
||||||
return (!isNaN(parseFloat(n)) && isFinite(n));
|
return (!isNaN(parseFloat(n)) && isFinite(n));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RedocComponent({
|
@Component({
|
||||||
selector: 'responses-list',
|
selector: 'responses-list',
|
||||||
templateUrl: './responses-list.html',
|
templateUrl: './responses-list.html',
|
||||||
styleUrls: ['./responses-list.css'],
|
styleUrls: ['./responses-list.css']
|
||||||
directives: [JsonSchema, Zippy, JsonSchemaLazy],
|
|
||||||
detect: true
|
|
||||||
})
|
})
|
||||||
export class ResponsesList extends BaseComponent {
|
export class ResponsesList extends BaseComponent {
|
||||||
|
@Input() pointer:string;
|
||||||
|
|
||||||
responses: Array<any>;
|
responses: Array<any>;
|
||||||
options: any;
|
options: any;
|
||||||
|
|
||||||
constructor(specMgr:SpecManager, optionsMgr:OptionsService) {
|
constructor(specMgr:SpecManager, optionsMgr:OptionsService) {
|
||||||
super(specMgr);
|
super(specMgr);
|
||||||
this.options = optionsMgr.options;
|
this.options = optionsMgr.options;
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { forwardRef } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { RedocComponent, BaseComponent, SpecManager } from '../base';
|
import { BaseComponent, SpecManager } from '../base';
|
||||||
import JsonPointer from '../../utils/JsonPointer';
|
import JsonPointer from '../../utils/JsonPointer';
|
||||||
import { Tabs, Tab } from '../../shared/components/index';
|
|
||||||
import { SchemaSample } from '../index';
|
|
||||||
import { statusCodeType } from '../../utils/helpers';
|
import { statusCodeType } from '../../utils/helpers';
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,14 +15,16 @@ function hasExample(response) {
|
||||||
response.schema);
|
response.schema);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RedocComponent({
|
@Component({
|
||||||
selector: 'responses-samples',
|
selector: 'responses-samples',
|
||||||
templateUrl: './responses-samples.html',
|
templateUrl: './responses-samples.html',
|
||||||
styleUrls: ['./responses-samples.css'],
|
styleUrls: ['./responses-samples.css'],
|
||||||
directives: [forwardRef( ()=> SchemaSample), Tabs, Tab]
|
|
||||||
})
|
})
|
||||||
export class ResponsesSamples extends BaseComponent {
|
export class ResponsesSamples extends BaseComponent {
|
||||||
|
@Input() pointer:string;
|
||||||
|
|
||||||
data: any;
|
data: any;
|
||||||
|
|
||||||
constructor(specMgr:SpecManager) {
|
constructor(specMgr:SpecManager) {
|
||||||
super(specMgr);
|
super(specMgr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { ElementRef, Input } from '@angular/core';
|
import { Component, ElementRef, Input, ChangeDetectionStrategy } from '@angular/core';
|
||||||
|
|
||||||
import * as OpenAPISampler from 'openapi-sampler';
|
import * as OpenAPISampler from 'openapi-sampler';
|
||||||
|
|
||||||
import { RedocComponent, BaseComponent, SpecManager } from '../base';
|
import { BaseComponent, SpecManager } from '../base';
|
||||||
import { JsonFormatter } from '../../utils/JsonFormatterPipe';
|
import { JsonFormatter } from '../../utils/JsonFormatterPipe';
|
||||||
import { SchemaNormalizer } from '../../services/schema-normalizer.service';
|
import { SchemaNormalizer } from '../../services/schema-normalizer.service';
|
||||||
|
|
||||||
import { CopyButton } from '../../shared/components/CopyButton/copy-button.directive';
|
@Component({
|
||||||
|
|
||||||
@RedocComponent({
|
|
||||||
selector: 'schema-sample',
|
selector: 'schema-sample',
|
||||||
templateUrl: './schema-sample.html',
|
templateUrl: './schema-sample.html',
|
||||||
pipes: [JsonFormatter],
|
pipes: [JsonFormatter],
|
||||||
directives: [CopyButton],
|
styleUrls: ['./schema-sample.css'],
|
||||||
styleUrls: ['./schema-sample.css']
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
})
|
})
|
||||||
export class SchemaSample extends BaseComponent {
|
export class SchemaSample extends BaseComponent {
|
||||||
|
@Input() pointer:string;
|
||||||
|
@Input() skipReadOnly:boolean;
|
||||||
|
|
||||||
element: any;
|
element: any;
|
||||||
sample: any;
|
sample: any;
|
||||||
enableButtons: boolean = false;
|
enableButtons: boolean = false;
|
||||||
@Input() skipReadOnly:boolean;
|
|
||||||
|
|
||||||
private _normalizer:SchemaNormalizer;
|
private _normalizer:SchemaNormalizer;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
<label class="menu-cat-header" (click)="activateAndScroll(idx, -1)" [hidden]="cat.headless"
|
<label class="menu-cat-header" (click)="activateAndScroll(idx, -1)" [hidden]="cat.headless"
|
||||||
[ngClass]="{active: cat.active}"> {{cat.name}}</label>
|
[ngClass]="{active: cat.active}"> {{cat.name}}</label>
|
||||||
<ul class="menu-subitems" @itemAnimation="cat.active ? 'expanded' : 'collapsed'">
|
<ul class="menu-subitems" [@itemAnimation]="cat.active ? 'expanded' : 'collapsed'">
|
||||||
<li *ngFor="let method of cat.methods; trackBy:summary; let methIdx = index"
|
<li *ngFor="let method of cat.methods; trackBy:summary; let methIdx = index"
|
||||||
[ngClass]="{active: method.active}"
|
[ngClass]="{active: method.active}"
|
||||||
(click)="activateAndScroll(idx, methIdx)">
|
(click)="activateAndScroll(idx, methIdx)">
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
async
|
async
|
||||||
} from '@angular/core/testing';
|
} from '@angular/core/testing';
|
||||||
|
|
||||||
import { TestComponentBuilder } from '@angular/compiler/testing';
|
import { TestComponentBuilder } from '@angular/core/testing';
|
||||||
|
|
||||||
import { MethodsList, SideMenu } from '../index';
|
import { MethodsList, SideMenu } from '../index';
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { ElementRef, ChangeDetectorRef } from '@angular/core';
|
import { Component, ElementRef, ChangeDetectorRef } from '@angular/core';
|
||||||
|
|
||||||
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
|
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
|
||||||
import { global } from '@angular/core/src/facade/lang';
|
import { global } from '@angular/core/src/facade/lang';
|
||||||
import { trigger, state, animate, transition, style } from '@angular/core';
|
import { trigger, state, animate, transition, style } from '@angular/core';
|
||||||
import { RedocComponent, BaseComponent, SpecManager } from '../base';
|
import { BaseComponent, SpecManager } from '../base';
|
||||||
import { ScrollService, Hash, MenuService, OptionsService } from '../../services/index';
|
import { ScrollService, Hash, MenuService, OptionsService } from '../../services/index';
|
||||||
|
|
||||||
import { MenuCategory } from '../../services/schema-helper.service';
|
import { MenuCategory } from '../../services/schema-helper.service';
|
||||||
|
|
||||||
@RedocComponent({
|
@Component({
|
||||||
selector: 'side-menu',
|
selector: 'side-menu',
|
||||||
templateUrl: './side-menu.html',
|
templateUrl: './side-menu.html',
|
||||||
styleUrls: ['./side-menu.css'],
|
styleUrls: ['./side-menu.css'],
|
||||||
detect: true,
|
|
||||||
onPushOnly: false,
|
|
||||||
animations: [
|
animations: [
|
||||||
trigger('itemAnimation', [
|
trigger('itemAnimation', [
|
||||||
state('collapsed, void',
|
state('collapsed, void',
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { SpecManager, RedocComponent, BaseComponent } from '../base';
|
import { Component, ChangeDetectionStrategy } from '@angular/core';
|
||||||
|
import { SpecManager, BaseComponent } from '../base';
|
||||||
import { WarningsService, OptionsService } from '../../services/index';
|
import { WarningsService, OptionsService } from '../../services/index';
|
||||||
|
|
||||||
@RedocComponent({
|
@Component({
|
||||||
selector: 'warnings',
|
selector: 'warnings',
|
||||||
styleUrls: ['./warnings.css'],
|
styleUrls: ['./warnings.css'],
|
||||||
templateUrl: './warnings.html',
|
templateUrl: './warnings.html',
|
||||||
detect: true,
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
onPushOnly: false
|
|
||||||
})
|
})
|
||||||
export class Warnings extends BaseComponent {
|
export class Warnings extends BaseComponent {
|
||||||
warnings: Array<string> = [];
|
warnings: Array<string> = [];
|
||||||
|
|
|
@ -1,21 +1,10 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
import { Component, ChangeDetectionStrategy, OnInit, OnDestroy } from '@angular/core';
|
import { OnInit, OnDestroy } from '@angular/core';
|
||||||
import { CORE_DIRECTIVES, JsonPipe, AsyncPipe } from '@angular/common';
|
|
||||||
import { SpecManager } from '../utils/SpecManager';
|
import { SpecManager } from '../utils/SpecManager';
|
||||||
import { MarkedPipe, JsonPointerEscapePipe, SafePipe } from '../utils/pipes';
|
|
||||||
|
|
||||||
export { SpecManager };
|
export { SpecManager };
|
||||||
|
|
||||||
// common inputs for all components
|
|
||||||
let commonInputs = ['pointer']; // json pointer to the schema chunk
|
|
||||||
|
|
||||||
// internal helper function
|
|
||||||
function safeConcat(a, b) {
|
|
||||||
let res = a && a.slice() || [];
|
|
||||||
b = (b == undefined) ? [] : b;
|
|
||||||
return res.concat(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
function snapshot(obj) {
|
function snapshot(obj) {
|
||||||
if(obj == undefined || typeof(obj) !== 'object') {
|
if(obj == undefined || typeof(obj) !== 'object') {
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -32,54 +21,13 @@ function snapshot(obj) {
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Class decorator
|
|
||||||
* Simplifies setup of component metainfo
|
|
||||||
* All options are options from either Component or View angular2 decorator
|
|
||||||
* For detailed info look angular2 doc
|
|
||||||
* @param {Object} options - component options
|
|
||||||
* @param {string[]} options.inputs - component inputs
|
|
||||||
* @param {*[]} options.directives - directives used by component
|
|
||||||
* (except CORE_DIRECTIVES)
|
|
||||||
* @param {*[]} options.pipes - pipes used by component
|
|
||||||
* @param {*[]} options.providers - component providers
|
|
||||||
* @param {string} options.templateUrl - path to component template
|
|
||||||
* @param {string} options.template - component template html
|
|
||||||
* @param {string} options.styles - component css styles
|
|
||||||
*/
|
|
||||||
export function RedocComponent(options) {
|
|
||||||
let inputs = safeConcat(options.inputs, commonInputs);
|
|
||||||
let directives = safeConcat(options.directives, CORE_DIRECTIVES);
|
|
||||||
let pipes = safeConcat(options.pipes, [JsonPointerEscapePipe, MarkedPipe, JsonPipe, AsyncPipe, SafePipe]);
|
|
||||||
if (options.onPushOnly === undefined) options.onPushOnly = true;
|
|
||||||
|
|
||||||
return function decorator(target) {
|
|
||||||
|
|
||||||
let componentDecorator = Component({
|
|
||||||
selector: options.selector,
|
|
||||||
inputs: inputs,
|
|
||||||
outputs: options.outputs,
|
|
||||||
providers: options.providers,
|
|
||||||
changeDetection: options.onPushOnly ? ChangeDetectionStrategy.OnPush : ChangeDetectionStrategy.Default,
|
|
||||||
animations: options.animations,
|
|
||||||
templateUrl: options.templateUrl,
|
|
||||||
template: options.template,
|
|
||||||
styles: options.styles,
|
|
||||||
directives: directives,
|
|
||||||
pipes: pipes
|
|
||||||
});
|
|
||||||
|
|
||||||
return componentDecorator(target) || target;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic Component
|
* Generic Component
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
export class BaseComponent implements OnInit, OnDestroy {
|
export class BaseComponent implements OnInit, OnDestroy {
|
||||||
componentSchema: any = null;
|
|
||||||
pointer: string;
|
pointer: string;
|
||||||
|
componentSchema: any = null;
|
||||||
dereferencedCache = {};
|
dereferencedCache = {};
|
||||||
|
|
||||||
constructor(public specMgr: SpecManager) {
|
constructor(public specMgr: SpecManager) {
|
||||||
|
|
|
@ -1,16 +1,25 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export * from './ApiInfo/api-info';
|
import { ApiInfo } from './ApiInfo/api-info';
|
||||||
export * from './ApiLogo/api-logo';
|
import { ApiLogo } from './ApiLogo/api-logo';
|
||||||
export * from './JsonSchema/json-schema';
|
import { JsonSchema } from './JsonSchema/json-schema';
|
||||||
export * from './JsonSchema/json-schema-lazy';
|
import { JsonSchemaLazy } from './JsonSchema/json-schema-lazy';
|
||||||
export * from './ParamsList/params-list';
|
import { ParamsList } from './ParamsList/params-list';
|
||||||
export * from './RequestSamples/request-samples';
|
import { RequestSamples } from './RequestSamples/request-samples';
|
||||||
export * from './ResponsesList/responses-list';
|
import { ResponsesList } from './ResponsesList/responses-list';
|
||||||
export * from './ResponsesSamples/responses-samples';
|
import { ResponsesSamples } from './ResponsesSamples/responses-samples';
|
||||||
export * from './SchemaSample/schema-sample';
|
import { SchemaSample } from './SchemaSample/schema-sample';
|
||||||
export * from './SideMenu/side-menu';
|
import { SideMenu } from './SideMenu/side-menu';
|
||||||
export * from './MethodsList/methods-list';
|
import { MethodsList } from './MethodsList/methods-list';
|
||||||
export * from './Method/method';
|
import { Method } from './Method/method';
|
||||||
|
import { Warnings } from './Warnings/warnings';
|
||||||
|
|
||||||
export * from './Redoc/redoc';
|
import { Redoc } from './Redoc/redoc';
|
||||||
|
|
||||||
|
export const REDOC_DIRECTIVES = [
|
||||||
|
ApiInfo, ApiLogo, JsonSchema, JsonSchemaLazy, ParamsList, RequestSamples, ResponsesList,
|
||||||
|
ResponsesSamples, SchemaSample, SideMenu, MethodsList, Method, Warnings, Redoc
|
||||||
|
];
|
||||||
|
|
||||||
|
export { ApiInfo, ApiLogo, JsonSchema, JsonSchemaLazy, ParamsList, RequestSamples, ResponsesList,
|
||||||
|
ResponsesSamples, SchemaSample, SideMenu, MethodsList, Method, Warnings, Redoc }
|
||||||
|
|
58
lib/index.js
58
lib/index.js
|
@ -3,13 +3,61 @@ import './components/Redoc/redoc-initial-styles.css!css';
|
||||||
import 'dropkickjs/build/css/dropkick.css!css';
|
import 'dropkickjs/build/css/dropkick.css!css';
|
||||||
import 'prismjs/themes/prism-dark.css!css';
|
import 'prismjs/themes/prism-dark.css!css';
|
||||||
import 'hint.css/hint.base.css!css';
|
import 'hint.css/hint.base.css!css';
|
||||||
import { redocVersion } from './version.js';
|
//import { redocVersion } from './version.js';
|
||||||
|
|
||||||
|
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||||
|
import { enableProdMode } from '@angular/core';
|
||||||
|
import { RedocModule } from './redoc.module';
|
||||||
import { Redoc } from './components/index';
|
import { Redoc } from './components/index';
|
||||||
|
import { optionsService } from './redoc.module';
|
||||||
|
import { SpecManager } from './utils/SpecManager';
|
||||||
|
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
|
||||||
|
|
||||||
Redoc.version = redocVersion;
|
var dom = new BrowserDomAdapter();
|
||||||
|
|
||||||
export var init = Redoc.init;
|
//Redoc.version = redocVersion;
|
||||||
|
var moduleRef;
|
||||||
|
export function init(specUrl:string, options?) {
|
||||||
|
if (!optionsService.options.debugMode) {
|
||||||
|
enableProdMode();
|
||||||
|
}
|
||||||
|
|
||||||
window['Redoc'] = Redoc;
|
if (moduleRef) {
|
||||||
Redoc.autoInit();
|
destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
optionsService.options = options;
|
||||||
|
optionsService.options.specUrl = optionsService.options.specUrl || specUrl;
|
||||||
|
|
||||||
|
Redoc.showLoadingAnimation();
|
||||||
|
return SpecManager.instance().load(specUrl)
|
||||||
|
.then(() => {
|
||||||
|
return platformBrowserDynamic().bootstrapModule(RedocModule);
|
||||||
|
})
|
||||||
|
.then(appRef => {
|
||||||
|
Redoc.hideLoadingAnimation();
|
||||||
|
moduleRef = appRef;
|
||||||
|
console.log('ReDoc initialized!');
|
||||||
|
}).catch(err => {
|
||||||
|
Redoc.hideLoadingAnimation();
|
||||||
|
Redoc.displayError(err);
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export function destroy() {
|
||||||
|
moduleRef.destroy();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function autoInit() {
|
||||||
|
const specUrlAttributeName = 'spec-url';
|
||||||
|
let redocEl = dom.query('redoc');
|
||||||
|
if (!redocEl) return;
|
||||||
|
if (dom.hasAttribute(redocEl, specUrlAttributeName)) {
|
||||||
|
let url = dom.getAttribute(redocEl, specUrlAttributeName);
|
||||||
|
init(url);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
autoInit();
|
||||||
|
|
31
lib/redoc.module.ts
Normal file
31
lib/redoc.module.ts
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
import { NgModule, provide } from '@angular/core';
|
||||||
|
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
|
||||||
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
|
|
||||||
|
import { Redoc, REDOC_DIRECTIVES } from './components/index';
|
||||||
|
import { REDOC_COMMON_DIRECTIVES } from './shared/components/index';
|
||||||
|
import { REDOC_PIPES } from './utils/pipes';
|
||||||
|
|
||||||
|
import { OptionsService, RedocEventsService, MenuService,
|
||||||
|
ScrollService, Hash, WarningsService } from './services/index';
|
||||||
|
import { SpecManager } from './utils/SpecManager';
|
||||||
|
|
||||||
|
export const optionsService = new OptionsService(new BrowserDomAdapter());
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [ BrowserModule ],
|
||||||
|
declarations: [ REDOC_DIRECTIVES, REDOC_COMMON_DIRECTIVES, REDOC_PIPES],
|
||||||
|
bootstrap: [ Redoc ],
|
||||||
|
providers: [
|
||||||
|
SpecManager,
|
||||||
|
BrowserDomAdapter,
|
||||||
|
RedocEventsService,
|
||||||
|
ScrollService,
|
||||||
|
Hash,
|
||||||
|
MenuService,
|
||||||
|
WarningsService,
|
||||||
|
provide(OptionsService, {useValue: optionsService})
|
||||||
|
],
|
||||||
|
})
|
||||||
|
export class RedocModule {
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { Component, EventEmitter, ElementRef, Output, AfterContentInit } from '@angular/core';
|
import { Component, EventEmitter, ElementRef, Output, AfterContentInit } from '@angular/core';
|
||||||
import { CORE_DIRECTIVES } from '@angular/common';
|
|
||||||
import DropKick from 'dropkickjs';
|
import DropKick from 'dropkickjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -11,7 +10,6 @@ import DropKick from 'dropkickjs';
|
||||||
<ng-content></ng-content>
|
<ng-content></ng-content>
|
||||||
</select>
|
</select>
|
||||||
`,
|
`,
|
||||||
directives: [CORE_DIRECTIVES],
|
|
||||||
styleUrls: ['./drop-down.css']
|
styleUrls: ['./drop-down.css']
|
||||||
})
|
})
|
||||||
export class DropDown implements AfterContentInit {
|
export class DropDown implements AfterContentInit {
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { Component, EventEmitter, Input, Output, OnInit } from '@angular/core';
|
import { Component, EventEmitter, Input, Output, OnInit } from '@angular/core';
|
||||||
import { CORE_DIRECTIVES } from '@angular/common';
|
|
||||||
import { ChangeDetectorRef, ChangeDetectionStrategy } from '@angular/core';
|
import { ChangeDetectorRef, ChangeDetectionStrategy } from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -13,7 +12,6 @@ import { ChangeDetectorRef, ChangeDetectionStrategy } from '@angular/core';
|
||||||
</ul>
|
</ul>
|
||||||
<ng-content></ng-content>
|
<ng-content></ng-content>
|
||||||
`,
|
`,
|
||||||
directives: [CORE_DIRECTIVES],
|
|
||||||
styleUrls: ['tabs.css'],
|
styleUrls: ['tabs.css'],
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
})
|
})
|
||||||
|
@ -70,7 +68,6 @@ export class Tabs implements OnInit {
|
||||||
<ng-content></ng-content>
|
<ng-content></ng-content>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
directives: [CORE_DIRECTIVES],
|
|
||||||
styles: [`
|
styles: [`
|
||||||
.tab-wrap {
|
.tab-wrap {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { getChildDebugElement, mouseclick } from '../../../../tests/helpers';
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
inject,
|
inject,
|
||||||
expect,
|
|
||||||
TestComponentBuilder
|
TestComponentBuilder
|
||||||
} from '@angular/core/testing';
|
} from '@angular/core/testing';
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { Component, EventEmitter, Output, Input } from '@angular/core';
|
import { Component, EventEmitter, Output, Input } from '@angular/core';
|
||||||
import { CORE_DIRECTIVES } from '@angular/common';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'zippy',
|
selector: 'zippy',
|
||||||
templateUrl: './zippy.html',
|
templateUrl: './zippy.html',
|
||||||
styleUrls: ['./zippy.css'],
|
styleUrls: ['./zippy.css']
|
||||||
directives: [CORE_DIRECTIVES]
|
|
||||||
})
|
})
|
||||||
export class Zippy {
|
export class Zippy {
|
||||||
@Input() type = 'general';
|
@Input() type = 'general';
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
export * from './DropDown/drop-down';
|
import { DropDown } from './DropDown/drop-down';
|
||||||
export * from './StickySidebar/sticky-sidebar';
|
import { StickySidebar } from './StickySidebar/sticky-sidebar';
|
||||||
export * from './Tabs/tabs';
|
import { Tabs, Tab } from './Tabs/tabs';
|
||||||
export * from './Zippy/zippy';
|
import { Zippy } from './Zippy/zippy';
|
||||||
|
import { CopyButton } from './CopyButton/copy-button.directive';
|
||||||
|
import { SelectOnClick } from './SelectOnClick/select-on-click.directive';
|
||||||
|
|
||||||
|
export const REDOC_COMMON_DIRECTIVES = [
|
||||||
|
DropDown, StickySidebar, Tabs, Tab, Zippy, CopyButton, SelectOnClick
|
||||||
|
];
|
||||||
|
|
||||||
|
export { DropDown, StickySidebar, Tabs, Tab, Zippy, CopyButton, SelectOnClick }
|
||||||
|
|
|
@ -32,8 +32,8 @@ export class SpecManager {
|
||||||
.then(schema => {
|
.then(schema => {
|
||||||
this._url = url;
|
this._url = url;
|
||||||
this._schema = schema;
|
this._schema = schema;
|
||||||
resolve(this._schema);
|
|
||||||
this.init();
|
this.init();
|
||||||
|
return resolve(this._schema);
|
||||||
}, err => reject(err));
|
}, err => reject(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -117,3 +117,7 @@ export class EncodeURIComponentPipe implements PipeTransform {
|
||||||
return encodeURIComponent(value);
|
return encodeURIComponent(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const REDOC_PIPES = [
|
||||||
|
JsonPointerEscapePipe, MarkedPipe, SafePipe, PrismPipe, EncodeURIComponentPipe
|
||||||
|
];
|
||||||
|
|
25
package.json
25
package.json
|
@ -32,11 +32,11 @@
|
||||||
"jspm": {
|
"jspm": {
|
||||||
"configFile": "system.config.js",
|
"configFile": "system.config.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/common@2.0.0-rc.4": "npm:@angular/common@2.0.0-rc.4",
|
"@angular/common": "npm:@angular/common@^2.0.0-rc.5",
|
||||||
"@angular/compiler@2.0.0-rc.4": "npm:@angular/compiler@2.0.0-rc.4",
|
"@angular/compiler": "npm:@angular/compiler@^2.0.0-rc.5",
|
||||||
"@angular/core@2.0.0-rc.4": "npm:@angular/core@2.0.0-rc.4",
|
"@angular/core": "npm:@angular/core@^2.0.0-rc.5",
|
||||||
"@angular/platform-browser-dynamic@2.0.0-rc.4": "npm:@angular/platform-browser-dynamic@2.0.0-rc.4",
|
"@angular/platform-browser": "npm:@angular/platform-browser@^2.0.0-rc.5",
|
||||||
"@angular/platform-browser@2.0.0-rc.4": "npm:@angular/platform-browser@2.0.0-rc.4",
|
"@angular/platform-browser-dynamic": "npm:@angular/platform-browser-dynamic@^2.0.0-rc.5",
|
||||||
"dropkickjs": "npm:dropkickjs@^2.1.8",
|
"dropkickjs": "npm:dropkickjs@^2.1.8",
|
||||||
"es6-shim": "github:es-shims/es6-shim@^0.33.6",
|
"es6-shim": "github:es-shims/es6-shim@^0.33.6",
|
||||||
"hint.css": "npm:hint.css@^2.2.1",
|
"hint.css": "npm:hint.css@^2.2.1",
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
"slugify": "npm:slugify@^0.1.1",
|
"slugify": "npm:slugify@^0.1.1",
|
||||||
"stream-http": "npm:stream-http@^2.3.0",
|
"stream-http": "npm:stream-http@^2.3.0",
|
||||||
"url": "github:jspm/nodelibs-url@^0.1.0",
|
"url": "github:jspm/nodelibs-url@^0.1.0",
|
||||||
"zone.js": "npm:zone.js@0.6.12"
|
"zone.js": "npm:zone.js@^0.6.14"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel": "npm:babel-core@^5.8.34",
|
"babel": "npm:babel-core@^5.8.34",
|
||||||
|
@ -78,12 +78,11 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular/common": "^2.0.0-rc.4",
|
"@angular/common": "^2.0.0-rc.5",
|
||||||
"@angular/compiler": "^2.0.0-rc.4",
|
"@angular/compiler": "^2.0.0-rc.5",
|
||||||
"@angular/core": "^2.0.0-rc.4",
|
"@angular/core": "^2.0.0-rc.5",
|
||||||
"@angular/platform-browser": "^2.0.0-rc.4",
|
"@angular/platform-browser": "^2.0.0-rc.5",
|
||||||
"@angular/platform-browser-dynamic": "^2.0.0-rc.4",
|
"@angular/platform-browser-dynamic": "^2.0.0-rc.5",
|
||||||
"@angular/platform-server": "^2.0.0-rc.4",
|
|
||||||
"babel-polyfill": "^6.3.14",
|
"babel-polyfill": "^6.3.14",
|
||||||
"branch-release": "^1.0.3",
|
"branch-release": "^1.0.3",
|
||||||
"browser-sync": "^2.10.1",
|
"browser-sync": "^2.10.1",
|
||||||
|
@ -141,6 +140,6 @@
|
||||||
"typescript": "^1.8.10",
|
"typescript": "^1.8.10",
|
||||||
"vinyl-paths": "^2.0.0",
|
"vinyl-paths": "^2.0.0",
|
||||||
"yargs": "^4.7.1",
|
"yargs": "^4.7.1",
|
||||||
"zone.js": "^0.6.12"
|
"zone.js": "^0.6.14"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,11 @@ System.config({
|
||||||
},
|
},
|
||||||
|
|
||||||
map: {
|
map: {
|
||||||
"@angular/common": "npm:@angular/common@2.0.0-rc.4",
|
"@angular/common": "npm:@angular/common@2.0.0-rc.5",
|
||||||
"@angular/compiler": "npm:@angular/compiler@2.0.0-rc.4",
|
"@angular/compiler": "npm:@angular/compiler@2.0.0-rc.5",
|
||||||
"@angular/core": "npm:@angular/core@2.0.0-rc.4",
|
"@angular/core": "npm:@angular/core@2.0.0-rc.5",
|
||||||
"@angular/platform-browser": "npm:@angular/platform-browser@2.0.0-rc.4",
|
"@angular/platform-browser": "npm:@angular/platform-browser@2.0.0-rc.5",
|
||||||
"@angular/platform-browser-dynamic": "npm:@angular/platform-browser-dynamic@2.0.0-rc.4",
|
"@angular/platform-browser-dynamic": "npm:@angular/platform-browser-dynamic@2.0.0-rc.5",
|
||||||
"babel": "npm:babel-core@5.8.34",
|
"babel": "npm:babel-core@5.8.34",
|
||||||
"babel-runtime": "npm:babel-runtime@5.8.34",
|
"babel-runtime": "npm:babel-runtime@5.8.34",
|
||||||
"clean-css": "npm:clean-css@3.4.17",
|
"clean-css": "npm:clean-css@3.4.17",
|
||||||
|
@ -42,7 +42,7 @@ System.config({
|
||||||
"stream-http": "npm:stream-http@2.3.0",
|
"stream-http": "npm:stream-http@2.3.0",
|
||||||
"systemjs/plugin-json": "github:systemjs/plugin-json@0.1.2",
|
"systemjs/plugin-json": "github:systemjs/plugin-json@0.1.2",
|
||||||
"url": "github:jspm/nodelibs-url@0.1.0",
|
"url": "github:jspm/nodelibs-url@0.1.0",
|
||||||
"zone.js": "npm:zone.js@0.6.12",
|
"zone.js": "npm:zone.js@0.6.14",
|
||||||
"github:jspm/nodelibs-assert@0.1.0": {
|
"github:jspm/nodelibs-assert@0.1.0": {
|
||||||
"assert": "npm:assert@1.4.1"
|
"assert": "npm:assert@1.4.1"
|
||||||
},
|
},
|
||||||
|
@ -86,7 +86,7 @@ System.config({
|
||||||
"path-browserify": "npm:path-browserify@0.0.0"
|
"path-browserify": "npm:path-browserify@0.0.0"
|
||||||
},
|
},
|
||||||
"github:jspm/nodelibs-process@0.1.2": {
|
"github:jspm/nodelibs-process@0.1.2": {
|
||||||
"process": "npm:process@0.11.5"
|
"process": "npm:process@0.11.8"
|
||||||
},
|
},
|
||||||
"github:jspm/nodelibs-punycode@0.1.0": {
|
"github:jspm/nodelibs-punycode@0.1.0": {
|
||||||
"punycode": "npm:punycode@1.3.2"
|
"punycode": "npm:punycode@1.3.2"
|
||||||
|
@ -118,30 +118,30 @@ System.config({
|
||||||
"github:jspm/nodelibs-zlib@0.1.0": {
|
"github:jspm/nodelibs-zlib@0.1.0": {
|
||||||
"browserify-zlib": "npm:browserify-zlib@0.1.4"
|
"browserify-zlib": "npm:browserify-zlib@0.1.4"
|
||||||
},
|
},
|
||||||
"npm:@angular/common@2.0.0-rc.4": {
|
"npm:@angular/common@2.0.0-rc.5": {
|
||||||
"@angular/core": "npm:@angular/core@2.0.0-rc.4",
|
"@angular/core": "npm:@angular/core@2.0.0-rc.5",
|
||||||
"process": "github:jspm/nodelibs-process@0.1.2"
|
"process": "github:jspm/nodelibs-process@0.1.2"
|
||||||
},
|
},
|
||||||
"npm:@angular/compiler@2.0.0-rc.4": {
|
"npm:@angular/compiler@2.0.0-rc.5": {
|
||||||
"@angular/core": "npm:@angular/core@2.0.0-rc.4",
|
"@angular/core": "npm:@angular/core@2.0.0-rc.5",
|
||||||
"process": "github:jspm/nodelibs-process@0.1.2"
|
"process": "github:jspm/nodelibs-process@0.1.2"
|
||||||
},
|
},
|
||||||
"npm:@angular/core@2.0.0-rc.4": {
|
"npm:@angular/core@2.0.0-rc.5": {
|
||||||
"process": "github:jspm/nodelibs-process@0.1.2",
|
"process": "github:jspm/nodelibs-process@0.1.2",
|
||||||
"rxjs": "npm:rxjs@5.0.0-beta.6",
|
"rxjs": "npm:rxjs@5.0.0-beta.6",
|
||||||
"zone.js": "npm:zone.js@0.6.12"
|
"zone.js": "npm:zone.js@0.6.12"
|
||||||
},
|
},
|
||||||
"npm:@angular/platform-browser-dynamic@2.0.0-rc.4": {
|
"npm:@angular/platform-browser-dynamic@2.0.0-rc.5": {
|
||||||
"@angular/common": "npm:@angular/common@2.0.0-rc.4",
|
"@angular/common": "npm:@angular/common@2.0.0-rc.5",
|
||||||
"@angular/compiler": "npm:@angular/compiler@2.0.0-rc.4",
|
"@angular/compiler": "npm:@angular/compiler@2.0.0-rc.5",
|
||||||
"@angular/core": "npm:@angular/core@2.0.0-rc.4",
|
"@angular/core": "npm:@angular/core@2.0.0-rc.5",
|
||||||
"@angular/platform-browser": "npm:@angular/platform-browser@2.0.0-rc.4",
|
"@angular/platform-browser": "npm:@angular/platform-browser@2.0.0-rc.5",
|
||||||
"process": "github:jspm/nodelibs-process@0.1.2"
|
"process": "github:jspm/nodelibs-process@0.1.2"
|
||||||
},
|
},
|
||||||
"npm:@angular/platform-browser@2.0.0-rc.4": {
|
"npm:@angular/platform-browser@2.0.0-rc.5": {
|
||||||
"@angular/common": "npm:@angular/common@2.0.0-rc.4",
|
"@angular/common": "npm:@angular/common@2.0.0-rc.5",
|
||||||
"@angular/compiler": "npm:@angular/compiler@2.0.0-rc.4",
|
"@angular/compiler": "npm:@angular/compiler@2.0.0-rc.5",
|
||||||
"@angular/core": "npm:@angular/core@2.0.0-rc.4",
|
"@angular/core": "npm:@angular/core@2.0.0-rc.5",
|
||||||
"process": "github:jspm/nodelibs-process@0.1.2"
|
"process": "github:jspm/nodelibs-process@0.1.2"
|
||||||
},
|
},
|
||||||
"npm:amdefine@1.0.0": {
|
"npm:amdefine@1.0.0": {
|
||||||
|
@ -705,6 +705,11 @@ System.config({
|
||||||
"fs": "github:jspm/nodelibs-fs@0.1.2",
|
"fs": "github:jspm/nodelibs-fs@0.1.2",
|
||||||
"vm": "github:jspm/nodelibs-vm@0.1.0"
|
"vm": "github:jspm/nodelibs-vm@0.1.0"
|
||||||
},
|
},
|
||||||
|
"npm:process@0.11.8": {
|
||||||
|
"assert": "github:jspm/nodelibs-assert@0.1.0",
|
||||||
|
"fs": "github:jspm/nodelibs-fs@0.1.2",
|
||||||
|
"vm": "github:jspm/nodelibs-vm@0.1.0"
|
||||||
|
},
|
||||||
"npm:public-encrypt@4.0.0": {
|
"npm:public-encrypt@4.0.0": {
|
||||||
"bn.js": "npm:bn.js@4.11.4",
|
"bn.js": "npm:bn.js@4.11.4",
|
||||||
"browserify-rsa": "npm:browserify-rsa@4.0.1",
|
"browserify-rsa": "npm:browserify-rsa@4.0.1",
|
||||||
|
@ -934,6 +939,10 @@ System.config({
|
||||||
"npm:zone.js@0.6.12": {
|
"npm:zone.js@0.6.12": {
|
||||||
"buffer": "github:jspm/nodelibs-buffer@0.1.0",
|
"buffer": "github:jspm/nodelibs-buffer@0.1.0",
|
||||||
"process": "github:jspm/nodelibs-process@0.1.2"
|
"process": "github:jspm/nodelibs-process@0.1.2"
|
||||||
|
},
|
||||||
|
"npm:zone.js@0.6.14": {
|
||||||
|
"buffer": "github:jspm/nodelibs-buffer@0.1.0",
|
||||||
|
"process": "github:jspm/nodelibs-process@0.1.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,25 +1,33 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import {setBaseTestProviders} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
|
import {BrowserDynamicTestingModule, platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing';
|
||||||
import { OptionsService, RedocEventsService, Hash, ScrollService, MenuService } from '../lib/services/index';
|
import { OptionsService, RedocEventsService, MenuService,
|
||||||
|
ScrollService, Hash, WarningsService } from '../lib/services/index';
|
||||||
import { SpecManager } from '../lib/utils/SpecManager';
|
import { SpecManager } from '../lib/utils/SpecManager';
|
||||||
import { provide } from '@angular/core';
|
import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter';
|
||||||
|
import { REDOC_PIPES } from '../lib/utils/pipes';
|
||||||
|
import { REDOC_COMMON_DIRECTIVES } from '../lib/shared/components/index';
|
||||||
|
import { REDOC_DIRECTIVES } from '../lib/components/index';
|
||||||
|
|
||||||
import {
|
TestBed.initTestEnvironment(
|
||||||
TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
|
BrowserDynamicTestingModule,
|
||||||
TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS
|
platformBrowserDynamicTesting()
|
||||||
} from '@angular/platform-browser-dynamic/testing';
|
);
|
||||||
|
|
||||||
setBaseTestProviders(
|
beforeEach( () => {
|
||||||
[
|
TestBed.configureTestingModule({
|
||||||
TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
|
providers: [
|
||||||
provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}),
|
BrowserDomAdapter,
|
||||||
provide(OptionsService, {useClass: OptionsService}),
|
SpecManager,
|
||||||
provide(RedocEventsService, {useClass: RedocEventsService}),
|
BrowserDomAdapter,
|
||||||
provide(SpecManager, {useClass: SpecManager}),
|
RedocEventsService,
|
||||||
provide(Hash, {useClass: Hash}),
|
ScrollService,
|
||||||
provide(ScrollService, {useClass: ScrollService}),
|
Hash,
|
||||||
provide(MenuService, {useClass: MenuService})
|
MenuService,
|
||||||
|
WarningsService,
|
||||||
|
OptionsService
|
||||||
],
|
],
|
||||||
[TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS]);
|
declarations: [REDOC_PIPES, REDOC_DIRECTIVES, REDOC_COMMON_DIRECTIVES]
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user