From fae59c791718d5a8fa0a0e1d52a37d21e534e284 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Thu, 4 Feb 2016 11:49:00 +0200 Subject: [PATCH 01/25] Fix path params rendering --- lib/components/JsonSchema/json-schema.html | 2 +- lib/components/JsonSchema/json-schema.js | 14 ++++++++------ lib/components/ParamsList/params-list.html | 3 ++- lib/components/ParamsList/params-list.js | 5 +++++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/components/JsonSchema/json-schema.html b/lib/components/JsonSchema/json-schema.html index 298b3943..51a9b0a7 100644 --- a/lib/components/JsonSchema/json-schema.html +++ b/lib/components/JsonSchema/json-schema.html @@ -12,7 +12,7 @@
{{prop._displayType}} {{prop._displayFormat}} - Required + Required
This field value determines the exact schema:
diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index 75f723e3..0ed590aa 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -71,7 +71,8 @@ export default class JsonSchema extends BaseComponent { let discriminatorFieldIdx = -1; let props = Object.keys(schema.properties).map((prop, idx) => { let propData = schema.properties[prop]; - propData = this.injectPropData(prop, propData, schema); + let propPointer = JsonPointer.join(this.pointer, ['properties', prop]); + propData = JsonSchema.injectPropData(propData, prop, propPointer, this.requiredMap, schema); if (propData.isDiscriminator) discriminatorFieldIdx = idx; return propData; }); @@ -97,18 +98,19 @@ export default class JsonSchema extends BaseComponent { if (discrValues) discrValues.style.paddingLeft = maxWidth + 'px'; } - injectPropData(prop, propData, schema) { + static injectPropData(propData, propName, propPointer, requiredMap, schema) { propData = Object.assign({}, propData); - propData._name = prop; - propData.isRequired = this.requiredMap[prop]; + propData._name = propName; + propData.required = propData.required || (requiredMap && requiredMap[propName]); propData._displayType = propData.type; - propData.isDiscriminator = (schema.discriminator === prop); + propData.isDiscriminator = (schema && schema.discriminator === propName); if (propData.type === 'array') { let itemType = propData.items.type; let itemFormat = propData.items.format; if (itemType === 'object' || !itemType) { itemType = propData.items.title || 'object'; - propData._pointer = propData.items._pointer || JsonPointer.join(this.pointer, ['properties', prop, 'items']); + propData._pointer = propData.items._pointer + || JsonPointer.join(propPointer, ['items']); } propData._displayType = `${itemType}`; propData.format = itemFormat; diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html index fbbdb382..8bfe6853 100644 --- a/lib/components/ParamsList/params-list.html +++ b/lib/components/ParamsList/params-list.html @@ -6,7 +6,8 @@
- {{param.type}} + {{param._displayType}} {{param._displayFormat}} Required
diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.js index 2e296513..13233e5f 100644 --- a/lib/components/ParamsList/params-list.js +++ b/lib/components/ParamsList/params-list.js @@ -26,6 +26,11 @@ export default class ParamsList extends BaseComponent { this.data.bodyParam = bodyParam; } + params = params.map((paramData) => { + let propPointer = paramData._pointer; + return JsonSchema.injectPropData(paramData, paramData.name, propPointer); + }); + this.data.noParams = !(params.length || this.data.bodyParam); this.data.params = params; } From e861ae9adddf68acf8eb6a64255ec3bef050e791 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sat, 6 Feb 2016 17:00:31 +0200 Subject: [PATCH 02/25] Display enums info --- .../JsonSchema/json-schema-common.scss | 28 +++++++++++++++++-- lib/components/JsonSchema/json-schema.html | 3 ++ lib/components/JsonSchema/json-schema.js | 9 ++++++ lib/components/ParamsList/params-list.html | 3 ++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/lib/components/JsonSchema/json-schema-common.scss b/lib/components/JsonSchema/json-schema-common.scss index 434b63f3..78a260bf 100644 --- a/lib/components/JsonSchema/json-schema-common.scss +++ b/lib/components/JsonSchema/json-schema-common.scss @@ -72,11 +72,11 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; color: #999; } -.param-type.string { +.param-type.string, .enum-value.string { color: rgba(0, 80, 0, 0.7); } -.param-type.integer, .param-type.number { +.param-type.integer, .param-type.number, .enum-value.number { color: rgba(74, 139, 179, 0.8); } @@ -84,7 +84,7 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; color: rgba(0, 50, 159, 0.7); } -.param-type.boolean { +.param-type.boolean, .enum-value.boolean { color: firebrick; } @@ -158,3 +158,25 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; .param-schema .param-wrap:first-of-type .param-name:before { display: none !important; } + +.param-enum { + color: #666; + + &:before { + content: "Values: {" + } + + &:after { + content: "}" + } + + > .enum-value { + &:after { + content: ", "; + } + + &:last-of-type:after { + content: none; + } + } +} diff --git a/lib/components/JsonSchema/json-schema.html b/lib/components/JsonSchema/json-schema.html index 51a9b0a7..9828a49a 100644 --- a/lib/components/JsonSchema/json-schema.html +++ b/lib/components/JsonSchema/json-schema.html @@ -13,6 +13,9 @@ {{prop._displayType}} {{prop._displayFormat}} Required +
+ {{enumItem.val | json}} +
This field value determines the exact schema:
diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index 0ed590aa..a55aff42 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -99,14 +99,18 @@ export default class JsonSchema extends BaseComponent { } static injectPropData(propData, propName, propPointer, requiredMap, schema) { + let propEnum; + propData = Object.assign({}, propData); propData._name = propName; propData.required = propData.required || (requiredMap && requiredMap[propName]); propData._displayType = propData.type; propData.isDiscriminator = (schema && schema.discriminator === propName); + propEnum = propData.enum; if (propData.type === 'array') { let itemType = propData.items.type; let itemFormat = propData.items.format; + propEnum = propData.items.enum; if (itemType === 'object' || !itemType) { itemType = propData.items.title || 'object'; propData._pointer = propData.items._pointer @@ -128,6 +132,11 @@ export default class JsonSchema extends BaseComponent { } if (propData.format) propData._displayFormat = `<${propData.format}>`; + if (propEnum) { + propData.enum = propEnum.map((value) => { + return {val: value, type: typeof value}; + }); + } return propData; } diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html index 8bfe6853..86e66c5c 100644 --- a/lib/components/ParamsList/params-list.html +++ b/lib/components/ParamsList/params-list.html @@ -9,6 +9,9 @@ {{param._displayType}} {{param._displayFormat}} Required +
+ {{enumItem.val | json}} +
From 7f57558225e3e51d2626dee188cd8ed2b87d8756 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sat, 6 Feb 2016 18:02:10 +0200 Subject: [PATCH 03/25] fixed #12: schema representation on Safari --- lib/components/JsonSchema/json-schema-common.scss | 9 ++++++++- lib/components/JsonSchema/json-schema.html | 2 +- lib/components/JsonSchema/json-schema.js | 8 ++++---- lib/components/JsonSchema/json-schema.scss | 1 + lib/components/ParamsList/params-list.html | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/components/JsonSchema/json-schema-common.scss b/lib/components/JsonSchema/json-schema-common.scss index 78a260bf..7276e414 100644 --- a/lib/components/JsonSchema/json-schema-common.scss +++ b/lib/components/JsonSchema/json-schema-common.scss @@ -30,8 +30,9 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; } .param-name { + display: inline-block; font-size: 14px; - padding: $cell-padding $cell-spacing $cell-padding 0; + padding: $cell-padding 0 $cell-padding 0; font-weight: bold; box-sizing: border-box; line-height: $param-name-height; @@ -40,11 +41,17 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; position: relative; } +.param-name-content { + padding-right: $cell-spacing; + display: inline-block; +} + .param-info { width: 100%; padding: $cell-padding 0; box-sizing: border-box; border-bottom: 1px solid #ccc; + display: inline-block; } .param { diff --git a/lib/components/JsonSchema/json-schema.html b/lib/components/JsonSchema/json-schema.html index 9828a49a..14cf99ca 100644 --- a/lib/components/JsonSchema/json-schema.html +++ b/lib/components/JsonSchema/json-schema.html @@ -6,7 +6,7 @@
- {{prop._name}} + {{prop._name}}
diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index a55aff42..1128f072 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -86,12 +86,12 @@ export default class JsonSchema extends BaseComponent { adjustNameColumnWidth() { // TODO handle internal schemes differently - let names = [].slice.call(this.element.querySelectorAll('.param-name')); + let names = [].slice.call(this.element.querySelectorAll('.param-name-content')); let widths = names.map(el => el.offsetWidth); let maxWidth = Math.max(...widths); if (!maxWidth) return; names.forEach(el => { - el.style.minWidth = maxWidth + 'px'; + el.parentNode.style.minWidth = maxWidth + 'px'; }); let discrValues = this.element.querySelector('tabs ul'); @@ -141,8 +141,8 @@ export default class JsonSchema extends BaseComponent { return propData; } - init() { - setTimeout(() => this.adjustNameColumnWidth()); + ngAfterViewInit() { + this.adjustNameColumnWidth(); } } JsonSchema.parameters = JsonSchema.parameters.concat([[ElementRef]]); diff --git a/lib/components/JsonSchema/json-schema.scss b/lib/components/JsonSchema/json-schema.scss index 50948819..a8793f9e 100644 --- a/lib/components/JsonSchema/json-schema.scss +++ b/lib/components/JsonSchema/json-schema.scss @@ -3,6 +3,7 @@ /* styles for array-schema for array */ $array-marker-font-sz: 12px; $array-marker-line-height: 1.5; + .params-wrap.params-array:before, .params-wrap.params-array:after { display: block; font-weight: bold; diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html index 86e66c5c..2a51db6a 100644 --- a/lib/components/ParamsList/params-list.html +++ b/lib/components/ParamsList/params-list.html @@ -2,7 +2,7 @@
- {{param.name}} + {{param.name}}
From fa81187e10f3702e2779d85bfea66510b11981c8 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 7 Feb 2016 16:10:32 +0200 Subject: [PATCH 04/25] Use operationId in links; fixes #14 --- lib/components/Method/method.html | 2 +- lib/components/Method/method.js | 5 +++ lib/components/MethodsList/methods-list.html | 4 +-- lib/components/SideMenu/side-menu.js | 29 +++++++++++++---- lib/components/SideMenu/side-menu.spec.js | 34 +++++++++++++++++--- lib/utils/SchemaManager.js | 6 +++- tests/unit/SchemaManager.spec.js | 2 +- 7 files changed, 66 insertions(+), 16 deletions(-) diff --git a/lib/components/Method/method.html b/lib/components/Method/method.html index e677c448..1a428a93 100644 --- a/lib/components/Method/method.html +++ b/lib/components/Method/method.html @@ -1,7 +1,7 @@

- {{data.methodInfo.summary}} + {{data.methodInfo.summary}}

{{data.httpMethod}} diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js index 13aa8178..3ab6f066 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.js @@ -28,6 +28,11 @@ export default class Method extends BaseComponent { this.data.methodInfo = this.componentSchema; this.data.methodInfo.tags = this.filterMainTags(this.data.methodInfo.tags); this.data.bodyParam = this.findBodyParam(); + if (this.componentSchema.operationId) { + this.data.methodAnchor = 'operation/' + this.componentSchema.operationId; + } else { + this.data.methodAnchor = 'tag/' + this.tag + this.pointer; + } } filterMainTags(tags) { diff --git a/lib/components/MethodsList/methods-list.html b/lib/components/MethodsList/methods-list.html index 4532d941..10e0ccf6 100644 --- a/lib/components/MethodsList/methods-list.html +++ b/lib/components/MethodsList/methods-list.html @@ -1,10 +1,10 @@
-

{{tag.name}}

+

{{tag.name}}

+ [attr.tag]="method.tag" [tag]="method.tag" [attr.operation-id]="method.operationId">
diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.js index 614b70bc..fe050c8f 100644 --- a/lib/components/SideMenu/side-menu.js +++ b/lib/components/SideMenu/side-menu.js @@ -3,7 +3,8 @@ import {RedocComponent, BaseComponent} from '../base'; import {redocEvents} from '../../events'; -import {NgZone, ChangeDetectionStrategy, ElementRef} from 'angular2/core'; +import {NgZone, ChangeDetectionStrategy, ElementRef, forwardRef} from 'angular2/core'; +import Redoc from '../Redoc/redoc'; import {document} from 'angular2/src/facade/browser'; import {BrowserDomAdapter} from 'angular2/platform/browser'; import {global} from 'angular2/src/facade/lang'; @@ -60,10 +61,18 @@ export default class SideMenu extends BaseComponent { let hash = this.adapter.getLocation().hash; if (!hash) return; + let el; hash = hash.substr(1); - let tag = hash.split('/')[0]; - let ptr = hash.substr(tag.length); - let el = this.getMethodEl(ptr, tag); + let namespace = hash.split('/')[0]; + let ptr = hash.substr(namespace.length + 1); + if (namespace === 'operation') { + el = this.getMethodElByOperId(ptr); + } else if (namespace === 'tag') { + let tag = ptr.split('/')[0]; + ptr = ptr.substr(tag.length); + el = this.getMethodElByPtr(ptr, tag); + } + if (el) this.scrollTo(el); if (evt) evt.preventDefault(); } @@ -170,13 +179,18 @@ export default class SideMenu extends BaseComponent { return (methodIdx === 0 && catIdx === 0); } - getMethodEl(ptr, tag) { + getMethodElByPtr(ptr, tag) { let selector = ptr ? `[pointer="${ptr}"][tag="${tag}"]` : `[tag="${tag}"]`; return document.querySelector(selector); } + getMethodElByOperId(operationId) { + let selector =`[operation-id="${operationId}"]`; + return document.querySelector(selector); + } + getCurrentMethodEl() { - return this.getMethodEl(this.activeMethodPtr, this.data.menu[this.activeCatIdx].name); + return this.getMethodElByPtr(this.activeMethodPtr, this.data.menu[this.activeCatIdx].name); } /* returns 1 if element if above the view, 0 if in view and -1 below the view */ @@ -240,4 +254,5 @@ export default class SideMenu extends BaseComponent { this.changeActive(CHANGE.INITIAL); } } -SideMenu.parameters = SideMenu.parameters.concat([[ElementRef], [BrowserDomAdapter], [NgZone]]); +SideMenu.parameters = SideMenu.parameters.concat([[ElementRef], + [BrowserDomAdapter], [NgZone], [forwardRef(() => Redoc)] ]); diff --git a/lib/components/SideMenu/side-menu.spec.js b/lib/components/SideMenu/side-menu.spec.js index 8b3da94f..9f154f00 100644 --- a/lib/components/SideMenu/side-menu.spec.js +++ b/lib/components/SideMenu/side-menu.spec.js @@ -75,8 +75,22 @@ describe('Redoc components', () => { }); }); - it('should scroll to method when location hash is present', (done) => { - let hash = '#pet/paths/~1pet~1findByStatus/get'; + it('should scroll to method when location hash is present [jp]', (done) => { + let hash = '#tag/pet/paths/~1pet~1findByStatus/get'; + spyOn(component.adapter, 'getLocation').and.returnValue({hash: hash}); + spyOn(component, 'hashScroll').and.callThrough(); + spyOn(window, 'scrollTo').and.stub(); + redocEvents.bootstrapped.next(); + setTimeout(() => { + expect(component.hashScroll).toHaveBeenCalled(); + let scrollY = window.scrollTo.calls.argsFor(0)[1]; + expect(scrollY).toBeGreaterThan(0); + done(); + }); + }); + + it('should scroll to method when location hash is present [operation]', (done) => { + let hash = '#operation/getPetById'; spyOn(component.adapter, 'getLocation').and.returnValue({hash: hash}); spyOn(component, 'hashScroll').and.callThrough(); spyOn(window, 'scrollTo').and.stub(); @@ -121,8 +135,20 @@ describe('Redoc components', () => { expect(component.data).not.toBeNull(); }); - it('should scroll to method when location hash is present', (done) => { - let hash = '#pet/paths/~1pet~1findByStatus/get'; + it('should scroll to method when location hash is present [jp]', (done) => { + let hash = '#tag/pet/paths/~1pet~1findByStatus/get'; + spyOn(component.adapter, 'getLocation').and.returnValue({hash: hash}); + spyOn(component, 'hashScroll').and.callThrough(); + redocEvents.bootstrapped.next(); + setTimeout(() => { + expect(component.hashScroll).toHaveBeenCalled(); + expect(component.scrollParent.scrollTop).toBeGreaterThan(0); + done(); + }); + }); + + it('should scroll to method when location hash is present [operation]', (done) => { + let hash = '#operation/getPetById'; spyOn(component.adapter, 'getLocation').and.returnValue({hash: hash}); spyOn(component, 'hashScroll').and.callThrough(); redocEvents.bootstrapped.next(); diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.js index 254fd88d..2c11af6a 100644 --- a/lib/utils/SchemaManager.js +++ b/lib/utils/SchemaManager.js @@ -150,7 +150,11 @@ export default class SchemaManager { } if (tagDetails['x-traitTag']) continue; if (!tagDetails.methods) tagDetails.methods = []; - tagDetails.methods.push({pointer: methodPointer, summary: methodSummary}); + tagDetails.methods.push({ + pointer: methodPointer, + summary: methodSummary, + operationId: methodInfo.operationId + }); } } } diff --git a/tests/unit/SchemaManager.spec.js b/tests/unit/SchemaManager.spec.js index 0a2bfbf8..1ec4ec87 100644 --- a/tests/unit/SchemaManager.spec.js +++ b/tests/unit/SchemaManager.spec.js @@ -165,7 +165,7 @@ describe('Utils', () => { info.should.be.an.Object(); info.methods.should.be.an.Array(); for (let methodInfo of info.methods) { - methodInfo.should.have.keys('pointer', 'summary'); + methodInfo.should.have.properties(['pointer', 'summary']); let methSchema = schemaMgr.byPointer(methodInfo.pointer); expect(methSchema).not.toBeNull(); if (methSchema.summary) { From ea6df01bfde2d755caa547136def79c264051911 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 7 Feb 2016 16:11:15 +0200 Subject: [PATCH 05/25] Cache same schema views --- lib/components/JsonSchema/json-schema-lazy.js | 50 ++++++++++++++++++- lib/components/JsonSchema/json-schema.js | 11 +++- lib/components/JsonSchema/json-schema.scss | 3 ++ lib/components/ParamsList/params-list.html | 4 +- lib/components/ParamsList/params-list.js | 3 +- lib/components/Redoc/redoc.js | 6 +-- 6 files changed, 66 insertions(+), 11 deletions(-) diff --git a/lib/components/JsonSchema/json-schema-lazy.js b/lib/components/JsonSchema/json-schema-lazy.js index dddfb83b..bda6261e 100644 --- a/lib/components/JsonSchema/json-schema-lazy.js +++ b/lib/components/JsonSchema/json-schema-lazy.js @@ -5,10 +5,15 @@ import {CORE_DIRECTIVES} from 'angular2/common'; import JsonSchema from './json-schema'; import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader'; import OptionsManager from '../../options'; +import SchemaManager from '../../utils/SchemaManager'; + + +var cache = {}; + @Component({ selector: 'json-schema-lazy', - inputs: ['pointer'] + inputs: ['pointer', 'auto'] }) @View({ template: '', @@ -21,6 +26,11 @@ export default class JsonSchemaLazy { this.dcl = dcl; } + normalizePointer() { + let schema = SchemaManager.instance().byPointer(this.pointer); + return schema && schema.$ref || this.pointer; + } + load() { if (OptionsManager.instance().options.disableLazySchemas) return; if (this.loaded) return; @@ -31,5 +41,43 @@ export default class JsonSchemaLazy { } this.loaded = true; } + + // cache JsonSchema view + loadCached() { + this.pointer = this.normalizePointer(this.pointer); + if (cache[this.pointer]) { + cache[this.pointer].then((compRef) => { + setTimeout( ()=> { + let element = compRef.location.nativeElement; + + // skip caching view with discriminator as it needs attached controller + if (element.querySelector('.discriminator')) { + this.dcl.loadNextToLocation(JsonSchema, this.elementRef).then((compRef) => { + compRef.instance.pointer = this.pointer; + compRef.hostView.changeDetectorRef.markForCheck(); + }); + return; + } + insertAfter(element.cloneNode(true), this.elementRef.nativeElement); + } ); + }); + } else { + cache[this.pointer] = this.dcl.loadNextToLocation(JsonSchema, this.elementRef).then((compRef) => { + compRef.instance.pointer = this.pointer; + compRef.hostView.changeDetectorRef.markForCheck(); + return compRef; + }); + } + } + + ngAfterViewInit() { + if (!this.auto) return; + this.loadCached(); + } } + +function insertAfter(newNode, referenceNode) { + referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); +} + JsonSchemaLazy.parameters = [[ElementRef], [DynamicComponentLoader]]; diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index 1128f072..579bb7f4 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -87,7 +87,7 @@ export default class JsonSchema extends BaseComponent { adjustNameColumnWidth() { // TODO handle internal schemes differently let names = [].slice.call(this.element.querySelectorAll('.param-name-content')); - let widths = names.map(el => el.offsetWidth); + let widths = [144];//names.map(el => el.offsetWidth); let maxWidth = Math.max(...widths); if (!maxWidth) return; names.forEach(el => { @@ -142,7 +142,14 @@ export default class JsonSchema extends BaseComponent { } ngAfterViewInit() { - this.adjustNameColumnWidth(); + // adjust widht only on parent level + let el = this.element.parentElement; + while(el.tagName !== 'JSON-SCHEMA' && el.tagName !== 'REDOC') { + el = el.parentElement; + } + if (el.tagName === 'REDOC' ) { + this.adjustNameColumnWidth(); + } } } JsonSchema.parameters = JsonSchema.parameters.concat([[ElementRef]]); diff --git a/lib/components/JsonSchema/json-schema.scss b/lib/components/JsonSchema/json-schema.scss index a8793f9e..01d4ca51 100644 --- a/lib/components/JsonSchema/json-schema.scss +++ b/lib/components/JsonSchema/json-schema.scss @@ -3,6 +3,9 @@ /* styles for array-schema for array */ $array-marker-font-sz: 12px; $array-marker-line-height: 1.5; +:host { + display: block; +} .params-wrap.params-array:before, .params-wrap.params-array:after { display: block; diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html index 2a51db6a..e4583e9a 100644 --- a/lib/components/ParamsList/params-list.html +++ b/lib/components/ParamsList/params-list.html @@ -23,7 +23,7 @@
- - + +

diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.js index 13233e5f..d027db7c 100644 --- a/lib/components/ParamsList/params-list.js +++ b/lib/components/ParamsList/params-list.js @@ -2,12 +2,13 @@ import {RedocComponent, BaseComponent} from '../base'; import JsonSchema from '../JsonSchema/json-schema'; +import JsonSchemaLazy from '../JsonSchema/json-schema-lazy'; @RedocComponent({ selector: 'params-list', templateUrl: './lib/components/ParamsList/params-list.html', styleUrls: ['./lib/components/ParamsList/params-list.css'], - directives: [JsonSchema] + directives: [JsonSchema, JsonSchemaLazy] }) export default class ParamsList extends BaseComponent { constructor(schemaMgr) { diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index 77b3bf8f..2a000ca1 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -148,7 +148,7 @@ export default class Redoc extends BaseComponent { (appRef) => { Redoc.hideLoadingAnimation(); Redoc.appRef = appRef; - redocEvents.bootstrapped.next(); + setTimeout(() => redocEvents.bootstrapped.next()); console.log('ReDoc bootstrapped!'); }, error => { @@ -193,7 +193,3 @@ export default class Redoc extends BaseComponent { } } Redoc.parameters = Redoc.parameters.concat([[OptionsManager], [ElementRef], [BrowserDomAdapter]]); - -// TODO -// this doesn't work in side-menu.js because of some circular references issue -SideMenu.parameters = SideMenu.parameters.concat([[Redoc]]); From 4acae04d96a5974af51dc8e89cfeaaf563b1e62f Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 7 Feb 2016 16:11:58 +0200 Subject: [PATCH 06/25] Animate loading message --- lib/components/Redoc/redoc.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index 2a000ca1..ddf5ce26 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -93,6 +93,14 @@ export default class Redoc extends BaseComponent { position: relative; display: block; min-height:350px; + animation: 2s move linear infinite; + } + + @keyframes move { + 0% {transform: translateY(0px)} + 25% {transform: translateY(-10px)} + 50% {transform: translateY(0px)} + 75% {transform: translateY(10px)} } redoc.loading:before { From 7e4d56c405651a0d34521188f79381e346fe511c Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 7 Feb 2016 16:52:59 +0200 Subject: [PATCH 07/25] IE/Edge ui fixes --- lib/common/components/Zippy/zippy.scss | 1 + lib/components/ParamsList/params-list.scss | 26 +++++++++++++--------- lib/components/Redoc/redoc.js | 10 ++++----- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/lib/common/components/Zippy/zippy.scss b/lib/common/components/Zippy/zippy.scss index 97958a38..f31e943b 100644 --- a/lib/common/components/Zippy/zippy.scss +++ b/lib/common/components/Zippy/zippy.scss @@ -64,6 +64,7 @@ span.zippy-indicator { } .zippy-hidden { + overflow: hidden; visibility: hidden; height: 0; padding: 0; diff --git a/lib/components/ParamsList/params-list.scss b/lib/components/ParamsList/params-list.scss index 23c9b10a..2475d8f7 100644 --- a/lib/components/ParamsList/params-list.scss +++ b/lib/components/ParamsList/params-list.scss @@ -28,23 +28,27 @@ display: table-row; } -.param:first-of-type .param-name:before { - content: ""; - display: block; - position: absolute; - left: -$lines-width; - top: 0; - border-left: $line-border-erase; - height: ($param-name-height/2) + $cell-padding; +.param:last-of-type > .param-name { + border-left: 0; + &:after { + content: ""; + display: block; + position: absolute; + left: 0; + border-left: $line-border; + height: ($param-name-height/2) + $cell-padding + $lines-width; + background-color: white; + top: 0; + } } -.param:last-of-type .param-name:after { +.param:first-of-type .param-name:after { content: ""; display: block; position: absolute; left: -$lines-width; border-left: $line-border-erase; - top: ($param-name-height/2) + $cell-padding + $lines-width; + height: ($param-name-height/2) + $cell-padding; background-color: white; - bottom: 0; + top: 0; } diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index ddf5ce26..827a0b8e 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -93,14 +93,13 @@ export default class Redoc extends BaseComponent { position: relative; display: block; min-height:350px; - animation: 2s move linear infinite; } @keyframes move { - 0% {transform: translateY(0px)} - 25% {transform: translateY(-10px)} - 50% {transform: translateY(0px)} - 75% {transform: translateY(10px)} + 0% {transform: translateY(10px)} + 25% {transform: translateY(0px)} + 50% {transform: translateY(10px)} + 75% {transform: translateY(20px)} } redoc.loading:before { @@ -120,6 +119,7 @@ export default class Redoc extends BaseComponent { z-index: 9999; opacity: 1; transition: all 0.6s ease-out; + animation: 2s move linear infinite; } redoc.loading-remove:before { From f723240145341359a6aeaee99600956d120041c4 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Sun, 7 Feb 2016 16:59:41 +0200 Subject: [PATCH 08/25] Fix tests --- lib/components/JsonSchema/json-schema.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index 579bb7f4..5fc7734d 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -144,10 +144,10 @@ export default class JsonSchema extends BaseComponent { ngAfterViewInit() { // adjust widht only on parent level let el = this.element.parentElement; - while(el.tagName !== 'JSON-SCHEMA' && el.tagName !== 'REDOC') { + while(el && el.tagName !== 'JSON-SCHEMA' && el.tagName !== 'REDOC') { el = el.parentElement; } - if (el.tagName === 'REDOC' ) { + if (el && el.tagName === 'REDOC' ) { this.adjustNameColumnWidth(); } } From db7f500ba0b235ce5da38780503d81d71f6dfd8f Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 10 Feb 2016 13:19:50 +0200 Subject: [PATCH 09/25] IE10, IE9 Fixes Use Reflect.metadate decorator instead of Class.parameters Add fallback old syntax of flexbox Other minor styling fixes --- .eslintrc | 3 ++- .../components/StickySidebar/sticky-sidebar.js | 3 +-- lib/common/components/Tabs/tabs.js | 16 ++++++++++++---- lib/common/styles/_variables.scss | 2 +- .../JsonSchema/json-schema-common.scss | 7 ++++++- lib/components/JsonSchema/json-schema-lazy.js | 6 +++--- lib/components/JsonSchema/json-schema.js | 7 ++++--- lib/components/Method/method.js | 1 + lib/components/Redoc/redoc.js | 17 +++++++++-------- .../RequestSamples/request-samples.js | 9 ++++----- lib/components/SchemaSample/schema-sample.js | 6 +++--- lib/components/SideMenu/side-menu.js | 12 +++++++----- lib/components/base.js | 4 +++- lib/utils/JsonPointer.js | 2 ++ lib/utils/pipes.js | 1 + 15 files changed, 59 insertions(+), 37 deletions(-) diff --git a/.eslintrc b/.eslintrc index fdacb7f1..4876b92f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,7 +9,8 @@ "globals": { "should": true, "expect": true, - "sinon": true + "sinon": true, + "Reflect": true }, "rules": { "quotes": [2, "single"], diff --git a/lib/common/components/StickySidebar/sticky-sidebar.js b/lib/common/components/StickySidebar/sticky-sidebar.js index ad99a264..4ac1010e 100644 --- a/lib/common/components/StickySidebar/sticky-sidebar.js +++ b/lib/common/components/StickySidebar/sticky-sidebar.js @@ -7,6 +7,7 @@ import {BrowserDomAdapter} from 'angular2/platform/browser'; selector: '[sticky-sidebar]', inputs: ['scrollParent', 'scrollYOffset'] }) +@Reflect.metadata('parameters', [[ElementRef], [BrowserDomAdapter]]) export default class StickySidebar { constructor(elementRef, dom) { this.element = elementRef.nativeElement; @@ -59,5 +60,3 @@ export default class StickySidebar { this.unbind(); } } - -StickySidebar.parameters = [ [ElementRef], [BrowserDomAdapter] ]; diff --git a/lib/common/components/Tabs/tabs.js b/lib/common/components/Tabs/tabs.js index 5345f282..c73f3745 100644 --- a/lib/common/components/Tabs/tabs.js +++ b/lib/common/components/Tabs/tabs.js @@ -65,16 +65,24 @@ export class Tabs { }) @View({ template: ` -
+
- ` + `, + styles: [` + .tab-wrap { + display: none; + } + + .tab-wrap.active { + display: block; + }` + ] }) +@Reflect.metadata('parameters', [ [Tabs] ]) export class Tab { constructor(tabs) { this.active = false; tabs.addTab(this); } } - -Tab.parameters = [ [ Tabs ] ]; diff --git a/lib/common/styles/_variables.scss b/lib/common/styles/_variables.scss index 9df2da78..2252ed9a 100644 --- a/lib/common/styles/_variables.scss +++ b/lib/common/styles/_variables.scss @@ -15,6 +15,6 @@ $samples-panel-width: 40%; $sample-panel-headers-color: #8A9094; $sample-panel-color: #CFD2D3; -$tree-lines-color: #7D97CE; +$tree-lines-color: #CDD9F3;//#7D97CE; $side-menu-mobile-breakpoint: 1000px; diff --git a/lib/components/JsonSchema/json-schema-common.scss b/lib/components/JsonSchema/json-schema-common.scss index 7276e414..e3e7ce97 100644 --- a/lib/components/JsonSchema/json-schema-common.scss +++ b/lib/components/JsonSchema/json-schema-common.scss @@ -30,6 +30,8 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; } .param-name { + flex-grow: 0; + -ms-flex-grow: 0; display: inline-block; font-size: 14px; padding: $cell-padding 0 $cell-padding 0; @@ -47,7 +49,9 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; } .param-info { - width: 100%; + //width: 100%; + flex-grow: 1; + -ms-flex-grow: 1; padding: $cell-padding 0; box-sizing: border-box; border-bottom: 1px solid #ccc; @@ -56,6 +60,7 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin; .param { display: flex; + display: -ms-flexbox; } .param-required { diff --git a/lib/components/JsonSchema/json-schema-lazy.js b/lib/components/JsonSchema/json-schema-lazy.js index bda6261e..83bd4577 100644 --- a/lib/components/JsonSchema/json-schema-lazy.js +++ b/lib/components/JsonSchema/json-schema-lazy.js @@ -2,8 +2,9 @@ import {Component, View, ElementRef} from 'angular2/core'; import {CORE_DIRECTIVES} from 'angular2/common'; -import JsonSchema from './json-schema'; import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader'; + +import JsonSchema from './json-schema'; import OptionsManager from '../../options'; import SchemaManager from '../../utils/SchemaManager'; @@ -19,6 +20,7 @@ var cache = {}; template: '', directives: [CORE_DIRECTIVES] }) +@Reflect.metadata('parameters', [[ElementRef], [DynamicComponentLoader]]) export default class JsonSchemaLazy { constructor(elementRef, dcl) { @@ -79,5 +81,3 @@ export default class JsonSchemaLazy { function insertAfter(newNode, referenceNode) { referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); } - -JsonSchemaLazy.parameters = [[ElementRef], [DynamicComponentLoader]]; diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index 5fc7734d..192c64e2 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -1,8 +1,9 @@ 'use strict'; -import {RedocComponent, BaseComponent} from '../base'; -import {Tabs, Tab} from '../../common/components/Tabs/tabs'; import {ElementRef} from 'angular2/core'; + +import {RedocComponent, BaseComponent, SchemaManager} from '../base'; +import {Tabs, Tab} from '../../common/components/Tabs/tabs'; import JsonPointer from '../../utils/JsonPointer'; @RedocComponent({ @@ -12,6 +13,7 @@ import JsonPointer from '../../utils/JsonPointer'; directives: [JsonSchema, Tabs, Tab], inputs: ['isArray', 'final'] }) +@Reflect.metadata('parameters', [[SchemaManager], [ElementRef]]) export default class JsonSchema extends BaseComponent { constructor(schemaMgr, elementRef) { super(schemaMgr); @@ -152,4 +154,3 @@ export default class JsonSchema extends BaseComponent { } } } -JsonSchema.parameters = JsonSchema.parameters.concat([[ElementRef]]); diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js index 3ab6f066..fdad9d66 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.js @@ -2,6 +2,7 @@ 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'; diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index 827a0b8e..0c81d626 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -1,5 +1,12 @@ 'use strict'; +import {ChangeDetectionStrategy} from 'angular2/core'; +import {ElementRef} from 'angular2/core'; +import {BrowserDomAdapter, bootstrap} from 'angular2/platform/browser'; +import detectScollParent from 'scrollparent'; + +import {isFunction, isString} from 'angular2/src/facade/lang'; + import {RedocComponent, BaseComponent} from '../base'; import SchemaManager from '../../utils/SchemaManager'; @@ -11,13 +18,6 @@ import StickySidebar from '../../common/components/StickySidebar/sticky-sidebar' import OptionsManager from '../../options'; import {redocEvents} from '../../events'; -import {ChangeDetectionStrategy} from 'angular2/core'; -import {ElementRef} from 'angular2/core'; -import {BrowserDomAdapter, bootstrap} from 'angular2/platform/browser'; -import detectScollParent from 'scrollparent'; - -import {isFunction, isString} from 'angular2/src/facade/lang'; - let optionNames = new Set(['scrollYOffset', 'disableLazySchemas']); let dom = new BrowserDomAdapter(); @@ -30,6 +30,7 @@ let dom = new BrowserDomAdapter(); directives: [ApiInfo, ApiLogo, MethodsList, SideMenu, StickySidebar], changeDetection: ChangeDetectionStrategy.Default }) +@Reflect.metadata('parameters', [[SchemaManager], [OptionsManager], [ElementRef], [BrowserDomAdapter]]) export default class Redoc extends BaseComponent { constructor(schemaMgr, optionsMgr, elementRef, dom) { super(schemaMgr); @@ -100,6 +101,7 @@ export default class Redoc extends BaseComponent { 25% {transform: translateY(0px)} 50% {transform: translateY(10px)} 75% {transform: translateY(20px)} + 100% {transform: translateY(10px)} } redoc.loading:before { @@ -200,4 +202,3 @@ export default class Redoc extends BaseComponent { } } } -Redoc.parameters = Redoc.parameters.concat([[OptionsManager], [ElementRef], [BrowserDomAdapter]]); diff --git a/lib/components/RequestSamples/request-samples.js b/lib/components/RequestSamples/request-samples.js index f193c033..032c0f98 100644 --- a/lib/components/RequestSamples/request-samples.js +++ b/lib/components/RequestSamples/request-samples.js @@ -1,12 +1,12 @@ 'use strict'; -import {RedocComponent, BaseComponent} from '../base'; +import {ViewChildren, QueryList, ChangeDetectorRef, ChangeDetectionStrategy} from 'angular2/core'; + +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 {ViewChildren, QueryList, ChangeDetectorRef, ChangeDetectionStrategy} from 'angular2/core'; import {redocEvents} from '../../events'; @RedocComponent({ @@ -18,6 +18,7 @@ import {redocEvents} from '../../events'; pipes: [PrismPipe], changeDetection: ChangeDetectionStrategy.OnPush }) +@Reflect.metadata('parameters', [[SchemaManager], [new ViewChildren(Tabs), QueryList], [ChangeDetectorRef]]) export default class RequestSamples extends BaseComponent { constructor(schemaMgr, tabs, changeDetector) { super(schemaMgr); @@ -46,5 +47,3 @@ export default class RequestSamples extends BaseComponent { this.data.samples = this.componentSchema['x-code-samples'] || []; } } - -RequestSamples.parameters = RequestSamples.parameters.concat([ [new ViewChildren(Tabs), QueryList], [ChangeDetectorRef] ]); diff --git a/lib/components/SchemaSample/schema-sample.js b/lib/components/SchemaSample/schema-sample.js index 43a014a7..c0555c60 100644 --- a/lib/components/SchemaSample/schema-sample.js +++ b/lib/components/SchemaSample/schema-sample.js @@ -1,11 +1,11 @@ 'use strict'; -import {RedocComponent, BaseComponent} from '../base'; +import {ElementRef} from 'angular2/core'; import SchemaSampler from 'json-schema-instantiator'; import {JsonFormatter} from '../../utils/JsonFormatterPipe'; -import {ElementRef} from 'angular2/core'; +import {RedocComponent, BaseComponent, SchemaManager} from '../base'; @RedocComponent({ selector: 'schema-sample', @@ -13,6 +13,7 @@ import {ElementRef} from 'angular2/core'; pipes: [JsonFormatter], styleUrls: ['./lib/components/SchemaSample/schema-sample.css'] }) +@Reflect.metadata('parameters', [[SchemaManager], [ElementRef]]) export default class SchemaSample extends BaseComponent { constructor(schemaMgr, elementRef) { super(schemaMgr); @@ -54,4 +55,3 @@ export default class SchemaSample extends BaseComponent { }); } } -SchemaSample.parameters = SchemaSample.parameters.concat([[ElementRef]]); diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.js index fe050c8f..d03c85d5 100644 --- a/lib/components/SideMenu/side-menu.js +++ b/lib/components/SideMenu/side-menu.js @@ -1,14 +1,14 @@ 'use strict'; -import {RedocComponent, BaseComponent} from '../base'; -import {redocEvents} from '../../events'; - import {NgZone, ChangeDetectionStrategy, ElementRef, forwardRef} from 'angular2/core'; import Redoc from '../Redoc/redoc'; import {document} from 'angular2/src/facade/browser'; import {BrowserDomAdapter} from 'angular2/platform/browser'; import {global} from 'angular2/src/facade/lang'; +import {RedocComponent, BaseComponent, SchemaManager} from '../base'; +import {redocEvents} from '../../events'; + const CHANGE = { NEXT : 1, BACK : -1, @@ -27,6 +27,8 @@ const INVIEW_POSITION = { styleUrls: ['./lib/components/SideMenu/side-menu.css'], changeDetection: ChangeDetectionStrategy.Default }) +@Reflect.metadata('parameters', [[SchemaManager], [ElementRef], + [BrowserDomAdapter], [NgZone], [forwardRef(() => Redoc)]]) export default class SideMenu extends BaseComponent { constructor(schemaMgr, elementRef, adapter, zone, redoc) { super(schemaMgr); @@ -254,5 +256,5 @@ export default class SideMenu extends BaseComponent { this.changeActive(CHANGE.INITIAL); } } -SideMenu.parameters = SideMenu.parameters.concat([[ElementRef], - [BrowserDomAdapter], [NgZone], [forwardRef(() => Redoc)] ]); +//SideMenu.parameters = SideMenu.parameters.concat([[ElementRef], +// [BrowserDomAdapter], [NgZone], [forwardRef(() => Redoc)] ]); diff --git a/lib/components/base.js b/lib/components/base.js index c27c7049..c8e7146a 100644 --- a/lib/components/base.js +++ b/lib/components/base.js @@ -5,6 +5,8 @@ import SchemaManager from '../utils/SchemaManager'; import JsonPointer from '../utils/JsonPointer'; import {MarkedPipe, JsonPointerEscapePipe} from '../utils/pipes'; +export { SchemaManager }; + // common inputs for all components let commonInputs = ['pointer']; // json pointer to the schema chunk @@ -77,6 +79,7 @@ export function RedocComponent(options) { * Generic Component * @class */ +@Reflect.metadata('parameters', [[SchemaManager]]) export class BaseComponent { constructor(schemaMgr) { this.schemaMgr = schemaMgr; @@ -208,4 +211,3 @@ export class BaseComponent { */ destroy() {} } -BaseComponent.parameters = [[SchemaManager]]; diff --git a/lib/utils/JsonPointer.js b/lib/utils/JsonPointer.js index 165bcffd..8dd8fc90 100644 --- a/lib/utils/JsonPointer.js +++ b/lib/utils/JsonPointer.js @@ -63,4 +63,6 @@ export class JsonPointer extends JsonPointerLib { JsonPointerLib._origParse = JsonPointerLib.parse; JsonPointerLib.parse = JsonPointer.parse; + +Object.assign(JsonPointer, JsonPointerLib); export default JsonPointer; diff --git a/lib/utils/pipes.js b/lib/utils/pipes.js index df4bd4e2..32c23fbc 100644 --- a/lib/utils/pipes.js +++ b/lib/utils/pipes.js @@ -5,6 +5,7 @@ import {isString, stringify, isBlank} from 'angular2/src/facade/lang'; import {BaseException} from 'angular2/src/facade/exceptions'; import {JsonPointer} from './JsonPointer'; import marked from 'marked'; + import Prism from 'prismjs'; import 'prismjs/components/prism-actionscript.js'; import 'prismjs/components/prism-c.js'; From 3fa43e72cf753051a8d9264fe02aefe83659e041 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 10 Feb 2016 13:22:40 +0200 Subject: [PATCH 10/25] minor styles update --- lib/common/styles/_variables.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common/styles/_variables.scss b/lib/common/styles/_variables.scss index 2252ed9a..9df2da78 100644 --- a/lib/common/styles/_variables.scss +++ b/lib/common/styles/_variables.scss @@ -15,6 +15,6 @@ $samples-panel-width: 40%; $sample-panel-headers-color: #8A9094; $sample-panel-color: #CFD2D3; -$tree-lines-color: #CDD9F3;//#7D97CE; +$tree-lines-color: #7D97CE; $side-menu-mobile-breakpoint: 1000px; From e68054553de799fbf89f37b210d61feb7efbad7b Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 10 Feb 2016 13:36:10 +0200 Subject: [PATCH 11/25] Fix build --- lib/common/components/Tabs/tabs.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/common/components/Tabs/tabs.js b/lib/common/components/Tabs/tabs.js index c73f3745..44a6e8d9 100644 --- a/lib/common/components/Tabs/tabs.js +++ b/lib/common/components/Tabs/tabs.js @@ -69,6 +69,7 @@ export class Tabs {
`, + directives: [CORE_DIRECTIVES], styles: [` .tab-wrap { display: none; From 5485df84fe266a45a7190e2be73c674729de8424 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 10 Feb 2016 15:48:07 +0200 Subject: [PATCH 12/25] Various refactoring - renam DOM elements variables to start from $ - use DI for OptionsManager - move loading styles into separate CSS file - minor other refactors --- .../StickySidebar/sticky-sidebar.js | 23 ++-- lib/components/JsonSchema/json-schema-lazy.js | 23 ++-- lib/components/JsonSchema/json-schema.js | 39 +++--- .../Redoc/redoc-loading-styles.scss | 37 ++++++ lib/components/Redoc/redoc.html | 2 +- lib/components/Redoc/redoc.js | 116 +++--------------- .../ResponsesList/responses-list.js | 2 - lib/components/SideMenu/side-menu.js | 86 +++++++------ lib/options.js | 78 ++++++++---- 9 files changed, 198 insertions(+), 208 deletions(-) create mode 100644 lib/components/Redoc/redoc-loading-styles.scss diff --git a/lib/common/components/StickySidebar/sticky-sidebar.js b/lib/common/components/StickySidebar/sticky-sidebar.js index 4ac1010e..701204d1 100644 --- a/lib/common/components/StickySidebar/sticky-sidebar.js +++ b/lib/common/components/StickySidebar/sticky-sidebar.js @@ -10,14 +10,14 @@ import {BrowserDomAdapter} from 'angular2/platform/browser'; @Reflect.metadata('parameters', [[ElementRef], [BrowserDomAdapter]]) export default class StickySidebar { constructor(elementRef, dom) { - this.element = elementRef.nativeElement; + this.$element = elementRef.nativeElement; this.dom = dom; // initial styling - this.dom.setStyle(this.element, 'position', 'absolute'); - this.dom.setStyle(this.element, 'top', '0'); - this.dom.setStyle(this.element, 'bottom', '0'); - this.dom.setStyle(this.element, 'max-height', '100%'); + this.dom.setStyle(this.$element, 'position', 'absolute'); + this.dom.setStyle(this.$element, 'top', '0'); + this.dom.setStyle(this.$element, 'bottom', '0'); + this.dom.setStyle(this.$element, 'max-height', '100%'); } bind() { @@ -30,7 +30,7 @@ export default class StickySidebar { } updatePosition() { - if ( this.scrollY + this.scrollYOffset() >= this.redocEl.offsetTop) { + if ( this.scrollY + this.scrollYOffset() >= this.$redocEl.offsetTop) { this.stick(); } else { this.unstick(); @@ -38,13 +38,13 @@ export default class StickySidebar { } stick() { - this.dom.setStyle(this.element, 'position', 'fixed'); - this.dom.setStyle(this.element, 'top', this.scrollYOffset() + 'px'); + this.dom.setStyle(this.$element, 'position', 'fixed'); + this.dom.setStyle(this.$element, 'top', this.scrollYOffset() + 'px'); } unstick() { - this.dom.setStyle(this.element, 'position', 'absolute'); - this.dom.setStyle(this.element, 'top', 0); + this.dom.setStyle(this.$element, 'position', 'absolute'); + this.dom.setStyle(this.$element, 'top', 0); } get scrollY() { @@ -52,7 +52,8 @@ export default class StickySidebar { } ngOnInit() { - this.redocEl = this.element.offsetParent; + // FIXME use more reliable code + this.$redocEl = this.$element.offsetParent; this.bind(); } diff --git a/lib/components/JsonSchema/json-schema-lazy.js b/lib/components/JsonSchema/json-schema-lazy.js index 83bd4577..a8c7b589 100644 --- a/lib/components/JsonSchema/json-schema-lazy.js +++ b/lib/components/JsonSchema/json-schema-lazy.js @@ -20,21 +20,23 @@ var cache = {}; template: '', directives: [CORE_DIRECTIVES] }) -@Reflect.metadata('parameters', [[ElementRef], [DynamicComponentLoader]]) +@Reflect.metadata('parameters', [[SchemaManager], [ElementRef], [DynamicComponentLoader], [OptionsManager]]) export default class JsonSchemaLazy { - constructor(elementRef, dcl) { + constructor(schemaMgr, elementRef, dcl, optionsMgr) { this.elementRef = elementRef; this.dcl = dcl; + this.optionsMgr = optionsMgr; + this.schemaMgr = schemaMgr; } normalizePointer() { - let schema = SchemaManager.instance().byPointer(this.pointer); + let schema = this.schemaMgr.byPointer(this.pointer); return schema && schema.$ref || this.pointer; } load() { - if (OptionsManager.instance().options.disableLazySchemas) return; + if (this.optionsMgr.options.disableLazySchemas) return; if (this.loaded) return; if (this.pointer) { this.dcl.loadNextToLocation(JsonSchema, this.elementRef).then((compRef) => { @@ -50,17 +52,17 @@ export default class JsonSchemaLazy { if (cache[this.pointer]) { cache[this.pointer].then((compRef) => { setTimeout( ()=> { - let element = compRef.location.nativeElement; + let $element = compRef.location.nativeElement; - // skip caching view with discriminator as it needs attached controller - if (element.querySelector('.discriminator')) { + // skip caching view with tabs inside (discriminator) as it needs attached controller + if ($element.querySelector('tabs')) { this.dcl.loadNextToLocation(JsonSchema, this.elementRef).then((compRef) => { compRef.instance.pointer = this.pointer; compRef.hostView.changeDetectorRef.markForCheck(); }); return; } - insertAfter(element.cloneNode(true), this.elementRef.nativeElement); + insertAfter($element.cloneNode(true), this.elementRef.nativeElement); } ); }); } else { @@ -76,6 +78,11 @@ export default class JsonSchemaLazy { if (!this.auto) return; this.loadCached(); } + + ngOnDestroy() { + // clear cache + cache = {}; + } } function insertAfter(newNode, referenceNode) { diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index 192c64e2..0e8a4009 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -17,7 +17,7 @@ import JsonPointer from '../../utils/JsonPointer'; export default class JsonSchema extends BaseComponent { constructor(schemaMgr, elementRef) { super(schemaMgr); - this.element = elementRef.nativeElement; + this.$element = elementRef.nativeElement; this.final = false; } @@ -86,20 +86,6 @@ export default class JsonSchema extends BaseComponent { this.data.properties = props; } - adjustNameColumnWidth() { - // TODO handle internal schemes differently - let names = [].slice.call(this.element.querySelectorAll('.param-name-content')); - let widths = [144];//names.map(el => el.offsetWidth); - let maxWidth = Math.max(...widths); - if (!maxWidth) return; - names.forEach(el => { - el.parentNode.style.minWidth = maxWidth + 'px'; - }); - - let discrValues = this.element.querySelector('tabs ul'); - if (discrValues) discrValues.style.paddingLeft = maxWidth + 'px'; - } - static injectPropData(propData, propName, propPointer, requiredMap, schema) { let propEnum; @@ -145,12 +131,27 @@ export default class JsonSchema extends BaseComponent { ngAfterViewInit() { // adjust widht only on parent level - let el = this.element.parentElement; - while(el && el.tagName !== 'JSON-SCHEMA' && el.tagName !== 'REDOC') { - el = el.parentElement; + let $el = this.$element.parentElement; + while($el && $el.tagName !== 'JSON-SCHEMA' && $el.tagName !== 'REDOC') { + $el = $el.parentElement; } - if (el && el.tagName === 'REDOC' ) { + if ($el && $el.tagName === 'REDOC' ) { this.adjustNameColumnWidth(); } } + + adjustNameColumnWidth() { + // TODO handle internal schemes differently + + let names = [].slice.call(this.$element.querySelectorAll('.param-name-content')); + let widths = [144];//names.map(el => el.offsetWidth); + let maxWidth = Math.max(...widths); + if (!maxWidth) return; + names.forEach(el => { + el.parentNode.style.minWidth = maxWidth + 'px'; + }); + + let discrValues = this.$element.querySelector('tabs ul'); + if (discrValues) discrValues.style.paddingLeft = maxWidth + 'px'; + } } diff --git a/lib/components/Redoc/redoc-loading-styles.scss b/lib/components/Redoc/redoc-loading-styles.scss new file mode 100644 index 00000000..0e4f4bd9 --- /dev/null +++ b/lib/components/Redoc/redoc-loading-styles.scss @@ -0,0 +1,37 @@ +redoc.loading { + position: relative; + display: block; + min-height:350px; +} + +@keyframes move { + 0% {transform: translateY(10px)} + 25% {transform: translateY(0px)} + 50% {transform: translateY(10px)} + 75% {transform: translateY(20px)} + 100% {transform: translateY(10px)} +} + +redoc.loading:before { + content: "Loading..."; + font-size: 28px; + text-align: center; + padding-top: 40px; + color: #3F5C9C; + font-weight: bold; + display: block; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + background-color: white; + z-index: 9999; + opacity: 1; + transition: all 0.6s ease-out; + animation: 2s move linear infinite; +} + +redoc.loading-remove:before { + opacity: 0; +} diff --git a/lib/components/Redoc/redoc.html b/lib/components/Redoc/redoc.html index c72f5d40..8e166bd8 100644 --- a/lib/components/Redoc/redoc.html +++ b/lib/components/Redoc/redoc.html @@ -1,5 +1,5 @@
- `; builder = builder.overrideView( TestApp, new ViewMetadata({template: scollableDivTmpl, directives: [MethodsList, SideMenu]})); - builder.createAsync(TestApp).then(_fixture => { fixture = _fixture; component = getChildDebugElement(fixture.debugElement, 'side-menu').componentInstance; menuNativeEl = getChildDebugElement(fixture.debugElement, 'side-menu').nativeElement; - component.scrollParent = _fixture.nativeElement.children[0]; + component.options.scrollParent = _fixture.nativeElement.children[0]; + component.$scrollParent = _fixture.nativeElement.children[0]; fixture.detectChanges(); - done(); }, err => { throw err; @@ -137,24 +137,24 @@ describe('Redoc components', () => { it('should scroll to method when location hash is present [jp]', (done) => { let hash = '#tag/pet/paths/~1pet~1findByStatus/get'; - spyOn(component.adapter, 'getLocation').and.returnValue({hash: hash}); + spyOn(component.dom, 'getLocation').and.returnValue({hash: hash}); spyOn(component, 'hashScroll').and.callThrough(); redocEvents.bootstrapped.next(); setTimeout(() => { expect(component.hashScroll).toHaveBeenCalled(); - expect(component.scrollParent.scrollTop).toBeGreaterThan(0); + expect(component.$scrollParent.scrollTop).toBeGreaterThan(0); done(); }); }); it('should scroll to method when location hash is present [operation]', (done) => { let hash = '#operation/getPetById'; - spyOn(component.adapter, 'getLocation').and.returnValue({hash: hash}); + spyOn(component.dom, 'getLocation').and.returnValue({hash: hash}); spyOn(component, 'hashScroll').and.callThrough(); redocEvents.bootstrapped.next(); setTimeout(() => { expect(component.hashScroll).toHaveBeenCalled(); - expect(component.scrollParent.scrollTop).toBeGreaterThan(0); + expect(component.$scrollParent.scrollTop).toBeGreaterThan(0); done(); }); }); @@ -164,14 +164,14 @@ describe('Redoc components', () => { component.activeMethodIdx.should.be.equal(-1); let elTop = component.getCurrentMethodEl().getBoundingClientRect().bottom; - component.scrollParent.scrollTop = elTop + 1; + component.$scrollParent.scrollTop = elTop + 1; //simulate scroll down spyOn(component, 'scrollY').and.returnValue(elTop + 2); component.scrollHandler(); component.activeCatIdx.should.be.equal(1); - component.scrollParent.scrollTop = elTop - 1; + component.$scrollParent.scrollTop = elTop - 1; //simulate scroll up component.scrollY.and.returnValue(elTop - 2); component.scrollHandler(); @@ -187,10 +187,10 @@ describe('Redoc components', () => { }); it('should scroll to appropriate element when click on menu label', () => { - component.scrollParent.scrollTop.should.be.equal(0); + component.$scrollParent.scrollTop.should.be.equal(0); let menuItemEl = menuNativeEl.querySelector('li'); mouseclick(menuItemEl); - component.scrollParent.scrollTop.should.be.above(0); + component.$scrollParent.scrollTop.should.be.above(0); }); }); }); From a7913dec59be216537b9ed917a795e768bbc23b5 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Thu, 11 Feb 2016 13:38:44 +0200 Subject: [PATCH 14/25] Upgrade to Angular 2.0.0-beta.3 + refactoring --- demo/index.html | 2 +- demo/main.js | 2 + karma.conf.js | 4 +- lib/components/ApiInfo/api-info.spec.js | 1 - lib/components/ApiLogo/api-logo.js | 2 +- .../JsonSchema/json-schema-lazy.spec.js | 2 - lib/components/JsonSchema/json-schema.spec.js | 1 - lib/components/Method/method.spec.js | 1 - lib/components/Redoc/redoc.js | 23 +++++--- lib/components/SideMenu/side-menu.js | 6 +- lib/components/SideMenu/side-menu.spec.js | 1 - lib/index.js | 3 - lib/options.js | 16 ++--- lib/utils/pipes.js | 3 +- package.json | 2 +- system.config.js | 58 +++++++++---------- tests/helpers.js | 15 ++--- tests/setup.js | 13 +++++ 18 files changed, 82 insertions(+), 73 deletions(-) create mode 100644 tests/setup.js diff --git a/demo/index.html b/demo/index.html index 1d480d20..c189d992 100644 --- a/demo/index.html +++ b/demo/index.html @@ -17,7 +17,7 @@ - + diff --git a/demo/main.js b/demo/main.js index a7fd542a..836eaa45 100644 --- a/demo/main.js +++ b/demo/main.js @@ -8,4 +8,6 @@ Redoc.init(schemaUrlInput.value); return false; }) + + //window.redocDebugMode = true; })(); diff --git a/karma.conf.js b/karma.conf.js index a913a3fd..9d1d480d 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -49,12 +49,12 @@ module.exports = function (config) { 'node_modules/zone.js/dist/long-stack-trace-zone.js', 'node_modules/zone.js/dist/jasmine-patch.js', 'node_modules/babel-polyfill/dist/polyfill.js', - 'node_modules/reflect-metadata/Reflect.js' + './node_modules/reflect-metadata/Reflect.js' ], jspm: { config: 'system.config.js', - loadFiles: ['tests/unit/*.spec.js', 'tests/helpers.js', 'lib/**/*.js'], + loadFiles: ['tests/setup.js', 'tests/helpers.js', 'tests/unit/*.spec.js', 'lib/**/*.js'], serveFiles: ['tests/schemas/**/*.json','tests/schemas/**/*.yml', 'lib/**/*.html', '.tmp/lib/**/*.css'], nocache: true }, diff --git a/lib/components/ApiInfo/api-info.spec.js b/lib/components/ApiInfo/api-info.spec.js index d9f9e95f..83abf877 100644 --- a/lib/components/ApiInfo/api-info.spec.js +++ b/lib/components/ApiInfo/api-info.spec.js @@ -56,7 +56,6 @@ describe('Redoc components', () => { @Component({selector: 'test-app'}) @View({ directives: [ApiInfo], - providers: [SchemaManager], template: `` }) diff --git a/lib/components/ApiLogo/api-logo.js b/lib/components/ApiLogo/api-logo.js index a4e086bd..46db79dd 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 ApiInfo extends BaseComponent { +export default class ApiLogo extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/JsonSchema/json-schema-lazy.spec.js b/lib/components/JsonSchema/json-schema-lazy.spec.js index 0c0a1205..65535b52 100644 --- a/lib/components/JsonSchema/json-schema-lazy.spec.js +++ b/lib/components/JsonSchema/json-schema-lazy.spec.js @@ -30,7 +30,6 @@ describe('Redoc components', () => { beforeEachProviders(() => [ provide(SchemaManager, {useValue: schemaMgr}), provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}), - provide('OPTION_NAMES', {useValue: []}), provide(OptionsManager, {useClass: OptionsManager}) ]); beforeEach(inject([TestComponentBuilder, DynamicComponentLoader], (tcb, dcl) => { @@ -84,7 +83,6 @@ describe('Redoc components', () => { @Component({selector: 'test-app'}) @View({ directives: [JsonSchemaLazy], - providers: [SchemaManager, DynamicComponentLoader], template: `` }) diff --git a/lib/components/JsonSchema/json-schema.spec.js b/lib/components/JsonSchema/json-schema.spec.js index 8f2794c9..02e54491 100644 --- a/lib/components/JsonSchema/json-schema.spec.js +++ b/lib/components/JsonSchema/json-schema.spec.js @@ -23,7 +23,6 @@ describe('Redoc components', () => { let fixture; beforeEachProviders(() => [ provide(SchemaManager, {useValue: schemaMgr}), - provide('OPTION_NAMES', {useValue: []}), provide(OptionsManager, {useClass: OptionsManager}) ]); beforeEach(inject([TestComponentBuilder], (tcb) => { diff --git a/lib/components/Method/method.spec.js b/lib/components/Method/method.spec.js index 3e97e356..9e5aee33 100644 --- a/lib/components/Method/method.spec.js +++ b/lib/components/Method/method.spec.js @@ -23,7 +23,6 @@ describe('Redoc components', () => { beforeEachProviders(() => [ provide(SchemaManager, {useValue: new SchemaManager()}), provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}), - provide('OPTION_NAMES', {useValue: []}), provide(OptionsManager, {useClass: OptionsManager}) ]); beforeEach(injectAsync([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => { diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index 9a298d59..4faa1353 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -1,10 +1,9 @@ 'use strict'; -import {ChangeDetectionStrategy, provide} from 'angular2/core'; +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 SchemaManager from '../../utils/SchemaManager'; @@ -18,15 +17,14 @@ import {redocEvents} from '../../events'; import './redoc-loading-styles.css!css'; -let dom = new BrowserDomAdapter(); +var dom = new BrowserDomAdapter(); +var _modeLocked = false; @RedocComponent({ selector: 'redoc', providers: [ SchemaManager, - BrowserDomAdapter, - provide('OPTION_NAMES', {useValue: new Set(['scrollYOffset', 'disableLazySchemas'])}), - provide(OptionsManager, {useClass: OptionsManager}) + BrowserDomAdapter ], templateUrl: './lib/components/Redoc/redoc.html', styleUrls: ['./lib/components/Redoc/redoc.css'], @@ -60,14 +58,23 @@ export default class Redoc extends BaseComponent { } static init(schemaUrl, options) { + var optionsMgr = new OptionsManager(); + optionsMgr.options = options; + var providers = [ + provide(OptionsManager, {useValue: optionsMgr}) + ]; + if (Redoc.appRef) { Redoc.dispose(); } Redoc.showLoadingAnimation(); return SchemaManager.instance().load(schemaUrl) .then(() => { - (new OptionsManager()).options = options; - return bootstrap(Redoc); + if (!_modeLocked && !optionsMgr.options.debugMode) { + enableProdMode(); + _modeLocked = true; + } + return bootstrap(Redoc, providers); }) .then( (appRef) => { diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.js index 00e42ba9..a3791bee 100644 --- a/lib/components/SideMenu/side-menu.js +++ b/lib/components/SideMenu/side-menu.js @@ -32,12 +32,10 @@ const INVIEW_POSITION = { export default class SideMenu extends BaseComponent { constructor(schemaMgr, elementRef, dom, zone, optionsMgr) { super(schemaMgr); + this.$element = elementRef.nativeElement; this.dom = dom; this.options = optionsMgr.options; this.$scrollParent = this.options.$scrollParent; - this.$mobileNav = dom.querySelector(elementRef.nativeElement, '.mobile-nav'); - this.$resourcesNav = dom.querySelector(elementRef.nativeElement, '#resources-nav'); - // for some reason constructor is not run inside zone // as workaround running it manually zone.run(() => { @@ -251,6 +249,8 @@ export default class SideMenu extends BaseComponent { } init() { + this.$mobileNav = this.dom.querySelector(this.$element, '.mobile-nav'); + this.$resourcesNav = this.dom.querySelector(this.$element, '#resources-nav'); this.changeActive(CHANGE.INITIAL); } } diff --git a/lib/components/SideMenu/side-menu.spec.js b/lib/components/SideMenu/side-menu.spec.js index 5785c751..0e5ce1ad 100644 --- a/lib/components/SideMenu/side-menu.spec.js +++ b/lib/components/SideMenu/side-menu.spec.js @@ -32,7 +32,6 @@ describe('Redoc components', () => { beforeEachProviders(() => [ provide(SchemaManager, {useValue: new SchemaManager()}), provide(BrowserDomAdapter, {useValue: new BrowserDomAdapter()}), - provide('OPTION_NAMES', {useValue: []}), provide(OptionsManager, {useValue: testOptions}) ]); beforeEach(injectAsync([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => { diff --git a/lib/index.js b/lib/index.js index 70104b76..1a0b8775 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,10 +1,7 @@ 'use strict'; import {Redoc} from './components/index'; -import {enableProdMode} from 'angular2/core'; - export var init = Redoc.init; window.Redoc = Redoc; -enableProdMode(); Redoc.autoInit(); diff --git a/lib/options.js b/lib/options.js index 831f7362..689310a5 100644 --- a/lib/options.js +++ b/lib/options.js @@ -1,20 +1,22 @@ 'use strict'; -import {Inject} from 'angular2/core'; import {isFunction, isString} from 'angular2/src/facade/lang'; import {BrowserDomAdapter} from 'angular2/platform/browser'; +import {global} from 'angular2/src/facade/lang'; var defaults = { scrollYOffset: 0, - disableLazySchemas: false + disableLazySchemas: false, + debugMode: global.redocDebugMode }; -@Reflect.metadata('parameters', [[new Inject('OPTION_NAMES')], [BrowserDomAdapter]]) +var OPTION_NAMES = new Set(['scrollYOffset', 'disableLazySchemas']); + +@Reflect.metadata('parameters', [[BrowserDomAdapter]]) export default class OptionsManager { - constructor(optionNames, dom) { + constructor() { this._options = defaults; - this.optionNames = optionNames; - this.dom = dom; + this.dom = new BrowserDomAdapter(); } get options() { @@ -36,7 +38,7 @@ export default class OptionsManager { name: k.replace(/-(.)/g, (m, $1) => $1.toUpperCase()) }) ) - .filter(option => this.optionNames.has(option.name)) + .filter(option => OPTION_NAMES.has(option.name)) .forEach(option => { parsedOpts[option.name] = attributesMap.get(option.attrName); }); diff --git a/lib/utils/pipes.js b/lib/utils/pipes.js index 32c23fbc..45f5af15 100644 --- a/lib/utils/pipes.js +++ b/lib/utils/pipes.js @@ -4,7 +4,6 @@ import {Pipe} from 'angular2/core'; import {isString, stringify, isBlank} from 'angular2/src/facade/lang'; import {BaseException} from 'angular2/src/facade/exceptions'; import {JsonPointer} from './JsonPointer'; -import marked from 'marked'; import Prism from 'prismjs'; import 'prismjs/components/prism-actionscript.js'; @@ -30,6 +29,8 @@ import 'prismjs/components/prism-vim.js'; import 'prismjs/themes/prism-dark.css!css'; +import marked from 'marked'; + marked.setOptions({ renderer: new marked.Renderer(), gfm: true, diff --git a/package.json b/package.json index 02d313da..55d5e1aa 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "jspm": { "configFile": "system.config.js", "dependencies": { - "angular2": "npm:angular2@^2.0.0-beta.0", + "angular2": "npm:angular2@2.0.0-beta.3", "es6-shim": "github:es-shims/es6-shim@^0.33.6", "json-formatter-js": "npm:json-formatter-js@^0.2.0", "json-pointer": "npm:json-pointer@^0.3.0", diff --git a/system.config.js b/system.config.js index 59157f88..92b58f7f 100644 --- a/system.config.js +++ b/system.config.js @@ -37,7 +37,7 @@ System.config({ }, map: { - "angular2": "npm:angular2@2.0.0-beta.0", + "angular2": "npm:angular2@2.0.0-beta.3", "babel": "npm:babel-core@5.8.34", "babel-runtime": "npm:babel-runtime@5.8.34", "clean-css": "npm:clean-css@3.4.6", @@ -135,14 +135,14 @@ System.config({ "path": "github:jspm/nodelibs-path@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2" }, - "npm:angular2@2.0.0-beta.0": { + "npm:angular2@2.0.0-beta.3": { "crypto": "github:jspm/nodelibs-crypto@0.1.0", "es6-promise": "npm:es6-promise@3.0.2", "es6-shim": "npm:es6-shim@0.33.13", "process": "github:jspm/nodelibs-process@0.1.2", "reflect-metadata": "npm:reflect-metadata@0.1.2", "rxjs": "npm:rxjs@5.0.0-beta.0", - "zone.js": "npm:zone.js@0.5.10" + "zone.js": "npm:zone.js@0.5.11" }, "npm:argparse@1.0.3": { "assert": "github:jspm/nodelibs-assert@0.1.0", @@ -153,9 +153,9 @@ System.config({ "sprintf-js": "npm:sprintf-js@1.0.3", "util": "github:jspm/nodelibs-util@0.1.0" }, - "npm:asn1.js@4.3.0": { + "npm:asn1.js@4.4.0": { "assert": "github:jspm/nodelibs-assert@0.1.0", - "bn.js": "npm:bn.js@4.6.4", + "bn.js": "npm:bn.js@4.10.3", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "inherits": "npm:inherits@2.0.1", "minimalistic-assert": "npm:minimalistic-assert@1.0.0", @@ -199,11 +199,14 @@ System.config({ "readable-stream": "npm:readable-stream@2.0.5", "util": "github:jspm/nodelibs-util@0.1.0" }, + "npm:bn.js@4.10.3": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0" + }, "npm:boom@2.10.1": { "hoek": "npm:hoek@2.16.3", "http": "github:jspm/nodelibs-http@1.7.1" }, - "npm:browserify-aes@1.0.5": { + "npm:browserify-aes@1.0.6": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "buffer-xor": "npm:buffer-xor@1.0.3", "cipher-base": "npm:cipher-base@1.0.2", @@ -215,7 +218,7 @@ System.config({ "systemjs-json": "github:systemjs/plugin-json@0.1.0" }, "npm:browserify-cipher@1.0.0": { - "browserify-aes": "npm:browserify-aes@1.0.5", + "browserify-aes": "npm:browserify-aes@1.0.6", "browserify-des": "npm:browserify-des@1.0.0", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "crypto": "github:jspm/nodelibs-crypto@0.1.0", @@ -229,20 +232,20 @@ System.config({ "inherits": "npm:inherits@2.0.1" }, "npm:browserify-rsa@4.0.0": { - "bn.js": "npm:bn.js@4.6.4", + "bn.js": "npm:bn.js@4.10.3", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "constants": "github:jspm/nodelibs-constants@0.1.0", "crypto": "github:jspm/nodelibs-crypto@0.1.0", "randombytes": "npm:randombytes@2.0.2" }, "npm:browserify-sign@4.0.0": { - "bn.js": "npm:bn.js@4.6.4", + "bn.js": "npm:bn.js@4.10.3", "browserify-rsa": "npm:browserify-rsa@4.0.0", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "create-hash": "npm:create-hash@1.1.2", "create-hmac": "npm:create-hmac@1.1.4", "crypto": "github:jspm/nodelibs-crypto@0.1.0", - "elliptic": "npm:elliptic@6.0.2", + "elliptic": "npm:elliptic@6.2.3", "inherits": "npm:inherits@2.0.1", "parse-asn1": "npm:parse-asn1@5.0.0", "stream": "github:jspm/nodelibs-stream@0.1.0" @@ -332,10 +335,10 @@ System.config({ "buffer": "github:jspm/nodelibs-buffer@0.1.0" }, "npm:create-ecdh@4.0.0": { - "bn.js": "npm:bn.js@4.6.4", + "bn.js": "npm:bn.js@4.10.3", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "crypto": "github:jspm/nodelibs-crypto@0.1.0", - "elliptic": "npm:elliptic@6.0.2" + "elliptic": "npm:elliptic@6.2.3" }, "npm:create-hash@1.1.2": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", @@ -363,14 +366,14 @@ System.config({ "create-ecdh": "npm:create-ecdh@4.0.0", "create-hash": "npm:create-hash@1.1.2", "create-hmac": "npm:create-hmac@1.1.4", - "diffie-hellman": "npm:diffie-hellman@5.0.1", + "diffie-hellman": "npm:diffie-hellman@5.0.2", "inherits": "npm:inherits@2.0.1", "pbkdf2": "npm:pbkdf2@3.0.4", "public-encrypt": "npm:public-encrypt@4.0.0", "randombytes": "npm:randombytes@2.0.2" }, - "npm:dashdash@1.12.1": { - "assert-plus": "npm:assert-plus@0.1.5", + "npm:dashdash@1.12.2": { + "assert-plus": "npm:assert-plus@0.2.0", "fs": "github:jspm/nodelibs-fs@0.1.2", "path": "github:jspm/nodelibs-path@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2", @@ -393,8 +396,8 @@ System.config({ "inherits": "npm:inherits@2.0.1", "minimalistic-assert": "npm:minimalistic-assert@1.0.0" }, - "npm:diffie-hellman@5.0.1": { - "bn.js": "npm:bn.js@4.6.4", + "npm:diffie-hellman@5.0.2": { + "bn.js": "npm:bn.js@4.10.3", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "crypto": "github:jspm/nodelibs-crypto@0.1.0", "miller-rabin": "npm:miller-rabin@4.0.0", @@ -406,8 +409,8 @@ System.config({ "crypto": "github:jspm/nodelibs-crypto@0.1.0", "jsbn": "npm:jsbn@0.1.0" }, - "npm:elliptic@6.0.2": { - "bn.js": "npm:bn.js@4.6.4", + "npm:elliptic@6.2.3": { + "bn.js": "npm:bn.js@4.10.3", "brorand": "npm:brorand@1.0.5", "hash.js": "npm:hash.js@1.0.3", "inherits": "npm:inherits@2.0.1", @@ -584,7 +587,7 @@ System.config({ "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:miller-rabin@4.0.0": { - "bn.js": "npm:bn.js@4.6.4", + "bn.js": "npm:bn.js@4.10.3", "brorand": "npm:brorand@1.0.5" }, "npm:mime-db@1.21.0": { @@ -616,8 +619,8 @@ System.config({ "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:parse-asn1@5.0.0": { - "asn1.js": "npm:asn1.js@4.3.0", - "browserify-aes": "npm:browserify-aes@1.0.5", + "asn1.js": "npm:asn1.js@4.4.0", + "browserify-aes": "npm:browserify-aes@1.0.6", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "create-hash": "npm:create-hash@1.1.2", "evp_bytestokey": "npm:evp_bytestokey@1.0.0", @@ -637,10 +640,7 @@ System.config({ "systemjs-json": "github:systemjs/plugin-json@0.1.0" }, "npm:pinkie-promise@2.0.0": { - "pinkie": "npm:pinkie@2.0.1" - }, - "npm:pinkie@2.0.1": { - "process": "github:jspm/nodelibs-process@0.1.2" + "pinkie": "npm:pinkie@2.0.4" }, "npm:prismjs@1.3.0": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", @@ -654,7 +654,7 @@ System.config({ "assert": "github:jspm/nodelibs-assert@0.1.0" }, "npm:public-encrypt@4.0.0": { - "bn.js": "npm:bn.js@4.6.4", + "bn.js": "npm:bn.js@4.10.3", "browserify-rsa": "npm:browserify-rsa@4.0.0", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "create-hash": "npm:create-hash@1.1.2", @@ -758,7 +758,7 @@ System.config({ "assert-plus": "npm:assert-plus@0.2.0", "buffer": "github:jspm/nodelibs-buffer@0.1.0", "crypto": "github:jspm/nodelibs-crypto@0.1.0", - "dashdash": "npm:dashdash@1.12.1", + "dashdash": "npm:dashdash@1.12.2", "ecc-jsbn": "npm:ecc-jsbn@0.1.1", "jodid25519": "npm:jodid25519@1.0.2", "jsbn": "npm:jsbn@0.1.0", @@ -866,7 +866,7 @@ System.config({ "systemjs-json": "github:systemjs/plugin-json@0.1.0", "validator": "npm:validator@4.5.0" }, - "npm:zone.js@0.5.10": { + "npm:zone.js@0.5.11": { "es6-promise": "npm:es6-promise@3.0.2", "process": "github:jspm/nodelibs-process@0.1.2" } diff --git a/tests/helpers.js b/tests/helpers.js index 3ce7c4ca..90f2bc14 100644 --- a/tests/helpers.js +++ b/tests/helpers.js @@ -1,27 +1,20 @@ 'use strict'; -import {BrowserDomAdapter} from 'angular2/platform/browser'; -BrowserDomAdapter.makeCurrent(); +import {By} from 'angular2/platform/browser'; /** Gets a child DebugElement by tag name. */ export function getChildDebugElement(parent, tagName) { - return parent.query(debugEl => { - return debugEl.nativeElement.tagName && debugEl.nativeElement.tagName.toLowerCase() === tagName; - }); + return parent.query(By.css(tagName)); } /** Gets a child DebugElement by Component Type. */ export function getChildDebugElementByType(parent, type) { - return parent.query(debugEl => { - return debugEl.componentInstance instanceof type; - }); + return parent.query(By.directive(type)); } /** Gets a child DebugElements by tag name. */ export function getChildDebugElementAll(parent, tagName) { - return parent.queryAll(debugEl => { - return debugEl.nativeElement.tagName && debugEl.nativeElement.tagName.toLowerCase() === tagName; - }); + return parent.queryAll(By.css(tagName)); } export function mouseclick( element ) { diff --git a/tests/setup.js b/tests/setup.js new file mode 100644 index 00000000..d008172c --- /dev/null +++ b/tests/setup.js @@ -0,0 +1,13 @@ +'use strict'; + +import {setBaseTestProviders} from 'angular2/testing'; + +import { + TEST_BROWSER_PLATFORM_PROVIDERS, + TEST_BROWSER_APPLICATION_PROVIDERS +} from 'angular2/platform/testing/browser'; +import { + + ELEMENT_PROBE_PROVIDERS_PROD_MODE +} from 'angular2/platform/browser'; +setBaseTestProviders(TEST_BROWSER_PLATFORM_PROVIDERS, [TEST_BROWSER_APPLICATION_PROVIDERS, ELEMENT_PROBE_PROVIDERS_PROD_MODE]); From 791f6e1b64edcaab9ab0174c86d2e9ab8dd5b0f3 Mon Sep 17 00:00:00 2001 From: Making GitHub Delicious Date: Sat, 13 Feb 2016 09:08:51 -0700 Subject: [PATCH 15/25] add waffle.io badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index a460b5e1..3e70eb78 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +[![Stories in Ready](https://badge.waffle.io/Rebilly/ReDoc.png?label=ready&title=Ready)](https://waffle.io/Rebilly/ReDoc) # 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) [![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) From 503cbab2f02afd63a6d1ad71aa9bf92ef89c36e4 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Tue, 16 Feb 2016 15:31:12 +0200 Subject: [PATCH 16/25] Updated angular to beta.6 + fix test --- lib/components/MethodsList/methods-list.spec.js | 10 +++++++--- lib/components/ResponsesList/responses-list.html | 2 +- lib/components/ResponsesList/responses-list.js | 7 +++++-- package.json | 3 ++- system.config.js | 8 ++++---- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/components/MethodsList/methods-list.spec.js b/lib/components/MethodsList/methods-list.spec.js index ea1d86c5..50f62689 100644 --- a/lib/components/MethodsList/methods-list.spec.js +++ b/lib/components/MethodsList/methods-list.spec.js @@ -2,6 +2,8 @@ import { getChildDebugElement } from 'tests/helpers'; import {Component, View, provide} from 'angular2/core'; +import OptionsManager from 'lib/options'; +import {BrowserDomAdapter} from 'angular2/platform/browser'; import { TestComponentBuilder, @@ -15,12 +17,14 @@ import MethodsList from 'lib/components/MethodsList/methods-list'; import SchemaManager from 'lib/utils/SchemaManager'; describe('Redoc components', () => { - describe('ApiInfo Component', () => { + describe('MethodsList Component', () => { let builder; let component; let fixture; beforeEachProviders(() => [ - provide(SchemaManager, {useValue: new SchemaManager()}) + provide(SchemaManager, {useValue: new SchemaManager()}), + provide(OptionsManager, {useClass: OptionsManager}), + provide(BrowserDomAdapter, {useClass: BrowserDomAdapter}) ]); beforeEach(injectAsync([TestComponentBuilder, SchemaManager], (tcb, schemaMgr) => { builder = tcb; @@ -32,7 +36,7 @@ describe('Redoc components', () => { component = getChildDebugElement(fixture.debugElement, 'methods-list').componentInstance; fixture.detectChanges(); done(); - }, err => { throw err; }); + }, err => done.fail(err) ); }); diff --git a/lib/components/ResponsesList/responses-list.html b/lib/components/ResponsesList/responses-list.html index 569a12d4..a002e919 100644 --- a/lib/components/ResponsesList/responses-list.html +++ b/lib/components/ResponsesList/responses-list.html @@ -14,7 +14,7 @@
Response schema
- + diff --git a/lib/components/ResponsesList/responses-list.js b/lib/components/ResponsesList/responses-list.js index d8ed65e4..6c85d901 100644 --- a/lib/components/ResponsesList/responses-list.js +++ b/lib/components/ResponsesList/responses-list.js @@ -1,11 +1,12 @@ 'use strict'; -import {RedocComponent, BaseComponent} from '../base'; +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'; function isNumeric(n) { return (!isNaN(parseFloat(n)) && isFinite(n)); @@ -17,9 +18,11 @@ 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 { - constructor(schemaMgr) { + constructor(schemaMgr, optionsMgr) { super(schemaMgr); + this.options = optionsMgr.options; } prepareModel() { diff --git a/package.json b/package.json index 55d5e1aa..d6b7a7f4 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,9 @@ "jspm": { "configFile": "system.config.js", "dependencies": { - "angular2": "npm:angular2@2.0.0-beta.3", + "angular2": "npm:angular2@2.0.0-beta.6", "es6-shim": "github:es-shims/es6-shim@^0.33.6", + "json": "github:systemjs/plugin-json@^0.1.0", "json-formatter-js": "npm:json-formatter-js@^0.2.0", "json-pointer": "npm:json-pointer@^0.3.0", "json-schema-instantiator": "npm:json-schema-instantiator@^0.3.0", diff --git a/system.config.js b/system.config.js index 92b58f7f..960c2bfa 100644 --- a/system.config.js +++ b/system.config.js @@ -37,7 +37,7 @@ System.config({ }, map: { - "angular2": "npm:angular2@2.0.0-beta.3", + "angular2": "npm:angular2@2.0.0-beta.6", "babel": "npm:babel-core@5.8.34", "babel-runtime": "npm:babel-runtime@5.8.34", "clean-css": "npm:clean-css@3.4.6", @@ -135,14 +135,14 @@ System.config({ "path": "github:jspm/nodelibs-path@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2" }, - "npm:angular2@2.0.0-beta.3": { + "npm:angular2@2.0.0-beta.6": { "crypto": "github:jspm/nodelibs-crypto@0.1.0", "es6-promise": "npm:es6-promise@3.0.2", "es6-shim": "npm:es6-shim@0.33.13", "process": "github:jspm/nodelibs-process@0.1.2", "reflect-metadata": "npm:reflect-metadata@0.1.2", "rxjs": "npm:rxjs@5.0.0-beta.0", - "zone.js": "npm:zone.js@0.5.11" + "zone.js": "npm:zone.js@0.5.14" }, "npm:argparse@1.0.3": { "assert": "github:jspm/nodelibs-assert@0.1.0", @@ -866,7 +866,7 @@ System.config({ "systemjs-json": "github:systemjs/plugin-json@0.1.0", "validator": "npm:validator@4.5.0" }, - "npm:zone.js@0.5.11": { + "npm:zone.js@0.5.14": { "es6-promise": "npm:es6-promise@3.0.2", "process": "github:jspm/nodelibs-process@0.1.2" } From 659566234ef0831278207db0552a85d07566defe Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Tue, 16 Feb 2016 20:20:11 +0200 Subject: [PATCH 17/25] reinstall angular beta.6 due to failing build on travis --- system.config.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/system.config.js b/system.config.js index 960c2bfa..c5896f10 100644 --- a/system.config.js +++ b/system.config.js @@ -137,7 +137,7 @@ System.config({ }, "npm:angular2@2.0.0-beta.6": { "crypto": "github:jspm/nodelibs-crypto@0.1.0", - "es6-promise": "npm:es6-promise@3.0.2", + "es6-promise": "npm:es6-promise@3.1.2", "es6-shim": "npm:es6-shim@0.33.13", "process": "github:jspm/nodelibs-process@0.1.2", "reflect-metadata": "npm:reflect-metadata@0.1.2", @@ -416,7 +416,7 @@ System.config({ "inherits": "npm:inherits@2.0.1", "systemjs-json": "github:systemjs/plugin-json@0.1.0" }, - "npm:es6-promise@3.0.2": { + "npm:es6-promise@3.1.2": { "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:es6-shim@0.33.13": { @@ -546,7 +546,7 @@ System.config({ "buffer": "github:jspm/nodelibs-buffer@0.1.0", "call-me-maybe": "npm:call-me-maybe@1.0.1", "debug": "npm:debug@2.2.0", - "es6-promise": "npm:es6-promise@3.0.2", + "es6-promise": "npm:es6-promise@3.1.2", "events": "github:jspm/nodelibs-events@0.1.1", "fs": "github:jspm/nodelibs-fs@0.1.2", "http": "github:jspm/nodelibs-http@1.7.1", @@ -793,7 +793,7 @@ System.config({ "buffer": "github:jspm/nodelibs-buffer@0.1.0", "call-me-maybe": "npm:call-me-maybe@1.0.1", "debug": "npm:debug@2.2.0", - "es6-promise": "npm:es6-promise@3.0.2", + "es6-promise": "npm:es6-promise@3.1.2", "events": "github:jspm/nodelibs-events@0.1.1", "fs": "github:jspm/nodelibs-fs@0.1.2", "http": "github:jspm/nodelibs-http@1.7.1", @@ -867,7 +867,7 @@ System.config({ "validator": "npm:validator@4.5.0" }, "npm:zone.js@0.5.14": { - "es6-promise": "npm:es6-promise@3.0.2", + "es6-promise": "npm:es6-promise@3.1.2", "process": "github:jspm/nodelibs-process@0.1.2" } } From 328a3323e0c406b52481f9d861a45af2b7e40368 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Tue, 16 Feb 2016 22:08:30 +0200 Subject: [PATCH 18/25] fix npm prepublish issue --- .travis.yml | 12 ++++++------ package.json | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0252e24c..72496275 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,12 +38,6 @@ deploy: on: branch: master condition: $JOB != e2e - - skip_cleanup: true - provider: script - script: npm run branch-release - on: - branch: master - condition: $JOB != e2e - provider: npm skip_cleanup: true email: gotsijroman@gmail.com @@ -51,3 +45,9 @@ deploy: secure: PuhWLERrCEFmXmdFpw2OVFlqpOIVDmgwk5JUJOYaFdVCh/smp0+jZCQ4vrdFpuG96rnDVirD+A8xvW6NgsNNaRthLgOB/LRdFN69rU6Gvn3At6wlnC55t5dlhxPvCfnzJcHVBLXX4EmMkjnZqDg2uczXTzPodr3FnQJNuXmP8B33fzDVLyHccvXZ90abwXWVrgRIXPU28niqCR8DOC2OTzs7wqz+BLNkYDRRbyYXsg62HWuD33x5iof5IqBmhzBt3usCGmF3QGcgHrXHdZw3sZnit8+Bua++3KrXR0x6HGXXN1AoXVmCAkCa5OTQ5R3tCRxiJN3P2KLnvWeZR74sTFkovJB/6pGCvbJ/c7Wnuw6sD7SgOUBD359ULB6lAf5OnxBLoNebX4JxxVXF+zA4E3Bl44VxkzDpPWc15xqBPMB5vBREzMVmJ5mExn2s5cmLQjADbl9h0y6gZnhnNJ+iTmqtrVyM0ZkF2rPrzrTdGD+ULmRIlTMkdD1bh+/TJ3RdXT3P4/zNUJmiNnvgnnJVYYvsGaXWF+7uCVHT/8k2RsoSHqgkqh0gkDqGSwVix55y5mC7T2Vk9lMBhm6MvFJXaonOX0kxJS4EDQ3plPd6/ybG+TLhwggYnQ8o9msU5Nt6FpUShKiezjKurIhbQZdwlVivX3tahjW2QjNDO58xGgY= on: tags: true + - skip_cleanup: true + provider: script + script: npm run branch-release + on: + branch: master + condition: $JOB != e2e diff --git a/package.json b/package.json index d6b7a7f4..6bda3350 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,6 @@ "main": "dist/redoc.min.js", "scripts": { "test": "gulp lint && ./build/run_tests.sh", - "prepublish": "gulp build", "jspm-install": "jspm install", "start": "gulp serve", "build-dist": "gulp build", From d03fdd43d914e6e5892ad59519a8ba2f48d7171f Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Tue, 16 Feb 2016 22:22:37 +0200 Subject: [PATCH 19/25] Add before_script to .travis.yml --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 72496275..13ded6a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,8 @@ cache: before_install: - travis_retry npm install jspm - jspm config registries.github.auth $JSPM_GITHUB_AUTH_TOKEN +before_script: +- npm run jspm-install before_deploy: - npm run build-dist deploy: From 5697564032b45a2ef0d9c04ba2e412e848366ff5 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 17 Feb 2016 11:22:38 +0200 Subject: [PATCH 20/25] Disable mangle (due to ng2 minification issue) --- build/tasks/build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/tasks/build.js b/build/tasks/build.js index 2f14a46f..5baa2801 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -91,7 +91,7 @@ function bundle(outputFile, minify, cb) { builder .buildStatic(path.join(paths.tmp, paths.sourceEntryPoint), outputFile, - { format:'umd', sourceMaps: true, lowResSourceMaps: true, minify: minify } + { format:'umd', sourceMaps: true, mangle: false, lowResSourceMaps: true, minify: minify } ) .then(function() { cb(); From b7d68b7a9e445ab032b40db6824a00e988698d99 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 17 Feb 2016 11:44:30 +0200 Subject: [PATCH 21/25] updated waffle badge position --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 3e70eb78..c39f95b2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ -[![Stories in Ready](https://badge.waffle.io/Rebilly/ReDoc.png?label=ready&title=Ready)](https://waffle.io/Rebilly/ReDoc) # 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) [![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) +[![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) [![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) [![npm](http://img.shields.io/npm/v/redoc.svg)](https://www.npmjs.com/package/swagger-parser) [![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) From ce5306f1debb9e6044ca277dca5e91200068f781 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 17 Feb 2016 23:45:27 +0200 Subject: [PATCH 22/25] Add unsupported browser bar (fixes #17) --- build/tasks/build.js | 2 ++ lib/utils/browser-update.js | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 lib/utils/browser-update.js diff --git a/build/tasks/build.js b/build/tasks/build.js index 5baa2801..408cea9c 100644 --- a/build/tasks/build.js +++ b/build/tasks/build.js @@ -42,12 +42,14 @@ gulp.task('inlineTemplates', ['sass'], function() { }); var JS_DEV_DEPS = [ + 'lib/utils/browser-update.js', 'node_modules/zone.js/dist/zone-microtask.js', 'node_modules/reflect-metadata/Reflect.js', 'node_modules/babel-polyfill/dist/polyfill.js' ]; var JS_DEV_DEPS_MIN = [ + 'lib/utils/browser-update.js', 'node_modules/zone.js/dist/zone-microtask.min.js', 'node_modules/reflect-metadata/Reflect.js', 'node_modules/babel-polyfill/dist/polyfill.min.js' diff --git a/lib/utils/browser-update.js b/lib/utils/browser-update.js new file mode 100644 index 00000000..73648633 --- /dev/null +++ b/lib/utils/browser-update.js @@ -0,0 +1,10 @@ +/*eslint no-unused-vars: 0*/ +'use strict'; +var $buoop = { vs: {i:9, f:25, o:12.1, s:7}, c:2, test: true }; +function $buo_f(){ + var e = document.createElement('script'); + e.src = '//browser-update.org/update.min.js'; + document.body.appendChild(e); +} +try {document.addEventListener('DOMContentLoaded', $buo_f, false);} +catch(e){window.attachEvent('onload', $buo_f);} From 518321bfd46e50111dcb7f72254e3b914f005442 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Thu, 18 Feb 2016 15:05:45 +0200 Subject: [PATCH 23/25] Remove test flag from browser-update script --- lib/utils/browser-update.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/browser-update.js b/lib/utils/browser-update.js index 73648633..b4b34d0b 100644 --- a/lib/utils/browser-update.js +++ b/lib/utils/browser-update.js @@ -1,6 +1,6 @@ /*eslint no-unused-vars: 0*/ 'use strict'; -var $buoop = { vs: {i:9, f:25, o:12.1, s:7}, c:2, test: true }; +var $buoop = { vs: {i:9, f:25, o:12.1, s:7}, c:2 }; function $buo_f(){ var e = document.createElement('script'); e.src = '//browser-update.org/update.min.js'; From b87883607eb7483bebca6bdf38f100e67d9df212 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Fri, 19 Feb 2016 17:10:11 +0200 Subject: [PATCH 24/25] Remove extra use-strict from browser-update --- lib/utils/browser-update.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils/browser-update.js b/lib/utils/browser-update.js index b4b34d0b..7e08bc7c 100644 --- a/lib/utils/browser-update.js +++ b/lib/utils/browser-update.js @@ -1,5 +1,5 @@ /*eslint no-unused-vars: 0*/ -'use strict'; +/*eslint strict: 0*/ var $buoop = { vs: {i:9, f:25, o:12.1, s:7}, c:2 }; function $buo_f(){ var e = document.createElement('script'); From 267b0a03388d7bd2168ec09fb9c96773867c2220 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 22 Feb 2016 15:25:31 +0200 Subject: [PATCH 25/25] v0.6.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6bda3350..47ac0303 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "redoc", "description": "Swagger-generated API Reference Documentation", - "version": "0.5.2", + "version": "0.6.0", "repository": { "type": "git", "url": "git://github.com/Rebilly/ReDoc"