From c1f1944caeba84f48a5fb20c1cec5a8df93ea08f Mon Sep 17 00:00:00 2001 From: amanganiello Date: Thu, 22 Sep 2016 09:13:29 +0200 Subject: [PATCH 01/26] fix issue #116 --- README.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 63ef580d..84d44767 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,7 @@ Redoc.init('http://petstore.swagger.io/v2/swagger.json', { ```bash npm run build:sass ``` -- _(optional)_ Replace `demo/swagger.json` with your own schema +- _(optional)_ Replace `demo/swagger.yaml` with your own schema - Start the server `npm start` - Open `http://localhost:9000` diff --git a/package.json b/package.json index b803e2e9..384826a8 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,7 @@ "tslint": "^3.15.0-dev.0", "tslint-stylish": "^2.1.0-beta", "typescript": "^2.0.2", - "webpack": "^2.1.0-beta.21", + "webpack": "^2.1.0-beta.22", "webpack-dev-server": "^2.1.0-beta.2" }, "dependencies": { From 0c7357ac130fb9cc01f51717663e7df5e101500d Mon Sep 17 00:00:00 2001 From: amanganiello Date: Thu, 22 Sep 2016 09:57:44 +0200 Subject: [PATCH 02/26] test linux fix issue #116 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 384826a8..8b804226 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "build:prod": "npm run build:sass && npm run ngc && npm run webpack:prod", "build-dist": "npm run build:prod", "stats": "webpack --config build/webpack.prod.js --json > stats.json", - "start": "webpack-dev-server --config build/webpack.dev.js --content-base demo", + "start": "npm install webpack@2.1.0-beta.22 --save-dev && webpack-dev-server --config build/webpack.dev.js --content-base demo", "e2e-server": "http-server -p 3000 tests/e2e", "e2e-copy": "cp dist/redoc.min.js tests/e2e/", "webdriver": "webdriver-manager update", From 221fd7bf7b295f01c37f7f7cf2173725ac8696ae Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Tue, 18 Oct 2016 23:39:43 +0300 Subject: [PATCH 03/26] separate RedocModule from AppModule --- lib/app.module.ts | 13 +++++++++++++ lib/bootstrap.dev.ts | 4 ++-- lib/bootstrap.ts | 4 ++-- lib/redoc.module.ts | 4 ++-- 4 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 lib/app.module.ts diff --git a/lib/app.module.ts b/lib/app.module.ts new file mode 100644 index 00000000..37ee2c5a --- /dev/null +++ b/lib/app.module.ts @@ -0,0 +1,13 @@ +import { NgModule } from '@angular/core'; +import { BrowserModule } from '@angular/platform-browser'; + +import { RedocModule } from './redoc.module'; +import { Redoc } from './components/index'; + +@NgModule({ + imports: [ BrowserModule, RedocModule ], + bootstrap: [ Redoc ], + exports: [ Redoc ] +}) +export class AppModule { +} diff --git a/lib/bootstrap.dev.ts b/lib/bootstrap.dev.ts index f826b733..296618d7 100644 --- a/lib/bootstrap.dev.ts +++ b/lib/bootstrap.dev.ts @@ -1,6 +1,6 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; -import { RedocModule } from './redoc.module'; +import { AppModule } from './app.module'; export function bootstrapRedoc() { - return platformBrowserDynamic().bootstrapModule(RedocModule); + return platformBrowserDynamic().bootstrapModule(AppModule); } diff --git a/lib/bootstrap.ts b/lib/bootstrap.ts index d7439b26..c55ccecb 100644 --- a/lib/bootstrap.ts +++ b/lib/bootstrap.ts @@ -1,6 +1,6 @@ import { platformBrowser } from '@angular/platform-browser'; -import { RedocModuleNgFactory } from './redoc.module.ngfactory'; +import { AppModuleNgFactory } from './app.module.ngfactory'; export function bootstrapRedoc() { - return platformBrowser().bootstrapModuleFactory(RedocModuleNgFactory); + return platformBrowser().bootstrapModuleFactory(AppModuleNgFactory); } diff --git a/lib/redoc.module.ts b/lib/redoc.module.ts index 98f15729..a29e0951 100644 --- a/lib/redoc.module.ts +++ b/lib/redoc.module.ts @@ -1,5 +1,5 @@ import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; +import { CommonModule } from '@angular/common'; import { Redoc, REDOC_DIRECTIVES } from './components/index'; import { REDOC_COMMON_DIRECTIVES } from './shared/components/index'; @@ -10,7 +10,7 @@ import { OptionsService, RedocEventsService, MenuService, import { SpecManager } from './utils/SpecManager'; @NgModule({ - imports: [ BrowserModule ], + imports: [ CommonModule ], declarations: [ REDOC_DIRECTIVES, REDOC_COMMON_DIRECTIVES, REDOC_PIPES], bootstrap: [ Redoc ], providers: [ From 17e7bf9fd8898860f7d705a1fcbc60aa1e610c2e Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 23 Oct 2016 20:18:42 +0300 Subject: [PATCH 04/26] Refactor + minor fixes/optimizations --- lib/components/ApiInfo/api-info.spec.ts | 2 +- lib/components/ApiInfo/api-info.ts | 2 +- lib/components/ApiLogo/api-logo.spec.ts | 2 +- lib/components/JsonSchema/json-schema-lazy.ts | 26 ++-- lib/components/JsonSchema/json-schema.spec.ts | 2 +- lib/components/Method/method.spec.ts | 2 +- .../MethodsList/methods-list.spec.ts | 2 +- lib/components/Redoc/redoc.html | 6 +- lib/components/Redoc/redoc.spec.ts | 119 +----------------- lib/components/Redoc/redoc.ts | 96 +++++++------- .../RequestSamples/request-samples.ts | 15 +-- .../security-definitions.html | 2 + .../security-definitions.scss | 28 +++++ .../security-definitions.ts | 25 ++++ lib/components/SideMenu/side-menu.spec.ts | 2 +- lib/components/SideMenu/side-menu.ts | 1 - lib/components/base.spec.ts | 2 +- lib/components/base.ts | 2 +- lib/components/index.ts | 5 +- lib/index.ts | 4 +- lib/redoc.module.ts | 17 +-- lib/services/app-state.service.ts | 11 ++ lib/services/clipboard.service.ts | 3 +- lib/services/events.service.ts | 8 -- lib/services/hash.service.spec.ts | 21 ++-- lib/services/hash.service.ts | 39 +++--- lib/services/index.ts | 2 +- lib/services/menu.service.spec.ts | 17 +-- lib/services/menu.service.ts | 4 +- lib/services/schema-helper.serivce.spec.ts | 2 +- lib/services/schema-helper.service.ts | 2 +- .../schema-normalizer.service.spec.ts | 2 +- lib/services/schema-normalizer.service.ts | 2 +- lib/services/scroll.service.ts | 6 +- lib/utils/browser-update.js | 10 -- lib/utils/custom-error-handler.ts | 12 ++ lib/utils/helpers.js | 103 --------------- lib/utils/index.ts | 1 + lib/utils/{SpecManager.ts => spec-manager.ts} | 22 +++- tests/spec-bundle.js | 11 +- tests/unit/SpecManager.spec.ts | 2 +- 41 files changed, 251 insertions(+), 391 deletions(-) create mode 100644 lib/components/SecurityDefinitions/security-definitions.html create mode 100644 lib/components/SecurityDefinitions/security-definitions.scss create mode 100644 lib/components/SecurityDefinitions/security-definitions.ts create mode 100644 lib/services/app-state.service.ts delete mode 100644 lib/services/events.service.ts delete mode 100644 lib/utils/browser-update.js create mode 100644 lib/utils/custom-error-handler.ts delete mode 100644 lib/utils/helpers.js create mode 100644 lib/utils/index.ts rename lib/utils/{SpecManager.ts => spec-manager.ts} (91%) diff --git a/lib/components/ApiInfo/api-info.spec.ts b/lib/components/ApiInfo/api-info.spec.ts index 7f5bf1c8..4d0e6612 100644 --- a/lib/components/ApiInfo/api-info.spec.ts +++ b/lib/components/ApiInfo/api-info.spec.ts @@ -11,7 +11,7 @@ import { } from '@angular/core/testing'; import { ApiInfo } from './api-info'; -import { SpecManager } from '../../utils/SpecManager'; +import { SpecManager } from '../../utils/spec-manager'; describe('Redoc components', () => { describe('ApiInfo Component', () => { diff --git a/lib/components/ApiInfo/api-info.ts b/lib/components/ApiInfo/api-info.ts index 9847210a..00a301c6 100644 --- a/lib/components/ApiInfo/api-info.ts +++ b/lib/components/ApiInfo/api-info.ts @@ -12,7 +12,7 @@ import { OptionsService, MenuService } from '../../services/index'; export class ApiInfo extends BaseComponent implements OnInit { info: any = {}; specUrl: String; - constructor(specMgr:SpecManager, private optionsService:OptionsService, private menuServ: MenuService) { + constructor(specMgr:SpecManager, private optionsService: OptionsService) { super(specMgr); } diff --git a/lib/components/ApiLogo/api-logo.spec.ts b/lib/components/ApiLogo/api-logo.spec.ts index e4ba00c0..5ef98c1f 100644 --- a/lib/components/ApiLogo/api-logo.spec.ts +++ b/lib/components/ApiLogo/api-logo.spec.ts @@ -10,7 +10,7 @@ import { } from '@angular/core/testing'; import { ApiLogo } from './api-logo'; -import { SpecManager } from '../../utils/SpecManager'; +import { SpecManager } from '../../utils/spec-manager'; describe('Redoc components', () => { diff --git a/lib/components/JsonSchema/json-schema-lazy.ts b/lib/components/JsonSchema/json-schema-lazy.ts index 80dc3f63..4cfe9143 100644 --- a/lib/components/JsonSchema/json-schema-lazy.ts +++ b/lib/components/JsonSchema/json-schema-lazy.ts @@ -5,7 +5,7 @@ import { Component, ElementRef, ViewContainerRef, OnDestroy, Input, import { JsonSchema } from './json-schema'; import { OptionsService } from '../../services/options.service'; -import { SpecManager } from '../../utils/SpecManager'; +import { SpecManager } from '../../utils/spec-manager'; var cache = {}; @@ -38,7 +38,7 @@ export class JsonSchemaLazy implements OnDestroy, AfterViewInit { var componentFactory = this.resolver.resolveComponentFactory(JsonSchema); let contextInjector = this.location.parentInjector; let compRef = this.location.createComponent(componentFactory, null, contextInjector, null); - this.initComponent(compRef.instance); + this.projectComponentInputs(compRef.instance); this._renderer.setElementAttribute(compRef.location.nativeElement, 'class', this.location.element.nativeElement.className); compRef.changeDetectorRef.detectChanges(); this.loaded = true; @@ -58,24 +58,22 @@ export class JsonSchemaLazy implements OnDestroy, AfterViewInit { this.pointer = this.normalizePointer(); if (cache[this.pointer]) { let compRef = cache[this.pointer]; - setTimeout( ()=> { - let $element = compRef.location.nativeElement; + let $element = compRef.location.nativeElement; - // skip caching view with descendant schemas - // as it needs attached controller - if (!this.disableLazy && (compRef.instance.hasDescendants || compRef.instance._hasSubSchemas)) { - this._loadAfterSelf(); - return; - } - insertAfter($element.cloneNode(true), this.elementRef.nativeElement); - this.loaded = true; - }); + // skip caching view with descendant schemas + // as it needs attached controller + if (!this.disableLazy && (compRef.instance.hasDescendants || compRef.instance._hasSubSchemas)) { + this._loadAfterSelf(); + return; + } + insertAfter($element.cloneNode(true), this.elementRef.nativeElement); + this.loaded = true; } else { cache[this.pointer] = this._loadAfterSelf(); } } - initComponent(instance:JsonSchema) { + projectComponentInputs(instance:JsonSchema) { Object.assign(instance, this); } diff --git a/lib/components/JsonSchema/json-schema.spec.ts b/lib/components/JsonSchema/json-schema.spec.ts index d2c8f697..53b77cad 100644 --- a/lib/components/JsonSchema/json-schema.spec.ts +++ b/lib/components/JsonSchema/json-schema.spec.ts @@ -10,7 +10,7 @@ import { getChildDebugElement } from '../../../tests/helpers'; import { JsonSchema } from './json-schema'; -import { SpecManager } from '../../utils/SpecManager';; +import { SpecManager } from '../../utils/spec-manager';; describe('Redoc components', () => { beforeEach(() => { diff --git a/lib/components/Method/method.spec.ts b/lib/components/Method/method.spec.ts index c5e80d15..c35508a0 100644 --- a/lib/components/Method/method.spec.ts +++ b/lib/components/Method/method.spec.ts @@ -10,7 +10,7 @@ import { import { getChildDebugElement } from '../../../tests/helpers'; import { Method } from './method'; -import { SpecManager } from '../../utils/SpecManager';; +import { SpecManager } from '../../utils/spec-manager';; describe('Redoc components', () => { beforeEach(() => { diff --git a/lib/components/MethodsList/methods-list.spec.ts b/lib/components/MethodsList/methods-list.spec.ts index e552d2d2..ca59e157 100644 --- a/lib/components/MethodsList/methods-list.spec.ts +++ b/lib/components/MethodsList/methods-list.spec.ts @@ -11,7 +11,7 @@ import { getChildDebugElement } from '../../../tests/helpers'; import { MethodsList } from './methods-list'; -import { SpecManager } from '../../utils/SpecManager'; +import { SpecManager } from '../../utils/spec-manager'; describe('Redoc components', () => { beforeEach(() => { diff --git a/lib/components/Redoc/redoc.html b/lib/components/Redoc/redoc.html index 8df000b0..11e8c3d7 100644 --- a/lib/components/Redoc/redoc.html +++ b/lib/components/Redoc/redoc.html @@ -1,4 +1,8 @@ -
+
+

Oops... ReDoc failed to render this spec

+
{{_error.message}}
+
+