diff --git a/.travis.yml b/.travis.yml index 208306e8..31d1a1e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,10 @@ branches: - releases matrix: include: - - env: JOB=e2e + - env: JOB=e2e-guru fast_finish: true allow_failures: - - env: JOB=e2e + - env: JOB=e2e-guru env: global: - GH_REF: github.com/Rebilly/ReDoc.git @@ -41,16 +41,16 @@ deploy: secure: PuhWLERrCEFmXmdFpw2OVFlqpOIVDmgwk5JUJOYaFdVCh/smp0+jZCQ4vrdFpuG96rnDVirD+A8xvW6NgsNNaRthLgOB/LRdFN69rU6Gvn3At6wlnC55t5dlhxPvCfnzJcHVBLXX4EmMkjnZqDg2uczXTzPodr3FnQJNuXmP8B33fzDVLyHccvXZ90abwXWVrgRIXPU28niqCR8DOC2OTzs7wqz+BLNkYDRRbyYXsg62HWuD33x5iof5IqBmhzBt3usCGmF3QGcgHrXHdZw3sZnit8+Bua++3KrXR0x6HGXXN1AoXVmCAkCa5OTQ5R3tCRxiJN3P2KLnvWeZR74sTFkovJB/6pGCvbJ/c7Wnuw6sD7SgOUBD359ULB6lAf5OnxBLoNebX4JxxVXF+zA4E3Bl44VxkzDpPWc15xqBPMB5vBREzMVmJ5mExn2s5cmLQjADbl9h0y6gZnhnNJ+iTmqtrVyM0ZkF2rPrzrTdGD+ULmRIlTMkdD1bh+/TJ3RdXT3P4/zNUJmiNnvgnnJVYYvsGaXWF+7uCVHT/8k2RsoSHqgkqh0gkDqGSwVix55y5mC7T2Vk9lMBhm6MvFJXaonOX0kxJS4EDQ3plPd6/ybG+TLhwggYnQ8o9msU5Nt6FpUShKiezjKurIhbQZdwlVivX3tahjW2QjNDO58xGgY= on: tags: true - condition: $JOB != e2e + condition: $JOB != e2e-guru - skip_cleanup: true provider: script script: npm run branch-release on: branch: master - condition: $JOB != e2e + condition: $JOB != e2e-guru - skip_cleanup: true provider: script script: npm run deploy on: tags: true - condition: $JOB != e2e + condition: $JOB != e2e-guru diff --git a/build/prepare_deploy.sh b/build/prepare_deploy.sh index f180a36e..71a8562b 100755 --- a/build/prepare_deploy.sh +++ b/build/prepare_deploy.sh @@ -8,7 +8,7 @@ git reset --hard git fetch origin gh-pages:gh-pages git checkout gh-pages cp -R ../releases/* . -git checkout master +git checkout @{-1} cd - # build diff --git a/build/run_tests.sh b/build/run_tests.sh index 308641bf..6d05f49d 100755 --- a/build/run_tests.sh +++ b/build/run_tests.sh @@ -1,6 +1,8 @@ #!/bin/bash -if [ "$JOB" = "e2e" ]; then +if [ "$JOB" = "e2e-guru" ]; then npm run e2e else npm run unit + echo "Starting Basic E2E" + npm run e2e fi diff --git a/build/tasks/build.js b/build/tasks/build.js index 69fc44a9..5361d12c 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -41,6 +41,7 @@ gulp.task('inlineTemplates', ['sass'], function() { var JS_DEV_DEPS = [ 'lib/utils/browser-update.js', 'node_modules/zone.js/dist/zone.js', + 'node_modules/zone.js/dist/long-stack-trace-zone.js', 'node_modules/reflect-metadata/Reflect.js', 'node_modules/babel-polyfill/dist/polyfill.js' ]; diff --git a/lib/components/ApiInfo/api-info.js b/lib/components/ApiInfo/api-info.js index 8fd9391c..89d39f6d 100644 --- a/lib/components/ApiInfo/api-info.js +++ b/lib/components/ApiInfo/api-info.js @@ -1,22 +1,22 @@ 'use strict'; -import {SchemaManager, RedocComponent, BaseComponent} from '../base'; -import OptionsManager from '../../options'; +import { SchemaManager, RedocComponent, BaseComponent } from '../base'; +import { OptionsService } from '../../services/index'; @RedocComponent({ selector: 'api-info', styleUrls: ['./lib/components/ApiInfo/api-info.css'], templateUrl: './lib/components/ApiInfo/api-info.html' }) -@Reflect.metadata('parameters', [[SchemaManager], [OptionsManager]]) -export default class ApiInfo extends BaseComponent { - constructor(schemaMgr, optionsMgr) { +@Reflect.metadata('parameters', [[SchemaManager], [OptionsService]]) +export class ApiInfo extends BaseComponent { + constructor(schemaMgr, optionsService) { super(schemaMgr); - this.optionsMgr = optionsMgr; + this.optionsService = optionsService; } prepareModel() { this.data = this.componentSchema.info; - this.specUrl = this.optionsMgr.options.specUrl; + this.specUrl = this.optionsService.options.specUrl; } } diff --git a/lib/components/ApiInfo/api-info.scss b/lib/components/ApiInfo/api-info.scss index b7e81ba2..762471b9 100644 --- a/lib/components/ApiInfo/api-info.scss +++ b/lib/components/ApiInfo/api-info.scss @@ -1,4 +1,4 @@ -@import '../../common/styles/variables'; +@import '../../shared/styles/variables'; .api-info-header { font-weight: normal; diff --git a/lib/components/ApiInfo/api-info.spec.js b/lib/components/ApiInfo/api-info.spec.js index 87bcbc0e..a9c2d990 100644 --- a/lib/components/ApiInfo/api-info.spec.js +++ b/lib/components/ApiInfo/api-info.spec.js @@ -1,22 +1,23 @@ 'use strict'; import { getChildDebugElement } from 'tests/helpers'; -import {Component, provide} from 'angular2/core'; +import { Component, provide } from '@angular/core'; import { - TestComponentBuilder, - async, inject, + async, beforeEach, beforeEachProviders, it -} from 'angular2/testing'; +} from '@angular/core/testing'; -import ApiInfo from 'lib/components/ApiInfo/api-info'; +import { TestComponentBuilder } from '@angular/compiler/testing'; + +import { ApiInfo } from 'lib/components/ApiInfo/api-info'; import SchemaManager from 'lib/utils/SchemaManager'; -import OptionsManager from 'lib/options'; +import { OptionsService } from 'lib/services/index'; -let optsMgr = new OptionsManager(); +let optionsService = new OptionsService(); describe('Redoc components', () => { describe('ApiInfo Component', () => { @@ -25,7 +26,7 @@ describe('Redoc components', () => { let fixture; beforeEachProviders(() => [ provide(SchemaManager, {useValue: new SchemaManager()}), - provide(OptionsManager, {useValue: optsMgr}) + provide(OptionsService, {useValue: optionsService}) ]); beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => { @@ -39,7 +40,9 @@ describe('Redoc components', () => { component = getChildDebugElement(fixture.debugElement, 'api-info').componentInstance; fixture.detectChanges(); done(); - }, err => done.fail(err)); + }, err => { + done.fail(err); + }); }); diff --git a/lib/components/ApiLogo/api-logo.js b/lib/components/ApiLogo/api-logo.js index 46db79dd..dcf5a0bc 100644 --- a/lib/components/ApiLogo/api-logo.js +++ b/lib/components/ApiLogo/api-logo.js @@ -7,7 +7,7 @@ import {RedocComponent, BaseComponent} from '../base'; styleUrls: ['./lib/components/ApiLogo/api-logo.css'], templateUrl: './lib/components/ApiLogo/api-logo.html' }) -export default class ApiLogo extends BaseComponent { +export class ApiLogo extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/ApiLogo/api-logo.scss b/lib/components/ApiLogo/api-logo.scss index 1e16b41e..7f78e62b 100644 --- a/lib/components/ApiLogo/api-logo.scss +++ b/lib/components/ApiLogo/api-logo.scss @@ -1,4 +1,4 @@ -@import '../../common/styles/variables'; +@import '../../shared/styles/variables'; img { max-height: 150px; diff --git a/lib/components/ApiLogo/api-logo.spec.js b/lib/components/ApiLogo/api-logo.spec.js index 946f36c8..a156aacb 100644 --- a/lib/components/ApiLogo/api-logo.spec.js +++ b/lib/components/ApiLogo/api-logo.spec.js @@ -1,18 +1,19 @@ 'use strict'; import { getChildDebugElement } from 'tests/helpers'; -import {Component, provide} from 'angular2/core'; +import {Component, provide} from '@angular/core'; import { - TestComponentBuilder, - async, inject, + async, beforeEach, beforeEachProviders, it -} from 'angular2/testing'; +} from '@angular/core/testing'; -import ApiLogo from 'lib/components/ApiLogo/api-logo'; +import { TestComponentBuilder } from '@angular/compiler/testing'; + +import { ApiLogo } from 'lib/components/ApiLogo/api-logo'; import SchemaManager from 'lib/utils/SchemaManager'; diff --git a/lib/components/JsonSchema/json-schema-common.scss b/lib/components/JsonSchema/json-schema-common.scss index 4b2d2953..ddcb9656 100644 --- a/lib/components/JsonSchema/json-schema-common.scss +++ b/lib/components/JsonSchema/json-schema-common.scss @@ -1,4 +1,4 @@ -@import '../../common/styles/variables'; +@import '../../shared/styles/variables'; $lines-width: 1px; $bullet-size: 1px; $cell-spacing: 25px; diff --git a/lib/components/JsonSchema/json-schema-lazy.js b/lib/components/JsonSchema/json-schema-lazy.js index 13457319..d532ef6a 100644 --- a/lib/components/JsonSchema/json-schema-lazy.js +++ b/lib/components/JsonSchema/json-schema-lazy.js @@ -1,11 +1,11 @@ 'use strict'; -import {Component, ElementRef, ViewContainerRef} from 'angular2/core'; -import {CORE_DIRECTIVES} from 'angular2/common'; -import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader'; +import { Component, ElementRef, ViewContainerRef } from '@angular/core'; +import { CORE_DIRECTIVES } from '@angular/common'; +import { DynamicComponentLoader } from '@angular/core'; -import JsonSchema from './json-schema'; -import OptionsManager from '../../options'; +import { JsonSchema } from './json-schema'; +import { OptionsService } from '../../services/index'; import SchemaManager from '../../utils/SchemaManager'; @@ -18,14 +18,15 @@ var cache = {}; template: '', directives: [CORE_DIRECTIVES] }) -@Reflect.metadata('parameters', [[SchemaManager], [ViewContainerRef], [ElementRef], [DynamicComponentLoader], [OptionsManager]]) -export default class JsonSchemaLazy { +@Reflect.metadata('parameters', [[SchemaManager], [ViewContainerRef], [ + ElementRef], [DynamicComponentLoader], [OptionsService]]) +export class JsonSchemaLazy { - constructor(schemaMgr, viewRef, elementRef, dcl, optionsMgr) { + constructor(schemaMgr, viewRef, elementRef, dcl, optionsService) { this.viewRef = viewRef; this.elementRef = elementRef; this.dcl = dcl; - this.optionsMgr = optionsMgr; + this.optionsService = optionsService; this.schemaMgr = schemaMgr; } @@ -35,13 +36,17 @@ export default class JsonSchemaLazy { } load() { - if (this.optionsMgr.options.disableLazySchemas) return; + if (this.optionsService.options.disableLazySchemas) return; if (this.loaded) return; if (this.pointer) { this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => { this.initComponent(compRef); // trigger change detection - compRef.hostView.changeDetectorRef.detectChanges(); + if (compRef.changeDetectorRef) { + compRef.changeDetectorRef.detectChanges(); + } else { + compRef.hostView.changeDetectorRef.detectChanges(); + } }); } this.loaded = true; @@ -60,7 +65,11 @@ export default class JsonSchemaLazy { if ($element.querySelector('.discriminator-wrap')) { this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => { this.initComponent(compRef); - compRef.hostView.changeDetectorRef.detectChanges(); + if (compRef.changeDetectorRef) { + compRef.changeDetectorRef.detectChanges(); + } else { + compRef.hostView.changeDetectorRef.detectChanges(); + } }); return; } @@ -70,7 +79,11 @@ export default class JsonSchemaLazy { } else { cache[this.pointer] = this.dcl.loadNextToLocation(JsonSchema, this.viewRef).then((compRef) => { this.initComponent(compRef); - compRef.hostView.changeDetectorRef.detectChanges(); + if (compRef.changeDetectorRef) { + compRef.changeDetectorRef.detectChanges(); + } else { + compRef.hostView.changeDetectorRef.detectChanges(); + } return compRef; }); } diff --git a/lib/components/JsonSchema/json-schema-lazy.spec.js b/lib/components/JsonSchema/json-schema-lazy.spec.js index debc622c..5e09b679 100644 --- a/lib/components/JsonSchema/json-schema-lazy.spec.js +++ b/lib/components/JsonSchema/json-schema-lazy.spec.js @@ -1,21 +1,23 @@ 'use strict'; import { getChildDebugElement } from 'tests/helpers'; -import {Component, provide} from 'angular2/core'; -import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader'; -import {BrowserDomAdapter} from 'angular2/platform/browser'; +import { Component, provide } from '@angular/core'; +import { DynamicComponentLoader } from '@angular/core'; +import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter'; import { - TestComponentBuilder, inject, beforeEach, beforeEachProviders, it -} from 'angular2/testing'; +} from '@angular/core/testing'; -import JsonSchemaLazy from 'lib/components/JsonSchema/json-schema-lazy'; +import { TestComponentBuilder } from '@angular/compiler/testing'; + + +import { JsonSchemaLazy } from 'lib/components/JsonSchema/json-schema-lazy'; import SchemaManager from 'lib/utils/SchemaManager'; -import OptionsManager from 'lib/options'; +import { OptionsService } from 'lib/services/index'; describe('Redoc components', () => { describe('JsonSchemaLazy Component', () => { @@ -31,7 +33,7 @@ describe('Redoc components', () => { beforeEachProviders(() => [ provide(SchemaManager, {useValue: schemaMgr}), provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}), - provide(OptionsManager, {useClass: OptionsManager}) + provide(OptionsService, {useClass: OptionsService}) ]); beforeEach(inject([TestComponentBuilder, DynamicComponentLoader], (tcb, dcl) => { builder = tcb; diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index 8ab92146..a4deef6c 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -1,9 +1,9 @@ 'use strict'; -import {ElementRef} from 'angular2/core'; +import { ElementRef } from '@angular/core'; -import {RedocComponent, BaseComponent, SchemaManager} from '../base'; -import {DropDown} from '../../common/components/DropDown/dropdown'; +import { RedocComponent, BaseComponent, SchemaManager } from '../base'; +import { DropDown } from '../../shared/components/index'; import JsonPointer from '../../utils/JsonPointer'; @RedocComponent({ @@ -14,7 +14,7 @@ import JsonPointer from '../../utils/JsonPointer'; inputs: ['isArray', 'final', 'nestOdd', 'childFor', 'skipReadOnly'] }) @Reflect.metadata('parameters', [[SchemaManager], [ElementRef]]) -export default class JsonSchema extends BaseComponent { +export class JsonSchema extends BaseComponent { constructor(schemaMgr, elementRef) { super(schemaMgr); this.$element = elementRef.nativeElement; @@ -109,7 +109,7 @@ export default class JsonSchema extends BaseComponent { props = props || []; if (schema.additionalProperties && schema.additionalProperties !== false) { - let propsSchema = this.prepareAdditionalProperties(schema.additionalProperties); + let propsSchema = this.prepareAdditionalProperties(schema); propsSchema._additional = true; props.push(propsSchema); } @@ -126,8 +126,9 @@ export default class JsonSchema extends BaseComponent { } prepareAdditionalProperties(schema) { - return JsonSchema.injectPropertyData(schema, ' *', - JsonPointer.join(schema._pointer || this.pointer, ['additionalProperties'])); + var addProps = schema.additionalProperties; + return JsonSchema.injectPropertyData(addProps, ' *', + JsonPointer.join(addProps._pointer || schema._pointer || this.pointer, ['additionalProperties'])); } static injectPropertyData(propertySchema, propertyName, propPointer) { diff --git a/lib/components/JsonSchema/json-schema.spec.js b/lib/components/JsonSchema/json-schema.spec.js index 50a4bcb6..dcca663f 100644 --- a/lib/components/JsonSchema/json-schema.spec.js +++ b/lib/components/JsonSchema/json-schema.spec.js @@ -1,18 +1,19 @@ 'use strict'; -import { getChildDebugElement } from 'tests/helpers'; -import {Component, provide} from 'angular2/core'; -import OptionsManager from 'lib/options'; - +import { Component, provide } from '@angular/core'; import { - TestComponentBuilder, inject, beforeEach, beforeEachProviders, it -} from 'angular2/testing'; +} from '@angular/core/testing'; +import { TestComponentBuilder } from '@angular/compiler/testing'; -import JsonSchema from 'lib/components/JsonSchema/json-schema'; +import { OptionsService } from 'lib/services/index'; +import { getChildDebugElement } from 'tests/helpers'; + + +import { JsonSchema } from 'lib/components/JsonSchema/json-schema'; import SchemaManager from 'lib/utils/SchemaManager'; describe('Redoc components', () => { @@ -23,7 +24,7 @@ describe('Redoc components', () => { let fixture; beforeEachProviders(() => [ provide(SchemaManager, {useValue: schemaMgr}), - provide(OptionsManager, {useClass: OptionsManager}) + provide(OptionsService, {useClass: OptionsService}) ]); beforeEach(inject([TestComponentBuilder], (tcb) => { builder = tcb; diff --git a/lib/components/Method/method.html b/lib/components/Method/method.html index f3453aff..1fdb449f 100644 --- a/lib/components/Method/method.html +++ b/lib/components/Method/method.html @@ -16,11 +16,11 @@
Definition
{{data.httpMethod}}
- {{data.apiUrl}} {{data.path}} + {{data.apiUrl}}{{data.path}}

- +
diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js index 89757c5f..0070788c 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.js @@ -1,22 +1,22 @@ 'use strict'; -import {JsonPointer} from '../../utils/JsonPointer'; -import {RedocComponent, BaseComponent} from '../base'; +import { JsonPointer } from '../../utils/JsonPointer'; +import { RedocComponent, BaseComponent } from '../base'; -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 { 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'; @RedocComponent({ selector: 'method', templateUrl: './lib/components/Method/method.html', styleUrls: ['./lib/components/Method/method.css'], - directives: [ParamsList, ResponsesList, ResponsesSamples, SchemaSample, RequestSamples], + directives: [ ParamsList, ResponsesList, ResponsesSamples, SchemaSample, RequestSamples ], inputs: ['tag'] }) -export default class Method extends BaseComponent { +export class Method extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/Method/method.scss b/lib/components/Method/method.scss index f3cec22a..ea625f20 100644 --- a/lib/components/Method/method.scss +++ b/lib/components/Method/method.scss @@ -1,5 +1,5 @@ -@import '../../common/styles/variables'; -@import '../../common/styles/share-link'; +@import '../../shared/styles/variables'; +@import '../../shared/styles/share-link'; :host { padding-bottom: 100px; diff --git a/lib/components/Method/method.spec.js b/lib/components/Method/method.spec.js index 89d5ad1b..dd17c099 100644 --- a/lib/components/Method/method.spec.js +++ b/lib/components/Method/method.spec.js @@ -1,21 +1,21 @@ 'use strict'; -import { getChildDebugElement } from 'tests/helpers'; -import {Component, provide} from 'angular2/core'; -import {BrowserDomAdapter} from 'angular2/platform/browser'; - +import { Component, provide } from '@angular/core'; +import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter'; import { - TestComponentBuilder, - async, inject, + async, beforeEach, beforeEachProviders, it -} from 'angular2/testing'; +} from '@angular/core/testing'; +import { TestComponentBuilder } from '@angular/compiler/testing'; -import Method from 'lib/components/Method/method'; +import { getChildDebugElement } from 'tests/helpers'; + +import { Method } from 'lib/components/Method/method'; import SchemaManager from 'lib/utils/SchemaManager'; -import OptionsManager from 'lib/options'; +import { OptionsService, RedocEventsService } from 'lib/services/index'; describe('Redoc components', () => { describe('Method Component', () => { @@ -24,7 +24,8 @@ describe('Redoc components', () => { beforeEachProviders(() => [ provide(SchemaManager, {useValue: new SchemaManager()}), provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}), - provide(OptionsManager, {useClass: OptionsManager}) + provide(OptionsService, {useClass: OptionsService}), + provide(RedocEventsService, {useClass: RedocEventsService}) ]); beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => { builder = tcb; diff --git a/lib/components/MethodsList/methods-list.js b/lib/components/MethodsList/methods-list.js index 32998a4f..c9a55f3f 100644 --- a/lib/components/MethodsList/methods-list.js +++ b/lib/components/MethodsList/methods-list.js @@ -1,17 +1,18 @@ 'use strict'; -import {RedocComponent, BaseComponent} from '../base'; -import Method from '../Method/method'; -import {EncodeURIComponentPipe} from '../../utils/pipes'; +import { forwardRef } from '@angular/core'; +import { RedocComponent, BaseComponent } from '../base'; +import { Method } from '../Method/method'; +import { EncodeURIComponentPipe } from '../../utils/pipes'; @RedocComponent({ selector: 'methods-list', templateUrl: './lib/components/MethodsList/methods-list.html', styleUrls: ['./lib/components/MethodsList/methods-list.css'], - directives: [Method], - pipes: [EncodeURIComponentPipe] + directives: [ forwardRef(() => Method) ], + pipes: [ EncodeURIComponentPipe ] }) -export default class MethodsList extends BaseComponent { +export class MethodsList extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); diff --git a/lib/components/MethodsList/methods-list.scss b/lib/components/MethodsList/methods-list.scss index c4d64f39..ff1465c3 100644 --- a/lib/components/MethodsList/methods-list.scss +++ b/lib/components/MethodsList/methods-list.scss @@ -1,5 +1,5 @@ -@import '../../common/styles/variables'; -@import '../../common/styles/share-link'; +@import '../../shared/styles/variables'; +@import '../../shared/styles/share-link'; .tag-info { padding: 40px; diff --git a/lib/components/MethodsList/methods-list.spec.js b/lib/components/MethodsList/methods-list.spec.js index 22cba67b..76aaccbc 100644 --- a/lib/components/MethodsList/methods-list.spec.js +++ b/lib/components/MethodsList/methods-list.spec.js @@ -1,20 +1,20 @@ 'use strict'; -import { getChildDebugElement } from 'tests/helpers'; -import {Component, provide} from 'angular2/core'; -import OptionsManager from 'lib/options'; -import {BrowserDomAdapter} from 'angular2/platform/browser'; - +import { Component, provide } from '@angular/core'; +import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter'; import { - TestComponentBuilder, inject, async, beforeEach, beforeEachProviders, it -} from 'angular2/testing'; +} from '@angular/core/testing'; +import { TestComponentBuilder } from '@angular/compiler/testing'; -import MethodsList from 'lib/components/MethodsList/methods-list'; +import { getChildDebugElement } from 'tests/helpers'; + +import { OptionsService, RedocEventsService } from 'lib/services/index'; +import { MethodsList } from 'lib/components/MethodsList/methods-list'; import SchemaManager from 'lib/utils/SchemaManager'; describe('Redoc components', () => { @@ -24,8 +24,9 @@ describe('Redoc components', () => { let fixture; beforeEachProviders(() => [ provide(SchemaManager, {useValue: new SchemaManager()}), - provide(OptionsManager, {useClass: OptionsManager}), - provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}) + provide(OptionsService, {useClass: OptionsService}), + provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}), + provide(RedocEventsService, {useClass: RedocEventsService}) ]); beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => { builder = tcb; @@ -56,11 +57,9 @@ describe('Redoc components', () => { }); }); -/** Test component that contains an ApiInfo. */ @Component({ selector: 'test-app', - directives: [MethodsList], - providers: [SchemaManager], + directives: [ MethodsList ], template: `` }) diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.js index e664af1b..51486cfc 100644 --- a/lib/components/ParamsList/params-list.js +++ b/lib/components/ParamsList/params-list.js @@ -1,8 +1,8 @@ 'use strict'; -import {RedocComponent, BaseComponent} from '../base'; -import JsonSchema from '../JsonSchema/json-schema'; -import JsonSchemaLazy from '../JsonSchema/json-schema-lazy'; +import { RedocComponent, BaseComponent } from '../base'; +import { JsonSchema } from '../JsonSchema/json-schema'; +import {JsonSchemaLazy} from '../JsonSchema/json-schema-lazy'; function safePush(obj, prop, item) { if (!obj[prop]) obj[prop] = []; @@ -15,7 +15,7 @@ function safePush(obj, prop, item) { styleUrls: ['./lib/components/ParamsList/params-list.css'], directives: [JsonSchema, JsonSchemaLazy] }) -export default class ParamsList extends BaseComponent { +export class ParamsList extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/ParamsList/params-list.scss b/lib/components/ParamsList/params-list.scss index 211c04b4..f7b63f46 100644 --- a/lib/components/ParamsList/params-list.scss +++ b/lib/components/ParamsList/params-list.scss @@ -1,4 +1,4 @@ -@import '../../common/styles/variables'; +@import '../../shared/styles/variables'; $hint-color: #999999; diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index 3858d92e..76669ded 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -1,20 +1,20 @@ 'use strict'; -import {ChangeDetectionStrategy, provide, enableProdMode} from 'angular2/core'; -import {ElementRef} from 'angular2/core'; -import {BrowserDomAdapter, bootstrap} from 'angular2/platform/browser'; -import detectScollParent from 'scrollparent'; -import {RedocComponent, BaseComponent} from '../base'; +import { provide, enableProdMode, ElementRef } from '@angular/core'; +import { bootstrap } from '@angular/platform-browser-dynamic'; +import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter'; +import { RedocComponent, BaseComponent } from '../base'; + +import { ApiInfo } from '../ApiInfo/api-info'; +import { ApiLogo } from '../ApiLogo/api-logo'; +import { MethodsList } from '../MethodsList/methods-list'; +import { SideMenu } from '../SideMenu/side-menu'; + +import { StickySidebar } from '../../shared/components/index'; import SchemaManager from '../../utils/SchemaManager'; +import { OptionsService, RedocEventsService } from '../../services/index'; -import ApiInfo from '../ApiInfo/api-info'; -import ApiLogo from '../ApiLogo/api-logo'; -import MethodsList from '../MethodsList/methods-list'; -import SideMenu from '../SideMenu/side-menu'; -import StickySidebar from '../../common/components/StickySidebar/sticky-sidebar'; -import OptionsManager from '../../options'; -import {redocEvents} from '../../events'; - +import detectScollParent from 'scrollparent'; import './redoc-loading-styles.css!css'; var dom = new BrowserDomAdapter(); @@ -24,23 +24,30 @@ var _modeLocked = false; selector: 'redoc', providers: [ SchemaManager, - BrowserDomAdapter + BrowserDomAdapter, + RedocEventsService ], templateUrl: './lib/components/Redoc/redoc.html', styleUrls: ['./lib/components/Redoc/redoc.css'], - directives: [ApiInfo, ApiLogo, MethodsList, SideMenu, StickySidebar], - changeDetection: ChangeDetectionStrategy.Default + directives: [ ApiInfo, ApiLogo, MethodsList, SideMenu, StickySidebar ] }) @Reflect.metadata('parameters', [ - [SchemaManager], [OptionsManager], [ElementRef]]) -export default class Redoc extends BaseComponent { - constructor(schemaMgr, optionsMgr, elementRef) { + [SchemaManager], [OptionsService], [ElementRef], [RedocEventsService]]) +export class Redoc extends BaseComponent { + constructor(schemaMgr, optionsMgr, elementRef, events) { super(schemaMgr); this.element = elementRef.nativeElement; //parse options (top level component doesn't support inputs) optionsMgr.parseOptions( this.element ); optionsMgr.options.$scrollParent = detectScollParent( this.element ); this.options = optionsMgr.options; + this.events = events; + } + + ngAfterViewInit() { + setTimeout( () => { + this.events.bootstrapped.next(); + }); } static showLoadingAnimation() { @@ -58,11 +65,11 @@ export default class Redoc extends BaseComponent { } static init(specUrl, options) { - var optionsMgr = new OptionsManager(); - optionsMgr.options = options; - optionsMgr.options.specUrl = optionsMgr.options.specUrl || specUrl; + var optionsService = new OptionsService(dom); + optionsService.options = options; + optionsService.options.specUrl = optionsService.options.specUrl || specUrl; var providers = [ - provide(OptionsManager, {useValue: optionsMgr}) + provide(OptionsService, {useValue: optionsService}) ]; if (Redoc.appRef) { @@ -71,7 +78,7 @@ export default class Redoc extends BaseComponent { Redoc.showLoadingAnimation(); return SchemaManager.instance().load(specUrl) .then(() => { - if (!_modeLocked && !optionsMgr.options.debugMode) { + if (!_modeLocked && !optionsService.options.debugMode) { enableProdMode(); _modeLocked = true; } @@ -81,8 +88,6 @@ export default class Redoc extends BaseComponent { (appRef) => { Redoc.hideLoadingAnimation(); Redoc.appRef = appRef; - // setTimeout to allow cached elements to init - setTimeout(() => redocEvents.bootstrapped.next()); console.log('ReDoc bootstrapped!'); }, error => { diff --git a/lib/components/Redoc/redoc.scss b/lib/components/Redoc/redoc.scss index a446e4f8..048e4060 100644 --- a/lib/components/Redoc/redoc.scss +++ b/lib/components/Redoc/redoc.scss @@ -1,4 +1,4 @@ -@import '../../common/styles/variables'; +@import '../../shared/styles/variables'; :host { display: block; diff --git a/lib/components/Redoc/redoc.spec.js b/lib/components/Redoc/redoc.spec.js index b6bcaac6..d4cd8289 100644 --- a/lib/components/Redoc/redoc.spec.js +++ b/lib/components/Redoc/redoc.spec.js @@ -1,23 +1,24 @@ 'use strict'; import { getChildDebugElement } from 'tests/helpers'; -import {Component, ViewMetadata, provide} from 'angular2/core'; -import {BrowserDomAdapter} from 'angular2/platform/browser'; +import { Component, provide } from '@angular/core'; +import { BrowserDomAdapter } from '@angular/platform-browser/src/browser/browser_adapter'; import { - TestComponentBuilder, inject, async, beforeEach, beforeEachProviders, it -} from 'angular2/testing'; +} from '@angular/core/testing'; -import Redoc from 'lib/components/Redoc/redoc'; +import { TestComponentBuilder } from '@angular/compiler/testing'; + +import { Redoc } from 'lib/components/Redoc/redoc'; import SchemaManager from 'lib/utils/SchemaManager'; -import OptionsManager from 'lib/options'; +import { OptionsService } from 'lib/services/index'; -let optsMgr = new OptionsManager(); +let optsMgr = new OptionsService(new BrowserDomAdapter()); describe('Redoc components', () => { describe('Redoc Component', () => { @@ -25,7 +26,10 @@ describe('Redoc components', () => { beforeEachProviders(() => [ provide(SchemaManager, {useValue: new SchemaManager()}), provide(BrowserDomAdapter, {useValue: new BrowserDomAdapter()}), - provide(OptionsManager, {useValue: optsMgr}) + provide(OptionsService, {useValue: optsMgr}) + ]); + beforeEachProviders(() => [ + provide(OptionsService, {useValue: optsMgr}) ]); beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => { builder = tcb; @@ -49,62 +53,6 @@ describe('Redoc components', () => { done(); }, err => done.fail(err)); }); - - describe('Options', () => { - let component; - let fixture; - - function build(tmpl, cb) { - builder = builder.overrideView(TestApp, - new ViewMetadata({template: tmpl, directives: [Redoc]})); - builder.createAsync(TestApp).then(_fixture => { - fixture = _fixture; - component = getChildDebugElement(fixture.debugElement, 'redoc').componentInstance; - fixture.detectChanges(); - cb(); - }, err => cb(err)); - } - - afterEach(() => { - fixture.destroy(); - }); - - it('should parse numeric scrollYOffset', (done) => { - build(``, err => { - if (err) return done.fail(err); - component.options.scrollYOffset().should.be.equal(50); - done(); - }); - }); - - it('should parse selector scrollYOffset', (done) => { - build(`
- `, err => { - if (err) return done.fail(err); - component.options.scrollYOffset().should.be.equal(50); - done(); - }); - }); - - it('should return 0 for incorrect selector scrollYOffset', (done) => { - build(`
- `, err => { - if (err) return done.fail(err); - component.options.scrollYOffset().should.be.equal(0); - done(); - }); - }); - - it('should handle function scrollYOffset', (done) => { - optsMgr.options.scrollYOffset = () => 123; - build(``, err => { - if (err) return done.fail(err); - component.options.scrollYOffset().should.be.equal(123); - optsMgr.options.scrollYOffset = 0; - done(); - }); - }); - }); }); describe('Redoc init', () => { @@ -151,7 +99,7 @@ describe('Redoc components', () => { beforeEachProviders(() => [ provide(SchemaManager, {useValue: new SchemaManager()}), provide(BrowserDomAdapter, {useValue: new BrowserDomAdapter()}), - provide(OptionsManager, {useValue: optsMgr}) + provide(OptionsService, {useValue: optsMgr}) ]); beforeEach(async(inject([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => { builder = tcb; diff --git a/lib/components/RequestSamples/request-samples.html b/lib/components/RequestSamples/request-samples.html index 78bb0657..a11d9b1f 100644 --- a/lib/components/RequestSamples/request-samples.html +++ b/lib/components/RequestSamples/request-samples.html @@ -1,8 +1,8 @@ -
Request samples
- +
Request samples
+ - +

diff --git a/lib/components/RequestSamples/request-samples.js b/lib/components/RequestSamples/request-samples.js
index 032c0f98..96168c0e 100644
--- a/lib/components/RequestSamples/request-samples.js
+++ b/lib/components/RequestSamples/request-samples.js
@@ -1,49 +1,50 @@
 'use strict';
 
-import {ViewChildren, QueryList, ChangeDetectorRef, ChangeDetectionStrategy} from 'angular2/core';
+import { ViewChildren, QueryList } from '@angular/core';
 
-import {RedocComponent, BaseComponent, SchemaManager} from '../base';
+import { RedocComponent, BaseComponent, SchemaManager } from '../base';
 import JsonPointer from '../../utils/JsonPointer';
-import {Tabs, Tab} from '../../common/components/Tabs/tabs';
-import SchemaSample from '../SchemaSample/schema-sample';
-import {PrismPipe} from '../../utils/pipes';
-import {redocEvents} from '../../events';
+import { Tabs, Tab } from '../../shared/components/index';
+import { SchemaSample } from '../SchemaSample/schema-sample';
+import { PrismPipe } from '../../utils/pipes';
+import { RedocEventsService } from '../../services/index';
 
 @RedocComponent({
   selector: 'request-samples',
   templateUrl: './lib/components/RequestSamples/request-samples.html',
   styleUrls: ['./lib/components/RequestSamples/request-samples.css'],
   directives: [SchemaSample, Tabs, Tab],
-  inputs: ['bodySchemaPtr'],
-  pipes: [PrismPipe],
-  changeDetection: ChangeDetectionStrategy.OnPush
+  inputs: ['schemaPointer'],
+  pipes: [PrismPipe]
 })
-@Reflect.metadata('parameters', [[SchemaManager], [new ViewChildren(Tabs), QueryList], [ChangeDetectorRef]])
-export default class RequestSamples extends BaseComponent {
-  constructor(schemaMgr, tabs, changeDetector) {
+@Reflect.metadata('parameters', [[SchemaManager], [RedocEventsService], [new ViewChildren(Tabs), QueryList]])
+export class RequestSamples extends BaseComponent {
+  constructor(schemaMgr, events, childQuery) {
     super(schemaMgr);
-    tabs.changes.subscribe(_ => {
-      this.tabs = tabs.first;
-      this.subscribeForEvents(_);
+    childQuery.changes.subscribe(() => {
+      this.childTabs = childQuery.first;
     });
-    this.changeDetector = changeDetector;
+    this.events = events;
+  }
+
+  init() {
+    this.subscribeForEvents();
   }
 
   changeLangNotify(lang) {
-    redocEvents.samplesLanguageChanged.next(lang);
+    this.events.samplesLanguageChanged.next(lang);
   }
 
   subscribeForEvents() {
-    if (!this.tabs) return;
-    redocEvents.samplesLanguageChanged.subscribe((sampleLang) => {
-      this.tabs.selectyByTitle(sampleLang);
-      this.changeDetector.markForCheck();
+    this.events.samplesLanguageChanged.subscribe((sampleLang) => {
+      if (!this.childTabs) return;
+      this.childTabs.selectyByTitle(sampleLang);
     });
   }
 
   prepareModel() {
     this.data = {};
-    this.data.bodySchemaPtr = JsonPointer.join(this.bodySchemaPtr, 'schema');
+    this.data.schemaPointer = JsonPointer.join(this.schemaPointer, 'schema');
     this.data.samples = this.componentSchema['x-code-samples'] || [];
   }
 }
diff --git a/lib/components/RequestSamples/request-samples.scss b/lib/components/RequestSamples/request-samples.scss
index 333d0420..84569503 100644
--- a/lib/components/RequestSamples/request-samples.scss
+++ b/lib/components/RequestSamples/request-samples.scss
@@ -1,4 +1,4 @@
-@import '../../common/styles/variables';
+@import '../../shared/styles/variables';
 
 header {
     font-family: $headers-font;
diff --git a/lib/components/ResponsesList/responses-list.js b/lib/components/ResponsesList/responses-list.js
index 6c85d901..3830845c 100644
--- a/lib/components/ResponsesList/responses-list.js
+++ b/lib/components/ResponsesList/responses-list.js
@@ -2,11 +2,11 @@
 
 import {RedocComponent, BaseComponent, SchemaManager} from '../base';
 import JsonPointer from '../../utils/JsonPointer';
-import JsonSchema from '../JsonSchema/json-schema';
-import JsonSchemaLazy from '../JsonSchema/json-schema-lazy';
-import Zippy from '../../common/components/Zippy/zippy';
-import {statusCodeType} from '../../utils/helpers';
-import OptionsManager from '../../options';
+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 { OptionsService } from '../../services/index';
 
 function isNumeric(n) {
   return (!isNaN(parseFloat(n)) && isFinite(n));
@@ -18,8 +18,8 @@ function isNumeric(n) {
   styleUrls: ['./lib/components/ResponsesList/responses-list.css'],
   directives: [JsonSchema, Zippy, JsonSchemaLazy]
 })
-@Reflect.metadata('parameters', [[SchemaManager], [OptionsManager]])
-export default class ResponsesList extends BaseComponent {
+@Reflect.metadata('parameters', [[SchemaManager], [OptionsService]])
+export class ResponsesList extends BaseComponent {
   constructor(schemaMgr, optionsMgr) {
     super(schemaMgr);
     this.options = optionsMgr.options;
diff --git a/lib/components/ResponsesList/responses-list.scss b/lib/components/ResponsesList/responses-list.scss
index d9212b11..c63354c9 100644
--- a/lib/components/ResponsesList/responses-list.scss
+++ b/lib/components/ResponsesList/responses-list.scss
@@ -1,4 +1,4 @@
-@import '../../common/styles/variables';
+@import '../../shared/styles/variables';
 
 .responses-list-header {
   font-size: 18px;
diff --git a/lib/components/ResponsesSamples/responses-samples.js b/lib/components/ResponsesSamples/responses-samples.js
index db573f84..3515f5e9 100644
--- a/lib/components/ResponsesSamples/responses-samples.js
+++ b/lib/components/ResponsesSamples/responses-samples.js
@@ -1,10 +1,11 @@
 'use strict';
 
-import {RedocComponent, BaseComponent} from '../base';
+import { forwardRef } from '@angular/core';
+import { RedocComponent, BaseComponent } from '../base';
 import JsonPointer from '../../utils/JsonPointer';
-import {Tabs, Tab} from '../../common/components/Tabs/tabs';
-import SchemaSample from '../SchemaSample/schema-sample';
-import {statusCodeType} from '../../utils/helpers';
+import { Tabs, Tab } from '../../shared/components/index';
+import { SchemaSample } from '../index';
+import { statusCodeType } from '../../utils/helpers';
 
 
 function isNumeric(n) {
@@ -20,9 +21,9 @@ function hasExample(response) {
   selector: 'responses-samples',
   templateUrl: './lib/components/ResponsesSamples/responses-samples.html',
   styleUrls: ['./lib/components/ResponsesSamples/responses-samples.css'],
-  directives: [SchemaSample, Tabs, Tab]
+  directives: [forwardRef( ()=> SchemaSample), Tabs, Tab]
 })
-export default class ResponsesSamples extends BaseComponent {
+export class ResponsesSamples extends BaseComponent {
   constructor(schemaMgr) {
     super(schemaMgr);
   }
diff --git a/lib/components/ResponsesSamples/responses-samples.scss b/lib/components/ResponsesSamples/responses-samples.scss
index cb9ab0cd..1334dd8d 100644
--- a/lib/components/ResponsesSamples/responses-samples.scss
+++ b/lib/components/ResponsesSamples/responses-samples.scss
@@ -1,4 +1,4 @@
-@import '../../common/styles/variables';
+@import '../../shared/styles/variables';
 
 tab, tabs {
     display: block;
diff --git a/lib/components/SchemaSample/schema-sample.js b/lib/components/SchemaSample/schema-sample.js
index c0555c60..0c350ba1 100644
--- a/lib/components/SchemaSample/schema-sample.js
+++ b/lib/components/SchemaSample/schema-sample.js
@@ -1,11 +1,11 @@
 'use strict';
 
-import {ElementRef} from 'angular2/core';
+import { ElementRef } from '@angular/core';
 
 import SchemaSampler from 'json-schema-instantiator';
 
-import {JsonFormatter} from '../../utils/JsonFormatterPipe';
-import {RedocComponent, BaseComponent, SchemaManager} from '../base';
+import { RedocComponent, BaseComponent, SchemaManager } from '../base';
+import { JsonFormatter } from '../../utils/JsonFormatterPipe';
 
 @RedocComponent({
   selector: 'schema-sample',
@@ -14,7 +14,7 @@ import {RedocComponent, BaseComponent, SchemaManager} from '../base';
   styleUrls: ['./lib/components/SchemaSample/schema-sample.css']
 })
 @Reflect.metadata('parameters', [[SchemaManager], [ElementRef]])
-export default class SchemaSample extends BaseComponent {
+export class SchemaSample extends BaseComponent {
   constructor(schemaMgr, elementRef) {
     super(schemaMgr);
     this.element = elementRef.nativeElement;
diff --git a/lib/components/SchemaSample/schema-sample.scss b/lib/components/SchemaSample/schema-sample.scss
index 13463cca..ef191331 100644
--- a/lib/components/SchemaSample/schema-sample.scss
+++ b/lib/components/SchemaSample/schema-sample.scss
@@ -1,4 +1,4 @@
-@import '../../common/styles/variables';
+@import '../../shared/styles/variables';
 
 pre {
   background-color: transparent;
diff --git a/lib/components/SideMenu/side-menu.html b/lib/components/SideMenu/side-menu.html
index 429f7db7..a947fcc1 100644
--- a/lib/components/SideMenu/side-menu.html
+++ b/lib/components/SideMenu/side-menu.html
@@ -1,11 +1,11 @@
-
+
API Reference: {{activeCatCaption}} {{activeItemCaption}}
-
+