From dedf81caa0973842acda074f3778dab4c58baece Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Thu, 1 Sep 2016 11:54:25 +0300 Subject: [PATCH 01/12] Update CHANGELOG --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54b9aed8..229af56c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# 1.3.0 (2014-08-31) +### Bug fixes +* Fix code samples are not shown for operations without body param (#93) +* Fixed side menu overlapped site footer (#75) +* Fix broken order in discriminator dropdown + +### Features/Improvements +* Support "x-nullable" property by @kedashoe (#92) + # 1.2.0 (2016-08-30) ### Bug fixes * Fix sticky sidebar top sticking (#75) From a14bde334b2d0bf6808c1d681bc3acf81a809d6f Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 2 Sep 2016 23:18:31 +0300 Subject: [PATCH 02/12] Update to latest Angular RC.6 --- lib/components/ApiInfo/api-info.scss | 2 +- lib/components/ApiInfo/api-info.spec.ts | 13 ++++----- lib/components/ApiLogo/api-logo.spec.ts | 11 +++---- .../JsonSchema/json-schema-lazy.spec.ts | 13 +++++---- lib/components/JsonSchema/json-schema.spec.ts | 12 ++++---- lib/components/Method/method.spec.ts | 12 ++++---- .../MethodsList/methods-list.spec.ts | 12 ++++---- lib/components/Redoc/redoc.scss | 6 ++-- lib/components/Redoc/redoc.spec.ts | 24 ++++++++------- .../RequestSamples/request-samples.scss | 4 +-- .../SchemaSample/schema-sample.scss | 2 +- lib/components/SchemaSample/schema-sample.ts | 2 -- lib/components/SideMenu/side-menu.spec.ts | 14 +++++---- lib/components/SideMenu/side-menu.ts | 4 ++- lib/services/menu.service.spec.ts | 17 ++++++----- lib/shared/components/DropDown/drop-down.scss | 2 +- .../StickySidebar/sticky-sidebar.spec.ts | 12 ++++---- lib/shared/components/Tabs/tabs.spec.ts | 12 ++++---- lib/shared/components/Zippy/zippy.scss | 8 ++--- lib/shared/components/Zippy/zippy.spec.ts | 11 +++---- lib/utils/JsonFormatterPipe.ts | 10 +++++-- lib/utils/pipes.ts | 18 ++++++++---- package.json | 29 +++++++++---------- 23 files changed, 137 insertions(+), 113 deletions(-) diff --git a/lib/components/ApiInfo/api-info.scss b/lib/components/ApiInfo/api-info.scss index 67d64281..0c7c1a81 100644 --- a/lib/components/ApiInfo/api-info.scss +++ b/lib/components/ApiInfo/api-info.scss @@ -22,7 +22,7 @@ a.openapi-button { font-weight: normal; } -:host [section] { +:host /deep/ [section] { padding-top: 60px; margin-top: 20px; } diff --git a/lib/components/ApiInfo/api-info.spec.ts b/lib/components/ApiInfo/api-info.spec.ts index d8b6e2ee..7f5bf1c8 100644 --- a/lib/components/ApiInfo/api-info.spec.ts +++ b/lib/components/ApiInfo/api-info.spec.ts @@ -7,7 +7,7 @@ import { OptionsService } from '../../services/index'; import { inject, async, - TestComponentBuilder + TestBed } from '@angular/core/testing'; import { ApiInfo } from './api-info'; @@ -15,23 +15,23 @@ import { SpecManager } from '../../utils/SpecManager'; describe('Redoc components', () => { describe('ApiInfo Component', () => { - let builder; let component; let fixture; let opts; - - beforeEach(async(inject([TestComponentBuilder, SpecManager, OptionsService], (tcb, specMgr, _opts) => { + beforeEach(() => { + TestBed.configureTestingModule({ declarations: [ TestAppComponent ] }); + }); + beforeEach(async(inject([SpecManager, OptionsService], (specMgr, _opts) => { opts = _opts; opts.options = { scrollYOffset: () => 0, $scrollParent: window }; - builder = tcb; return specMgr.load('/tests/schemas/api-info-test.json'); }))); beforeEach(() => { - fixture = builder.createSync(TestAppComponent); + fixture = TestBed.createComponent(TestAppComponent); component = getChildDebugElement(fixture.debugElement, 'api-info').componentInstance; fixture.detectChanges(); }); @@ -55,7 +55,6 @@ describe('Redoc components', () => { /** Test component that contains an ApiInfo. */ @Component({ selector: 'test-app', - directives: [ApiInfo], template: `` }) diff --git a/lib/components/ApiLogo/api-logo.spec.ts b/lib/components/ApiLogo/api-logo.spec.ts index cc541c4e..e4ba00c0 100644 --- a/lib/components/ApiLogo/api-logo.spec.ts +++ b/lib/components/ApiLogo/api-logo.spec.ts @@ -6,7 +6,7 @@ import { Component } from '@angular/core'; import { inject, async, - TestComponentBuilder + TestBed } from '@angular/core/testing'; import { ApiLogo } from './api-logo'; @@ -21,13 +21,15 @@ describe('Redoc components', () => { let specMgr; let schemaUrl = '/tests/schemas/api-info-test.json'; - beforeEach(async(inject([TestComponentBuilder, SpecManager], (tcb, _specMgr) => { - builder = tcb; + beforeEach(() => { + TestBed.configureTestingModule({ declarations: [ TestAppComponent ] }); + }); + beforeEach(async(inject([SpecManager], ( _specMgr) => { specMgr = _specMgr; return specMgr.load(schemaUrl); }))); beforeEach(() => { - fixture = builder.createSync(TestAppComponent); + fixture = TestBed.createComponent(TestAppComponent); component = getChildDebugElement(fixture.debugElement, 'api-logo').componentInstance; fixture.detectChanges(); }); @@ -59,7 +61,6 @@ describe('Redoc components', () => { /** Test component that contains an ApiInfo. */ @Component({ selector: 'test-app', - directives: [ApiLogo], providers: [SpecManager], template: `` diff --git a/lib/components/JsonSchema/json-schema-lazy.spec.ts b/lib/components/JsonSchema/json-schema-lazy.spec.ts index f5052ba3..2ea539d9 100644 --- a/lib/components/JsonSchema/json-schema-lazy.spec.ts +++ b/lib/components/JsonSchema/json-schema-lazy.spec.ts @@ -5,22 +5,26 @@ import { Component } from '@angular/core'; import { inject, - TestComponentBuilder + TestBed } from '@angular/core/testing'; import { JsonSchemaLazy } from './json-schema-lazy'; describe('Redoc components', () => { + beforeEach(() => { + TestBed.configureTestingModule({ declarations: [ TestAppComponent ] }); + }); + describe('JsonSchemaLazy Component', () => { let builder; let component; let fixture; - beforeEach(inject([TestComponentBuilder], (tcb) => { - builder = tcb; + beforeEach(inject([TestBed], (tcb) => { + })); beforeEach(() => { - fixture = builder.createSync(TestAppComponent); + fixture = TestBed.createComponent(TestAppComponent); let debugEl = getChildDebugElement(fixture.debugElement, 'json-schema-lazy'); component = debugEl.componentInstance; spyOn(component, '_loadAfterSelf').and.stub(); @@ -47,7 +51,6 @@ describe('Redoc components', () => { /** Test component that contains a Method. */ @Component({ selector: 'test-app', - directives: [JsonSchemaLazy], template: `` }) diff --git a/lib/components/JsonSchema/json-schema.spec.ts b/lib/components/JsonSchema/json-schema.spec.ts index 3205c0be..d2c8f697 100644 --- a/lib/components/JsonSchema/json-schema.spec.ts +++ b/lib/components/JsonSchema/json-schema.spec.ts @@ -3,7 +3,7 @@ import { Component } from '@angular/core'; import { inject, - TestComponentBuilder + TestBed } from '@angular/core/testing'; import { getChildDebugElement } from '../../../tests/helpers'; @@ -13,19 +13,22 @@ import { JsonSchema } from './json-schema'; import { SpecManager } from '../../utils/SpecManager';; describe('Redoc components', () => { + beforeEach(() => { + TestBed.configureTestingModule({ declarations: [ TestAppComponent ] }); + }); describe('JsonSchema Component', () => { let builder; let component; let fixture; let specMgr; - beforeEach(inject([TestComponentBuilder, SpecManager], (tcb, _spec) => { - builder = tcb; + beforeEach(inject([SpecManager], ( _spec) => { + specMgr = _spec; })); beforeEach(() => { - fixture = builder.createSync(TestAppComponent); + fixture = TestBed.createComponent(TestAppComponent); let debugEl = getChildDebugElement(fixture.debugElement, 'json-schema'); component = debugEl.componentInstance; }); @@ -59,7 +62,6 @@ describe('Redoc components', () => { /** Test component that contains a Method. */ @Component({ selector: 'test-app', - directives: [JsonSchema], providers: [SpecManager], template: `` diff --git a/lib/components/Method/method.spec.ts b/lib/components/Method/method.spec.ts index 07f187ce..c5e80d15 100644 --- a/lib/components/Method/method.spec.ts +++ b/lib/components/Method/method.spec.ts @@ -4,7 +4,7 @@ import { Component } from '@angular/core'; import { inject, async, - TestComponentBuilder + TestBed } from '@angular/core/testing'; import { getChildDebugElement } from '../../../tests/helpers'; @@ -13,17 +13,20 @@ import { Method } from './method'; import { SpecManager } from '../../utils/SpecManager';; describe('Redoc components', () => { + beforeEach(() => { + TestBed.configureTestingModule({ declarations: [ TestAppComponent ] }); + }); describe('Method Component', () => { let builder; let component; - beforeEach(async(inject([TestComponentBuilder, SpecManager], (tcb, specMgr) => { - builder = tcb; + beforeEach(async(inject([SpecManager], ( specMgr) => { + return specMgr.load('/tests/schemas/extended-petstore.yml'); }))); beforeEach(() => { - let fixture = builder.createSync(TestAppComponent); + let fixture = TestBed.createComponent(TestAppComponent); component = getChildDebugElement(fixture.debugElement, 'method').componentInstance; fixture.detectChanges(); }); @@ -50,7 +53,6 @@ describe('Redoc components', () => { /** Test component that contains a Method. */ @Component({ selector: 'test-app', - directives: [Method], providers: [SpecManager], template: `` diff --git a/lib/components/MethodsList/methods-list.spec.ts b/lib/components/MethodsList/methods-list.spec.ts index ad0728be..e552d2d2 100644 --- a/lib/components/MethodsList/methods-list.spec.ts +++ b/lib/components/MethodsList/methods-list.spec.ts @@ -4,7 +4,7 @@ import { Component } from '@angular/core'; import { inject, async, - TestComponentBuilder + TestBed } from '@angular/core/testing'; import { getChildDebugElement } from '../../../tests/helpers'; @@ -14,17 +14,20 @@ import { MethodsList } from './methods-list'; import { SpecManager } from '../../utils/SpecManager'; describe('Redoc components', () => { + beforeEach(() => { + TestBed.configureTestingModule({ declarations: [ TestAppComponent ] }); + }); describe('MethodsList Component', () => { let builder; let component; let fixture; - beforeEach(async(inject([TestComponentBuilder, SpecManager], (tcb, specMgr) => { - builder = tcb; + beforeEach(async(inject([SpecManager], ( specMgr) => { + return specMgr.load('/tests/schemas/methods-list-component.json'); }))); beforeEach(() => { - fixture = builder.createSync(TestAppComponent); + fixture = TestBed.createComponent(TestAppComponent); component = getChildDebugElement(fixture.debugElement, 'methods-list').componentInstance; fixture.detectChanges(); }); @@ -47,7 +50,6 @@ describe('Redoc components', () => { @Component({ selector: 'test-app', - directives: [ MethodsList ], template: `` }) diff --git a/lib/components/Redoc/redoc.scss b/lib/components/Redoc/redoc.scss index a77f6777..6e1cd918 100644 --- a/lib/components/Redoc/redoc.scss +++ b/lib/components/Redoc/redoc.scss @@ -103,7 +103,7 @@ api-logo { /* global redoc styles */ @for $index from 1 through 5 { - :host h#{$index}{ + :host /deep/ h#{$index}{ margin-top: 0; font-family: $headers-font, $headers-font-family; color: $headers-color; @@ -111,7 +111,7 @@ api-logo { } } -:host { +:host /deep/ { h1 { font-size: $h1; } h2 { font-size: $h2; } h3 { font-size: $h3; } @@ -168,7 +168,7 @@ footer { /* markdown elements */ -:host .redoc-markdown-block { +:host /deep/ .redoc-markdown-block { pre { font-family: Courier, monospace; white-space: pre-wrap; diff --git a/lib/components/Redoc/redoc.spec.ts b/lib/components/Redoc/redoc.spec.ts index 288bb116..6ef20074 100644 --- a/lib/components/Redoc/redoc.spec.ts +++ b/lib/components/Redoc/redoc.spec.ts @@ -8,7 +8,7 @@ import { async } from '@angular/core/testing'; -import { TestComponentBuilder } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { Redoc } from './redoc'; import { SpecManager } from '../../utils/SpecManager'; @@ -17,28 +17,31 @@ import { OptionsService } from '../../services/index'; let optsMgr:OptionsService; describe('Redoc components', () => { + beforeEach(() => { + TestBed.configureTestingModule({ declarations: [ TestAppComponent ] }); + }); describe('Redoc Component', () => { let builder; let specMgr; - beforeEach(async(inject([TestComponentBuilder, SpecManager, OptionsService], - (tcb, _specMgr, _optsMgr) => { + beforeEach(async(inject([SpecManager, OptionsService], + ( _specMgr, _optsMgr) => { optsMgr = _optsMgr; - builder = tcb; + specMgr = _specMgr; return specMgr.load('/tests/schemas/extended-petstore.yml'); }))); it('should init component', () => { - let fixture = builder.createSync(TestAppComponent); + let fixture = TestBed.createComponent(TestAppComponent); let component = getChildDebugElement(fixture.debugElement, 'redoc').componentInstance; expect(component).not.toBeNull(); fixture.destroy(); }); it('should init components tree without errors', () => { - let fixture = builder.createSync(TestAppComponent); + let fixture = TestBed.createComponent(TestAppComponent); (() => fixture.detectChanges()).should.not.throw(); fixture.destroy(); }); @@ -89,16 +92,16 @@ describe('Redoc components', () => { // let dom; // let destroySpy; // - // beforeEach(async(inject([TestComponentBuilder, SpecManager, OptionsService, BrowserDomAdapter], - // (tcb, specMgr, opts, _dom) => { - // builder = tcb; + // beforeEach(async(inject([SpecManager, OptionsService, BrowserDomAdapter], + // ( specMgr, opts, _dom) => { + // // optsMgr = opts; // dom = _dom; // return specMgr.load('/tests/schemas/extended-petstore.yml'); // }))); // // beforeEach(() => { - // fixture = builder.createSync(TestAppComponent); + // fixture = TestBed.createComponent(TestAppComponent); // element = getChildDebugElement(fixture.debugElement, 'methods-list').nativeElement; // destroySpy = jasmine.createSpy('spy'); // Redoc.appRef = >{ @@ -165,7 +168,6 @@ describe('Redoc components', () => { /** Test component that contains a Redoc. */ @Component({ selector: 'test-app', - directives: [Redoc], template: `` }) diff --git a/lib/components/RequestSamples/request-samples.scss b/lib/components/RequestSamples/request-samples.scss index de7e3479..b5496886 100644 --- a/lib/components/RequestSamples/request-samples.scss +++ b/lib/components/RequestSamples/request-samples.scss @@ -46,7 +46,7 @@ header { font-weight: normal; } -:host > tabs > ul li { +:host /deep/ > tabs > ul li { font-family: $headers-font; font-size: .9em; border-radius: $border-radius; @@ -66,7 +66,7 @@ header { } } -:host tabs ul { +:host /deep/ tabs ul { padding-top: 10px; } diff --git a/lib/components/SchemaSample/schema-sample.scss b/lib/components/SchemaSample/schema-sample.scss index c4066d08..2f0ecedf 100644 --- a/lib/components/SchemaSample/schema-sample.scss +++ b/lib/components/SchemaSample/schema-sample.scss @@ -55,7 +55,7 @@ pre { opacity: 1; } -:host { +:host /deep/ { .property { //font-weight: bold; } diff --git a/lib/components/SchemaSample/schema-sample.ts b/lib/components/SchemaSample/schema-sample.ts index e072478a..11de5307 100644 --- a/lib/components/SchemaSample/schema-sample.ts +++ b/lib/components/SchemaSample/schema-sample.ts @@ -5,13 +5,11 @@ import { Component, ElementRef, Input, ChangeDetectionStrategy, OnInit } from '@ import * as OpenAPISampler from 'openapi-sampler'; import { BaseComponent, SpecManager } from '../base'; -import { JsonFormatter } from '../../utils/JsonFormatterPipe'; import { SchemaNormalizer } from '../../services/schema-normalizer.service'; @Component({ selector: 'schema-sample', templateUrl: './schema-sample.html', - pipes: [JsonFormatter], styleUrls: ['./schema-sample.css'], changeDetection: ChangeDetectionStrategy.OnPush }) diff --git a/lib/components/SideMenu/side-menu.spec.ts b/lib/components/SideMenu/side-menu.spec.ts index 0815c873..75b7e64c 100644 --- a/lib/components/SideMenu/side-menu.spec.ts +++ b/lib/components/SideMenu/side-menu.spec.ts @@ -9,7 +9,7 @@ import { async } from '@angular/core/testing'; -import { TestComponentBuilder } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { MethodsList, SideMenu } from '../index'; @@ -18,14 +18,17 @@ import { SpecManager } from '../../utils/SpecManager'; let testOptions; describe('Redoc components', () => { + beforeEach(() => { + TestBed.configureTestingModule({ declarations: [ TestAppComponent ] }); + }); describe('SideMenu Component', () => { let builder; let component; let fixture; - beforeEach(async(inject([TestComponentBuilder, SpecManager, OptionsService], - (tcb, specMgr, opts) => { - builder = tcb; + beforeEach(async(inject([SpecManager, OptionsService], + ( specMgr, opts) => { + testOptions = opts; testOptions.options = { scrollYOffset: () => 0, @@ -35,7 +38,7 @@ describe('Redoc components', () => { }))); beforeEach(() => { - fixture = builder.createSync(TestAppComponent); + fixture = TestBed.createComponent(TestAppComponent); component = getChildDebugElement(fixture.debugElement, 'side-menu').componentInstance; fixture.detectChanges(); }); @@ -54,7 +57,6 @@ describe('Redoc components', () => { /** Test component that contains an ApiInfo. */ @Component({ selector: 'test-app', - directives: [MethodsList, SideMenu], template: ` ` diff --git a/lib/components/SideMenu/side-menu.ts b/lib/components/SideMenu/side-menu.ts index 382eb964..0b9c23cf 100644 --- a/lib/components/SideMenu/side-menu.ts +++ b/lib/components/SideMenu/side-menu.ts @@ -2,13 +2,15 @@ import { Component, ElementRef, ChangeDetectorRef, OnInit } from '@angular/core'; -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 { BaseComponent, SpecManager } from '../base'; import { ScrollService, Hash, MenuService, OptionsService } from '../../services/index'; import { BrowserDomAdapter as DOM } from '../../utils/browser-adapter'; import { MenuCategory } from '../../services/schema-helper.service'; +const global = window; + @Component({ selector: 'side-menu', templateUrl: './side-menu.html', diff --git a/lib/services/menu.service.spec.ts b/lib/services/menu.service.spec.ts index df8697de..e48ce0ac 100644 --- a/lib/services/menu.service.spec.ts +++ b/lib/services/menu.service.spec.ts @@ -3,32 +3,34 @@ import { Component } from '@angular/core'; import { inject, async, - TestComponentBuilder + TestBed } from '@angular/core/testing'; import { MenuService } from './menu.service'; import { Hash } from './hash.service'; import { ScrollService } from './scroll.service'; -import { MethodsList } from '../components/index'; import { SpecManager } from '../utils/SpecManager';; describe('Menu service', () => { + beforeEach(() => { + TestBed.configureTestingModule({ declarations: [ TestAppComponent ] }); + }); + let menu, hashService, scroll; - let builder; let specMgr; - beforeEach(async(inject([TestComponentBuilder, SpecManager, Hash, ScrollService], - (tcb, _specMgr, _hash, _scroll, _menu) => { + beforeEach(async(inject([SpecManager, Hash, ScrollService], + ( _specMgr, _hash, _scroll, _menu) => { hashService = _hash; scroll = _scroll; - builder = tcb; + specMgr = _specMgr; return specMgr.load('/tests/schemas/extended-petstore.yml'); }))); beforeEach(() => { menu = new MenuService(hashService, scroll, specMgr); - let fixture = builder.createSync(TestAppComponent); + let fixture = TestBed.createComponent(TestAppComponent); fixture.detectChanges(); }); @@ -91,7 +93,6 @@ describe('Menu service', () => { @Component({ selector: 'test-app', - directives: [ MethodsList ], template: `
diff --git a/lib/shared/components/DropDown/drop-down.scss b/lib/shared/components/DropDown/drop-down.scss index 7143c9e8..151bbf4e 100644 --- a/lib/shared/components/DropDown/drop-down.scss +++ b/lib/shared/components/DropDown/drop-down.scss @@ -1,6 +1,6 @@ @import '../../styles/variables'; -:host { +:host /deep/ { .dk-select { max-width: 100%; font-family: $headers-font, $headers-font-family; diff --git a/lib/shared/components/StickySidebar/sticky-sidebar.spec.ts b/lib/shared/components/StickySidebar/sticky-sidebar.spec.ts index 43bbaf2e..4880dcdf 100644 --- a/lib/shared/components/StickySidebar/sticky-sidebar.spec.ts +++ b/lib/shared/components/StickySidebar/sticky-sidebar.spec.ts @@ -4,20 +4,23 @@ import { getChildDebugElementByType } from '../../../../tests/helpers'; import { Component } from '@angular/core'; import { inject, - TestComponentBuilder + TestBed } from '@angular/core/testing'; import { StickySidebar } from '../index'; describe('Common components', () => { + beforeEach(() => { + TestBed.configureTestingModule({ declarations: [ TestApp ] }); + }); describe('StickySidebar Component', () => { let builder; let component; let fixture; - beforeEach(inject([TestComponentBuilder], (tcb) => { - builder = tcb; - fixture = builder.createSync(TestApp); + beforeEach(inject([TestBed], (tcb) => { + + fixture = TestBed.createComponent(TestApp); let debugEl = getChildDebugElementByType(fixture.debugElement, StickySidebar); component = debugEl.injector.get(StickySidebar); })); @@ -64,7 +67,6 @@ describe('Common components', () => { /** Test component that contains an ApiInfo. */ @Component({ selector: 'test-app', - directives: [StickySidebar], template: `
diff --git a/lib/shared/components/Tabs/tabs.spec.ts b/lib/shared/components/Tabs/tabs.spec.ts index c48e0f61..c4abefa4 100644 --- a/lib/shared/components/Tabs/tabs.spec.ts +++ b/lib/shared/components/Tabs/tabs.spec.ts @@ -5,12 +5,15 @@ import { Component } from '@angular/core'; import { inject, - TestComponentBuilder + TestBed } from '@angular/core/testing'; import {Tabs, Tab} from '../index'; describe('Common components', () => { + beforeEach(() => { + TestBed.configureTestingModule({ declarations: [ TestApp ] }); + }); describe('Tabs Component', () => { let builder; let component; @@ -19,9 +22,9 @@ describe('Common components', () => { let fixture; let hostComponent; - beforeEach(inject([TestComponentBuilder], (tcb) => { - builder = tcb; - fixture = builder.createSync(TestApp); + beforeEach(inject([TestBed], (tcb) => { + + fixture = TestBed.createComponent(TestApp); hostComponent = fixture.debugElement.componentInstance; debugEl = getChildDebugElement(fixture.debugElement, 'tabs'); childDebugEls = getChildDebugElementAll(debugEl, 'tab'); @@ -131,7 +134,6 @@ describe('Common components', () => { /** Test component that contains an ApiInfo. */ @Component({ selector: 'test-app', - directives: [Tabs, Tab], template: ` Test diff --git a/lib/shared/components/Zippy/zippy.scss b/lib/shared/components/Zippy/zippy.scss index 6fe4fcba..208057b3 100644 --- a/lib/shared/components/Zippy/zippy.scss +++ b/lib/shared/components/Zippy/zippy.scss @@ -21,7 +21,7 @@ $zippy-redirect-bg-color: rgba($zippy-redirect-color, .08); .zippy-title { padding: 10px; border-radius: 2px; - margin: 2px 0; + margin-bottom: 4px; line-height: 1.5em; background-color: #f2f2f2; cursor: pointer; @@ -46,16 +46,12 @@ $zippy-redirect-bg-color: rgba($zippy-redirect-color, .08); background-color: $zippy-info-bg-color; } } + .zippy-indicator svg { height: 1.2em; vertical-align: middle; - transition: all 0.3s ease; - transform: rotateZ(-180deg); } -.zippy-hidden > .zippy-title svg { - transform: rotateZ(0); -} .zippy-title polygon { .zippy-success > & { diff --git a/lib/shared/components/Zippy/zippy.spec.ts b/lib/shared/components/Zippy/zippy.spec.ts index 4d013756..4cdebffe 100644 --- a/lib/shared/components/Zippy/zippy.spec.ts +++ b/lib/shared/components/Zippy/zippy.spec.ts @@ -5,21 +5,23 @@ import { getChildDebugElement, mouseclick } from '../../../../tests/helpers'; import { Component } from '@angular/core'; import { inject, - TestComponentBuilder + TestBed } from '@angular/core/testing'; import { Zippy } from '../index'; describe('Common components', () => { + beforeEach(() => { + TestBed.configureTestingModule({ declarations: [ TestApp ] }); + }); describe('Zippy Component', () => { let builder; let component; let nativeElement; let fixture; - beforeEach(inject([TestComponentBuilder], (tcb) => { - builder = tcb; - fixture = builder.createSync(TestApp); + beforeEach(inject([TestBed], (tcb) => { + fixture = TestBed.createComponent(TestApp); let debugEl = getChildDebugElement(fixture.debugElement, 'zippy'); component = debugEl.componentInstance; nativeElement = debugEl.nativeElement; @@ -92,7 +94,6 @@ describe('Common components', () => { /** Test component that contains an ApiInfo. */ @Component({ selector: 'test-app', - directives: [Zippy], template: `test` }) diff --git a/lib/utils/JsonFormatterPipe.ts b/lib/utils/JsonFormatterPipe.ts index 50d8b1d9..4c3006af 100644 --- a/lib/utils/JsonFormatterPipe.ts +++ b/lib/utils/JsonFormatterPipe.ts @@ -1,14 +1,18 @@ 'use strict'; import { Pipe, PipeTransform } from '@angular/core'; -import { isBlank } from '@angular/core/src/facade/lang'; -import { DomSanitizationService } from '@angular/platform-browser'; +//import { isBlank } from '@angular/core/src/facade/lang'; +import { DomSanitizer } from '@angular/platform-browser'; + +function isBlank(obj) { + return obj === undefined || obj === null; +} var level = 1; const COLLAPSE_LEVEL = 2; @Pipe({ name: 'jsonFormatter' }) export class JsonFormatter implements PipeTransform { - constructor(private sanitizer: DomSanitizationService) {} + constructor(private sanitizer: DomSanitizer) {} transform(value) { if (isBlank(value)) return value; return this.sanitizer.bypassSecurityTrustHtml(jsonToHTML(value)); diff --git a/lib/utils/pipes.ts b/lib/utils/pipes.ts index 516fcec5..a318fce4 100644 --- a/lib/utils/pipes.ts +++ b/lib/utils/pipes.ts @@ -1,15 +1,21 @@ 'use strict'; import { Pipe, PipeTransform } from '@angular/core'; -import { DomSanitizationService } from '@angular/platform-browser'; +import { DomSanitizer } from '@angular/platform-browser'; import { isString, stringify, isBlank } from '@angular/core/src/facade/lang'; -import { BaseException } from '@angular/core/src/facade/exceptions'; import JsonPointer from './JsonPointer'; import { renderMd } from './helpers'; +import { JsonFormatter } from './JsonFormatterPipe'; declare var Prism: any; +class BaseException { + message: string; + constructor(message) { + this.message = message; + } +} class InvalidPipeArgumentException extends BaseException { constructor(type, value) { @@ -52,7 +58,7 @@ export class JsonPointerEscapePipe implements PipeTransform { @Pipe({ name: 'marked' }) export class MarkedPipe implements PipeTransform { - constructor(private sanitizer: DomSanitizationService) {} + constructor(private sanitizer: DomSanitizer) {} transform(value:string) { if (isBlank(value)) return value; if (!isString(value)) { @@ -67,7 +73,7 @@ export class MarkedPipe implements PipeTransform { @Pipe({ name: 'safe' }) export class SafePipe implements PipeTransform { - constructor(private sanitizer: DomSanitizationService) {} + constructor(private sanitizer: DomSanitizer) {} transform(value:string) { if (isBlank(value)) return value; if (!isString(value)) { @@ -88,7 +94,7 @@ const langMap = { @Pipe({ name: 'prism' }) export class PrismPipe implements PipeTransform { - constructor(private sanitizer: DomSanitizationService) {} + constructor(private sanitizer: DomSanitizer) {} transform(value, args) { if (isBlank(args) || args.length === 0) { throw new BaseException('Prism pipe requires one argument'); @@ -119,5 +125,5 @@ export class EncodeURIComponentPipe implements PipeTransform { } export const REDOC_PIPES = [ - JsonPointerEscapePipe, MarkedPipe, SafePipe, PrismPipe, EncodeURIComponentPipe + JsonPointerEscapePipe, MarkedPipe, SafePipe, PrismPipe, EncodeURIComponentPipe, JsonFormatter ]; diff --git a/package.json b/package.json index a8f4db64..5efb4a32 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "author": "Roman Hotsiy", "license": "MIT", "devDependencies": { + "@angular/compiler-cli": "^0.6.0", "@types/core-js": "^0.9.31", "@types/jasmine": "^2.2.32", "@types/requirejs": "^2.1.26", @@ -71,29 +72,27 @@ "karma-webpack": "^1.8.0", "node-sass": "^3.8.0", "phantomjs-prebuilt": "^2.1.7", - "protractor": "^3.3.0", + "protractor": "^4.0.4", "raw-loader": "^0.5.1", "shelljs": "^0.7.0", - "should": "^9.0.2", + "should": "^11.1.0", "sinon": "^1.17.2", "source-map-loader": "^0.1.5", "style-loader": "^0.13.1", "ts-helpers": "^1.1.1", "tslint": "^3.15.0-dev.0", "tslint-stylish": "^2.1.0-beta", - "typescript": "^2.0.0", + "typescript": "^2.0.2", "webpack": "^2.1.0-beta.21", - "webpack-dev-server": "^1.15.0", - "yargs": "^4.7.1" + "webpack-dev-server": "^2.1.0-beta.2" }, "dependencies": { - "@angular/common": "^2.0.0-rc.5", - "@angular/compiler": "^2.0.0-rc.5", - "@angular/compiler-cli": "^0.5.0", - "@angular/core": "^2.0.0-rc.5", - "@angular/platform-browser": "^2.0.0-rc.5", - "@angular/platform-browser-dynamic": "^2.0.0-rc.5", - "@angular/platform-server": "^2.0.0-rc.5", + "@angular/common": "^2.0.0-rc.6", + "@angular/compiler": "^2.0.0-rc.6", + "@angular/core": "^2.0.0-rc.6", + "@angular/platform-browser": "^2.0.0-rc.6", + "@angular/platform-browser-dynamic": "^2.0.0-rc.6", + "@angular/platform-server": "^2.0.0-rc.6", "core-js": "^2.4.1", "dropkickjs": "^2.1.10", "hint.css": "^2.3.2", @@ -102,10 +101,10 @@ "openapi-sampler": "^0.3.0", "prismjs": "^1.5.1", "remarkable": "^1.6.2", - "rxjs": "5.0.0-beta.6", + "rxjs": "^5.0.0-beta.11", "scrollparent": "^1.0.0", - "slugify": "^0.1.1", + "slugify": "^1.0.2", "stream-http": "^2.3.1", - "zone.js": "^0.6.15" + "zone.js": "^0.6.17" } } From 52c22335347e5d223cbb75e4add593df5ebfd4f3 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 2 Sep 2016 23:24:51 +0300 Subject: [PATCH 03/12] Smaller bundle size by removing esprima dep from bundle --- build/webpack.dev.js | 24 +++++++++++++++--------- build/webpack.prod.js | 26 ++++++++++++++++---------- build/webpack.test.js | 24 +++++++++++++++--------- lib/polyfills.ts | 30 ++++++++++++++++++++++++++++-- lib/vendor.ts | 13 ++++++++----- manual-types/index.d.ts | 5 +++++ tsconfig.json | 10 ++++++---- 7 files changed, 93 insertions(+), 39 deletions(-) diff --git a/build/webpack.dev.js b/build/webpack.dev.js index 5ac0c436..831fbc35 100644 --- a/build/webpack.dev.js +++ b/build/webpack.dev.js @@ -12,13 +12,9 @@ module.exports = { debug: false, resolve: { - extensions: ['', '.ts', '.js', '.json', '.css', '.scss', '.html'], + extensions: ['', '.ts', '.js', '.json', '.css'], root: root('lib'), - descriptionFiles: ['package.json'], - modules: [ - 'node_modules', - root('lib') - ], + modulesDirectories: ['node_modules'], alias: { './lib/bootstrap': root('lib/bootstrap.dev'), http: 'stream-http', @@ -26,10 +22,17 @@ module.exports = { } }, externals: { - "jquery": "jQuery" + "jquery": "jQuery", + 'esprima': 'esprima' // optional dep of ys-yaml not needed for redoc }, node: { - fs: "empty" + fs: "empty", + crypto: "empty", + global: "window", + process: true, + module: false, + clearImmediate: false, + setImmediate: false }, entry: { 'redoc': './lib/index.ts', @@ -57,7 +60,10 @@ module.exports = { module: { preLoaders: [{ test: /\.js$/, - loader: 'source-map' + loader: 'source-map-loader', + exclude: [ + /node_modules/ + ] }], loaders: [{ test: /\.ts$/, diff --git a/build/webpack.prod.js b/build/webpack.prod.js index 96c9b71f..e234dd44 100644 --- a/build/webpack.prod.js +++ b/build/webpack.prod.js @@ -12,26 +12,29 @@ const BANNER = module.exports = { context: root(), - devtool: 'cheap-module-source-map', + devtool: 'source-map', resolve: { - extensions: ['', '.ts', '.js', '.json', '.css', '.scss', '.html'], + extensions: ['', '.ts', '.js', '.json', '.css'], root: root('lib'), - descriptionFiles: ['package.json'], - modules: [ - 'node_modules', - root('lib') - ], + modulesDirectories: ['node_modules'], alias: { http: 'stream-http', https: 'stream-http' } }, externals: { - "jquery": "jQuery" + 'jquery': 'jQuery', + 'esprima': 'esprima' // optional dep of ys-yaml not needed for redoc }, node: { - fs: "empty" + fs: "empty", + crypto: "empty", + global: "window", + process: true, + module: false, + clearImmediate: false, + setImmediate: false }, entry: { 'redoc': ['./lib/polyfills.ts', './lib/vendor.ts', './lib/index.ts'] @@ -49,7 +52,10 @@ module.exports = { module: { preLoaders: [{ test: /\.js$/, - loader: 'source-map' + loader: 'source-map-loader', + exclude: [ + /node_modules/ + ] }], loaders: [{ test: /\.ts$/, diff --git a/build/webpack.test.js b/build/webpack.test.js index 7e74aec9..ba223e6e 100644 --- a/build/webpack.test.js +++ b/build/webpack.test.js @@ -8,13 +8,9 @@ module.exports = { devtool: 'inline-source-map', resolve: { - extensions: ['', '.ts', '.js', '.json', '.css', '.scss', '.html'], + extensions: ['', '.ts', '.js', '.json', '.css'], root: root('lib'), - descriptionFiles: ['package.json'], - modules: [ - 'node_modules', - root('lib'), - ], + modulesDirectories: ['node_modules'], alias: { './lib/bootstrap': root('lib/bootstrap.dev'), http: 'stream-http', @@ -22,10 +18,17 @@ module.exports = { } }, externals: { - "jquery": "jQuery" + "jquery": "jQuery", + 'esprima': 'esprima' // optional dep of ys-yaml not needed for redoc }, node: { - fs: "empty" + fs: "empty", + crypto: "empty", + global: "window", + process: true, + module: false, + clearImmediate: false, + setImmediate: false }, output: { @@ -38,7 +41,10 @@ module.exports = { module: { preLoaders: [{ test: /\.js$/, - loader: 'source-map' + loader: 'source-map-loader', + exclude: [ + /node_modules/ + ] }], loaders: [ { test: /\.ts$/, diff --git a/lib/polyfills.ts b/lib/polyfills.ts index 33329a99..a5d5d8e4 100644 --- a/lib/polyfills.ts +++ b/lib/polyfills.ts @@ -1,4 +1,30 @@ -import 'core-js/es6'; +import 'core-js/es6/symbol'; +import 'core-js/es6/object'; +import 'core-js/es6/function'; +import 'core-js/es6/parse-int'; +import 'core-js/es6/parse-float'; +import 'core-js/es6/number'; +import 'core-js/es6/math'; +import 'core-js/es6/string'; +import 'core-js/es6/date'; +import 'core-js/es6/array'; +import 'core-js/es6/regexp'; +import 'core-js/es6/map'; +import 'core-js/es6/set'; +import 'core-js/es6/weak-map'; +import 'core-js/es6/weak-set'; +import 'core-js/es6/typed'; +import 'core-js/es6/reflect'; +// see issue https://github.com/AngularClass/angular2-webpack-starter/issues/709 +// import 'core-js/es6/promise'; + import 'core-js/es7/reflect'; -import 'ts-helpers'; import 'zone.js/dist/zone'; + +// Typescript emit helpers polyfill +import 'ts-helpers'; + +if (!IS_PRODUCTION) { + Error.stackTraceLimit = Infinity; + require('zone.js/dist/long-stack-trace-zone'); +} diff --git a/lib/vendor.ts b/lib/vendor.ts index 8a5df237..e6d13941 100644 --- a/lib/vendor.ts +++ b/lib/vendor.ts @@ -23,9 +23,12 @@ import 'dropkickjs/build/css/dropkick.css'; import 'prismjs/themes/prism-dark.css'; import 'hint.css/hint.base.css'; -import '@angular/common'; -import '@angular/core'; -import '@angular/platform-browser'; +if (!IS_PRODUCTION) { + require('@angular/platform-browser'); + require('@angular/platform-browser-dynamic'); + require('@angular/core'); + require('@angular/common'); -// RxJS -import 'rxjs/Rx'; + // RxJS + require('rxjs/Rx'); +} diff --git a/manual-types/index.d.ts b/manual-types/index.d.ts index 9fc4b783..22733ca1 100644 --- a/manual-types/index.d.ts +++ b/manual-types/index.d.ts @@ -14,3 +14,8 @@ declare module "*.css" { declare var LIB_VERSION: any; declare var IS_PRODUCTION: any; + +interface ErrorStackTraceLimit { + stackTraceLimit: number; +} +interface ErrorConstructor extends ErrorStackTraceLimit {} diff --git a/tsconfig.json b/tsconfig.json index 69c9d550..bbf26276 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,11 +2,11 @@ "compilerOptions": { "experimentalDecorators": true, "emitDecoratorMetadata": true, - "module": "es6", + "module": "commonjs", "target": "es5", "noImplicitAny": false, "sourceMap": true, - "outDir": ".tmp/lib", + "outDir": ".tmp", "pretty": true, "moduleResolution": "node", "types": [ @@ -21,10 +21,12 @@ "exclude": [ "node_modules", - ".tmp" + ".tmp", + "dist" ], "awesomeTypescriptLoaderOptions": { "resolveGlobs": true, - "forkChecker": true + "forkChecker": true, + "useWebpackText": true } } From 28fb22827f9323778db36c607a2daad22556ee3c Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 2 Sep 2016 23:25:03 +0300 Subject: [PATCH 04/12] Updated deps --- README.md | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f378ba91..80cf0226 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # ReDoc **OpenAPI/Swagger-generated API Reference Documentation** -[![Build Status](https://travis-ci.org/Rebilly/ReDoc.svg?branch=master)](https://travis-ci.org/Rebilly/ReDoc) [![Coverage Status](https://coveralls.io/repos/Rebilly/ReDoc/badge.svg?branch=master&service=github)](https://coveralls.io/github/Rebilly/ReDoc?branch=master) [![Tested on APIs.guru](http://api.apis.guru/badges/tested_on.svg)](https://APIs.guru) [![Code Climate](https://codeclimate.com/github/Rebilly/ReDoc/badges/gpa.svg)](https://codeclimate.com/github/Rebilly/ReDoc) [![David](https://david-dm.org/Rebilly/ReDoc/dev-status.svg)](https://david-dm.org/Rebilly/ReDoc#info=devDependencies) [![Stories in Ready](https://badge.waffle.io/Rebilly/ReDoc.png?label=ready&title=Ready)](https://waffle.io/Rebilly/ReDoc) +[![Build Status](https://travis-ci.org/Rebilly/ReDoc.svg?branch=master)](https://travis-ci.org/Rebilly/ReDoc) [![Coverage Status](https://coveralls.io/repos/Rebilly/ReDoc/badge.svg?branch=master&service=github)](https://coveralls.io/github/Rebilly/ReDoc?branch=master) [![Tested on APIs.guru](http://api.apis.guru/badges/tested_on.svg)](https://APIs.guru) [![Code Climate](https://codeclimate.com/github/Rebilly/ReDoc/badges/gpa.svg)](https://codeclimate.com/github/Rebilly/ReDoc) [![dependencies Status](https://david-dm.org/Rebilly/ReDoc/status.svg)](https://david-dm.org/Rebilly/ReDoc) [![devDependencies Status](https://david-dm.org/Rebilly/ReDoc/dev-status.svg)](https://david-dm.org/Rebilly/ReDoc#info=devDependencies) [![Stories in Ready](https://badge.waffle.io/Rebilly/ReDoc.png?label=ready&title=Ready)](https://waffle.io/Rebilly/ReDoc) [![npm](http://img.shields.io/npm/v/redoc.svg)](https://www.npmjs.com/package/redoc) [![Bower](http://img.shields.io/bower/v/redoc.svg)](http://bower.io/) [![License](https://img.shields.io/npm/l/redoc.svg)](https://github.com/Rebilly/ReDoc/blob/master/LICENSE) diff --git a/package.json b/package.json index 5efb4a32..2f713273 100644 --- a/package.json +++ b/package.json @@ -58,8 +58,8 @@ "istanbul-instrumenter-loader": "^0.2.0", "jasmine-core": "^2.4.1", "jasmine-spec-reporter": "^2.4.0", - "karma": "^0.13.15", - "karma-chrome-launcher": "^1.0.1", + "karma": "^1.2.0", + "karma-chrome-launcher": "^2.0.0", "karma-coverage": "github:douglasduteil/karma-coverage#next", "karma-coveralls": "^1.1.2", "karma-jasmine": "^1.0.2", From 719dfbfa1348c1659c460db21f92a07620ad38a6 Mon Sep 17 00:00:00 2001 From: LeFnord Date: Tue, 6 Sep 2016 10:52:31 +0200 Subject: [PATCH 05/12] makes basePath optional --- lib/utils/SpecManager.ts | 3 ++- tests/schemas/api-info-test.json | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils/SpecManager.ts b/lib/utils/SpecManager.ts index 886d5f54..32149e9c 100644 --- a/lib/utils/SpecManager.ts +++ b/lib/utils/SpecManager.ts @@ -56,7 +56,8 @@ export class SpecManager { } let host = this._schema.host || urlParts.host; - this.apiUrl = protocol + '://' + host + this._schema.basePath; + let basePath = this._schema.basePath || '/'; + this.apiUrl = protocol + '://' + host + basePath; if (this.apiUrl.endsWith('/')) { this.apiUrl = this.apiUrl.substr(0, this.apiUrl.length - 1); } diff --git a/tests/schemas/api-info-test.json b/tests/schemas/api-info-test.json index 946f9f29..a7e03f7b 100644 --- a/tests/schemas/api-info-test.json +++ b/tests/schemas/api-info-test.json @@ -14,7 +14,6 @@ } }, "host": "petstore.swagger.io", - "basePath": "/v2/", "schemes": ["http"], "paths": { "/pet": { From 553ee8091fa12dd04a947c38abc18ef95dd38ee7 Mon Sep 17 00:00:00 2001 From: Adam DuVander Date: Wed, 7 Sep 2016 14:41:10 -0700 Subject: [PATCH 06/12] Just a little typo --- demo/swagger.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/swagger.yaml b/demo/swagger.yaml index 86abb4f6..9bb9dee4 100644 --- a/demo/swagger.yaml +++ b/demo/swagger.yaml @@ -12,13 +12,13 @@ info: For this sample, you can use the api key `special-key` to test the authorization filters. # Introduction This API is documented in **OpenAPI format** and is based on - [Pestore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team. + [Petstore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team. It was **extended** to illustrate features of [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo) tool and [ReDoc](https://github.com/Rebilly/ReDoc) documentation. In addition to standard OpenAPI syntax we use a few [vendor extensions](https://github.com/Rebilly/ReDoc/blob/master/docs/redoc-vendor-extensions.md). # OpenAPI Specification This API is documented in **OpenAPI format** and is based on - [Pestore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team. + [Petstore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team. It was **extended** to illustrate features of [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo) tool and [ReDoc](https://github.com/Rebilly/ReDoc) documentation. In addition to standard OpenAPI syntax we use a few [vendor extensions](https://github.com/Rebilly/ReDoc/blob/master/docs/redoc-vendor-extensions.md). From 96dd49e27bd9a977dbf7a8699c078d326cfc2824 Mon Sep 17 00:00:00 2001 From: Benny Neugebauer Date: Thu, 8 Sep 2016 12:19:33 +0200 Subject: [PATCH 07/12] Fixed indentation --- tsconfig.json | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index bbf26276..950a07a1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,32 +1,31 @@ { - "compilerOptions": { - "experimentalDecorators": true, - "emitDecoratorMetadata": true, + "compilerOptions": { + "experimentalDecorators": true, + "emitDecoratorMetadata": true, "module": "commonjs", - "target": "es5", - "noImplicitAny": false, - "sourceMap": true, - "outDir": ".tmp", - "pretty": true, - "moduleResolution": "node", - "types": [ - "core-js", - "jasmine", - "should", - "requirejs" - ], - "noEmitHelpers": true - }, - "compileOnSave": false, - - "exclude": [ + "target": "es5", + "noImplicitAny": false, + "sourceMap": true, + "outDir": ".tmp", + "pretty": true, + "moduleResolution": "node", + "types": [ + "core-js", + "jasmine", + "should", + "requirejs" + ], + "noEmitHelpers": true + }, + "compileOnSave": false, + "exclude": [ "node_modules", ".tmp", - "dist" + "dist" ], - "awesomeTypescriptLoaderOptions": { + "awesomeTypescriptLoaderOptions": { "resolveGlobs": true, "forkChecker": true, - "useWebpackText": true + "useWebpackText": true } } From fb0defa04c12707581f13c631334c52c79b16e14 Mon Sep 17 00:00:00 2001 From: Mike Ralphson Date: Thu, 8 Sep 2016 19:31:17 +0100 Subject: [PATCH 08/12] Typo s/IGNORRED/IGNORED --- lib/services/schema-normalizer.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/services/schema-normalizer.service.ts b/lib/services/schema-normalizer.service.ts index 8b1de77a..57142ae7 100644 --- a/lib/services/schema-normalizer.service.ts +++ b/lib/services/schema-normalizer.service.ts @@ -208,7 +208,7 @@ class SchemaDereferencer { let keysCount = Object.keys(schema).length; if ( keysCount > 2 || (keysCount === 2 && !schema.description) ) { WarningsService.warn(`Other properties are defined at the same level as $ref at "#${pointer}". ` + - 'They are IGNORRED according to the JsonSchema spec'); + 'They are IGNORED according to the JsonSchema spec'); resolved.description = resolved.description || schema.description; } From 511415ca06d7d33c07d47f1b444fe51bc9c1a8dc Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 12 Sep 2016 22:48:44 +0300 Subject: [PATCH 09/12] Fix default hostname #108 --- lib/utils/SpecManager.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils/SpecManager.ts b/lib/utils/SpecManager.ts index 32149e9c..64755d6a 100644 --- a/lib/utils/SpecManager.ts +++ b/lib/utils/SpecManager.ts @@ -4,7 +4,7 @@ import * as JsonSchemaRefParser from 'json-schema-ref-parser'; import { JsonPointer } from './JsonPointer'; import { renderMd, safePush } from './helpers'; import * as slugify from 'slugify'; -import { parse as urlParse } from 'url'; +import { parse as urlParse, resolve as urlResolve } from 'url'; export class SpecManager { public _schema: any = {}; @@ -42,7 +42,7 @@ export class SpecManager { /* calculate common used values */ init() { - let urlParts = this._url ? urlParse(this._url) : {}; + let urlParts = this._url ? urlParse(urlResolve(window.location.href, this._url)) : {}; let schemes = this._schema.schemes; let protocol; if (!schemes || !schemes.length) { From c768512913eeba0c6aa72e902a622249e1938232 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 12 Sep 2016 22:50:42 +0300 Subject: [PATCH 10/12] Fix default value for falsy values is not displayed (#109) --- lib/components/JsonSchema/json-schema.html | 2 +- lib/components/ParamsList/params-list.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/components/JsonSchema/json-schema.html b/lib/components/JsonSchema/json-schema.html index c7865ff6..67d70ff8 100644 --- a/lib/components/JsonSchema/json-schema.html +++ b/lib/components/JsonSchema/json-schema.html @@ -72,7 +72,7 @@ Required Nullable -
Default: {{prop.default | json}}
+
Default: {{prop.default | json}}
{{enumItem.val | json}}
diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html index 89211a1b..4000f8ea 100644 --- a/lib/components/ParamsList/params-list.html +++ b/lib/components/ParamsList/params-list.html @@ -16,7 +16,7 @@ title="{{param._displayTypeHint}}"> {{param._displayType}} {{param._displayFormat}} {{param._range}} Required -
Default: {{param.default | json}}
+
Default: {{param.default | json}}
{{enumItem.val | json}}
From 39db6e84620d01ac5de7446cf28b82d81fde263e Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 12 Sep 2016 23:40:46 +0300 Subject: [PATCH 11/12] Fix schema collapse after change discriminator --- lib/components/JsonSchema/json-schema.ts | 3 ++- lib/services/schema-normalizer.service.ts | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/components/JsonSchema/json-schema.ts b/lib/components/JsonSchema/json-schema.ts index 6cc6642d..6fa7917d 100644 --- a/lib/components/JsonSchema/json-schema.ts +++ b/lib/components/JsonSchema/json-schema.ts @@ -47,6 +47,7 @@ export class JsonSchema extends BaseComponent implements OnInit { this.pointer = activeDescendant.$ref; this.schema = this.specMgr.byPointer(this.pointer); + this.normalizer.reset(); this.schema = this.normalizer.normalize(this.schema, this.normPointer, {resolved: true}); this.preprocessSchema(); @@ -119,7 +120,7 @@ export class JsonSchema extends BaseComponent implements OnInit { } trackByName(index: number, item: any): number { - return item.name; + return item.name + (item._pointer || ''); } ngOnInit() { diff --git a/lib/services/schema-normalizer.service.ts b/lib/services/schema-normalizer.service.ts index 57142ae7..f97d6d65 100644 --- a/lib/services/schema-normalizer.service.ts +++ b/lib/services/schema-normalizer.service.ts @@ -41,6 +41,10 @@ export class SchemaNormalizer { res['x-redoc-normalized'] = true; return res; } + + reset() { + this._dereferencer.reset(); + } } class SchemaWalker { @@ -178,6 +182,9 @@ class SchemaDereferencer { constructor(private _spec: SpecManager, private normalizator: SchemaNormalizer) { } + reset() { + this._refCouner.reset(); + } visit($ref) { this._refCouner.visit($ref); From 822d84c9f82c27f3f9c22f5b7b0483a792748ef4 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Tue, 13 Sep 2016 00:09:23 +0300 Subject: [PATCH 12/12] v1.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2f713273..16c7c602 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "redoc", "description": "Swagger-generated API Reference Documentation", - "version": "1.3.0", + "version": "1.3.1", "repository": { "type": "git", "url": "git://github.com/Rebilly/ReDoc"