From f8590bb4dd5a3fd9a98b4837f0baa65bde9aa6e2 Mon Sep 17 00:00:00 2001 From: Roman Gotsiy Date: Tue, 27 Oct 2015 19:44:08 +0200 Subject: [PATCH] default es6 export + REDOC_COMPONENTS --- lib/components/ApiInfo/api-info.js | 2 +- .../JsonSchemaView/json-schema-view.js | 2 +- lib/components/Method/method.js | 10 ++--- lib/components/MethodsList/methods-list.js | 4 +- lib/components/ParamsList/params-list.js | 4 +- lib/components/Redoc/redoc.js | 8 ++-- .../ResponsesList/responses-list.js | 6 +-- .../ResponsesSamples/responses-samples.js | 6 +-- lib/components/SchemaSample/schema-sample.js | 2 +- lib/components/SideMenu/side-menu.js | 10 ++--- lib/components/SideMenuCat/side-menu-cat.js | 2 +- lib/components/base.js | 7 ++- lib/components/index.js | 43 +++++++++++++++++-- lib/index.js | 6 +-- lib/utils/SchemaManager.js | 2 +- 15 files changed, 75 insertions(+), 39 deletions(-) diff --git a/lib/components/ApiInfo/api-info.js b/lib/components/ApiInfo/api-info.js index e1cf1cc1..d179dae9 100644 --- a/lib/components/ApiInfo/api-info.js +++ b/lib/components/ApiInfo/api-info.js @@ -7,7 +7,7 @@ import {RedocComponent, BaseComponent} from '../base'; styleUrls: ['./lib/components/ApiInfo/api-info.css'], templateUrl: './lib/components/ApiInfo/api-info.html' }) -export class ApiInfo extends BaseComponent { +export default class ApiInfo extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/JsonSchemaView/json-schema-view.js b/lib/components/JsonSchemaView/json-schema-view.js index 0c2063a4..3341c8cb 100644 --- a/lib/components/JsonSchemaView/json-schema-view.js +++ b/lib/components/JsonSchemaView/json-schema-view.js @@ -14,7 +14,7 @@ import {ElementRef} from 'angular2/angular2'; selector: 'schema', template: '' }) -export class JsonSchemaView extends BaseComponent { +export default class JsonSchemaView extends BaseComponent { constructor(schemaMgr, elementRef) { super(schemaMgr); this.element = elementRef.nativeElement; diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js index 111fdc9e..2f660359 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.js @@ -2,10 +2,10 @@ import {JsonPointer} from '../../utils/JsonPointer'; import {RedocComponent, BaseComponent} from '../base'; -import {ParamsList} from '../ParamsList/params-list'; -import {ResponsesList} from '../ResponsesList/responses-list'; -import {ResponsesSamples} from '../ResponsesSamples/responses-samples'; -import {SchemaSample} from '../SchemaSample/schema-sample'; +import ParamsList from '../ParamsList/params-list'; +import ResponsesList from '../ResponsesList/responses-list'; +import ResponsesSamples from '../ResponsesSamples/responses-samples'; +import SchemaSample from '../SchemaSample/schema-sample'; @RedocComponent({ selector: 'method', @@ -13,7 +13,7 @@ import {SchemaSample} from '../SchemaSample/schema-sample'; styleUrls: ['./lib/components/Method/method.css'], directives: [ParamsList, ResponsesList, ResponsesSamples, SchemaSample] }) -export class Method extends BaseComponent { +export default class Method extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/MethodsList/methods-list.js b/lib/components/MethodsList/methods-list.js index 1f743413..dc04f4cf 100644 --- a/lib/components/MethodsList/methods-list.js +++ b/lib/components/MethodsList/methods-list.js @@ -1,7 +1,7 @@ 'use strict'; import {RedocComponent, BaseComponent} from '../base'; -import {Method} from '../Method/method'; +import Method from '../Method/method'; @RedocComponent({ selector: 'methods-list', @@ -9,7 +9,7 @@ import {Method} from '../Method/method'; styleUrls: ['./lib/components/MethodsList/methods-list.css'], directives: [Method] }) -export class MethodsList extends BaseComponent { +export default class MethodsList extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.js index b8b5d83c..47e3d9f2 100644 --- a/lib/components/ParamsList/params-list.js +++ b/lib/components/ParamsList/params-list.js @@ -1,7 +1,7 @@ 'use strict'; import {RedocComponent, BaseComponent} from '../base'; -import {JsonSchemaView} from '../JsonSchemaView/json-schema-view'; +import JsonSchemaView from '../JsonSchemaView/json-schema-view'; @RedocComponent({ selector: 'params-list', @@ -9,7 +9,7 @@ import {JsonSchemaView} from '../JsonSchemaView/json-schema-view'; styleUrls: ['./lib/components/ParamsList/params-list.css'], directives: [JsonSchemaView] }) -export class ParamsList extends BaseComponent { +export default class ParamsList extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/Redoc/redoc.js b/lib/components/Redoc/redoc.js index 44f336bc..08f562d6 100644 --- a/lib/components/Redoc/redoc.js +++ b/lib/components/Redoc/redoc.js @@ -1,9 +1,9 @@ 'use strict'; import {RedocComponent, BaseComponent} from '../base'; -import {SchemaManager} from '../../utils/SchemaManager'; -import {ApiInfo} from '../ApiInfo/api-info'; -import {MethodsList} from '../MethodsList/methods-list'; +import SchemaManager from '../../utils/SchemaManager'; +import ApiInfo from '../ApiInfo/api-info'; +import MethodsList from '../MethodsList/methods-list'; @RedocComponent({ selector: 'redoc', @@ -11,7 +11,7 @@ import {MethodsList} from '../MethodsList/methods-list'; templateUrl: './lib/components/Redoc/redoc.html', directives: [ApiInfo, MethodsList] }) -export class Redoc extends BaseComponent { +export default class Redoc extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/ResponsesList/responses-list.js b/lib/components/ResponsesList/responses-list.js index 1dcdb159..a03bf31b 100644 --- a/lib/components/ResponsesList/responses-list.js +++ b/lib/components/ResponsesList/responses-list.js @@ -1,8 +1,8 @@ 'use strict'; import {RedocComponent, BaseComponent} from '../base'; -import {JsonPointer} from '../../utils/JsonPointer'; -import {JsonSchemaView} from '../JsonSchemaView/json-schema-view'; +import JsonPointer from '../../utils/JsonPointer'; +import JsonSchemaView from '../JsonSchemaView/json-schema-view'; function isNumeric(n) { return (!isNaN(parseFloat(n)) && isFinite(n)); @@ -14,7 +14,7 @@ function isNumeric(n) { styleUrls: ['./lib/components/ResponsesList/responses-list.css'], directives: [JsonSchemaView] }) -export class ResponsesList extends BaseComponent { +export default class ResponsesList extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/ResponsesSamples/responses-samples.js b/lib/components/ResponsesSamples/responses-samples.js index 41420127..1901605d 100644 --- a/lib/components/ResponsesSamples/responses-samples.js +++ b/lib/components/ResponsesSamples/responses-samples.js @@ -1,9 +1,9 @@ 'use strict'; import {RedocComponent, BaseComponent} from '../base'; -import {JsonPointer} from '../../utils/JsonPointer'; +import JsonPointer from '../../utils/JsonPointer'; import {Tabs, Tab} from '../../common-components/Tabs/tabs'; -import {SchemaSample} from '../SchemaSample/schema-sample'; +import SchemaSample from '../SchemaSample/schema-sample'; function isNumeric(n) { @@ -21,7 +21,7 @@ function hasExample(response) { styleUrls: ['./lib/components/ResponsesSamples/responses-samples.css'], directives: [SchemaSample, Tabs, Tab] }) -export class ResponsesSamples extends BaseComponent { +export default class ResponsesSamples extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/SchemaSample/schema-sample.js b/lib/components/SchemaSample/schema-sample.js index dc87d8a0..38234655 100644 --- a/lib/components/SchemaSample/schema-sample.js +++ b/lib/components/SchemaSample/schema-sample.js @@ -8,7 +8,7 @@ import SchemaSampler from 'json-schema-instantiator'; selector: 'schema-sample', templateUrl: './lib/components/SchemaSample/schema-sample.html' }) -export class SchemaSample extends BaseComponent { +export default class SchemaSample extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); } diff --git a/lib/components/SideMenu/side-menu.js b/lib/components/SideMenu/side-menu.js index 8f84737c..8df9c563 100644 --- a/lib/components/SideMenu/side-menu.js +++ b/lib/components/SideMenu/side-menu.js @@ -1,8 +1,8 @@ 'use strict'; import {RedocComponent, BaseComponent} from '../base'; -import {SchemaManager} from '../../utils/SchemaManager'; -import {SideMenuCat} from '../SideMenuCat/side-menu-cat'; +import SchemaManager from '../../utils/SchemaManager'; +import SideMenuCat from '../SideMenuCat/side-menu-cat'; import {NgZone} from 'angular2/angular2'; const CHANGE = { @@ -15,10 +15,10 @@ const CHANGE = { selector: 'side-menu', providers: [SchemaManager], templateUrl: './lib/components/SideMenu/side-menu.html', - styleUrls: ['./lib/components/SideMenu/side-menu.css'], + styleUrls: ['./lib/components/SideMenu/side-menu.css'], directives: [SideMenuCat] }) -export class SideMenu extends BaseComponent { +export default class SideMenu extends BaseComponent { constructor(schemaMgr, zone) { super(schemaMgr); this.zone = zone; @@ -129,4 +129,4 @@ export class SideMenu extends BaseComponent { this.changeActive(CHANGE.INITIAL); } } -SideMenu.parameters.push([NgZone]); +SideMenu.parameters = SideMenu.parameters.concat([NgZone]); diff --git a/lib/components/SideMenuCat/side-menu-cat.js b/lib/components/SideMenuCat/side-menu-cat.js index 9cfb9a77..e9780c9d 100644 --- a/lib/components/SideMenuCat/side-menu-cat.js +++ b/lib/components/SideMenuCat/side-menu-cat.js @@ -10,7 +10,7 @@ import {EventEmitter} from 'angular2/angular2'; styleUrls: ['./lib/components/SideMenuCat/side-menu-cat.css'], templateUrl: './lib/components/SideMenuCat/side-menu-cat.html' }) -export class SideMenuCat extends BaseComponent { +export default class SideMenuCat extends BaseComponent { constructor(schemaMgr) { super(schemaMgr); this.expand = new EventEmitter(); diff --git a/lib/components/base.js b/lib/components/base.js index e512b29a..844358ac 100644 --- a/lib/components/base.js +++ b/lib/components/base.js @@ -1,9 +1,8 @@ 'use strict'; import {Component, View, OnInit, CORE_DIRECTIVES} from 'angular2/angular2'; -import {SchemaManager} from '../utils/SchemaManager'; -import {JsonPointerEscapePipe} from '../utils/pipes'; -import {JsonPointer} from '../utils/JsonPointer'; -import {MarkedPipe} from '../utils/pipes'; +import SchemaManager from '../utils/SchemaManager'; +import JsonPointer from '../utils/JsonPointer'; +import {MarkedPipe, JsonPointerEscapePipe} from '../utils/pipes'; // common inputs for all components let commonInputs = ['pointer']; // json pointer to the schema chunk diff --git a/lib/components/index.js b/lib/components/index.js index 8b6de80d..66ce6b93 100644 --- a/lib/components/index.js +++ b/lib/components/index.js @@ -1,5 +1,42 @@ 'use strict'; -export * from './Redoc/redoc'; -export * from './SideMenu/side-menu'; -export * from './ApiInfo/api-info'; +import ApiInfo from './ApiInfo/api-info'; +import JsonSchemaView from './JsonSchemaView/json-schema-view'; +import Method from './Method/method.js'; +import MethodsList from './MethodsList/methods-list'; +import ParamsList from './ParamsList/params-list'; +import Redoc from './Redoc/redoc'; +import ResponsesList from './ResponsesList/responses-list'; +import ResponsesSamples from './ResponsesSamples/responses-samples'; +import SchemaSample from './SchemaSample/schema-sample'; +import SideMenu from './SideMenu/side-menu'; +import SideMenuCat from './SideMenuCat/side-menu-cat'; + +const REDOC_COMPONENTS = [ + ApiInfo, + JsonSchemaView, + Method, + MethodsList, + ParamsList, + Redoc, + ResponsesList, + ResponsesSamples, + SchemaSample, + SideMenu, + SideMenuCat +]; + +export { + ApiInfo, + JsonSchemaView, + Method, + MethodsList, + ParamsList, + Redoc, + ResponsesList, + ResponsesSamples, + SchemaSample, + SideMenu, + SideMenuCat, + REDOC_COMPONENTS +}; diff --git a/lib/index.js b/lib/index.js index 42e485d1..7b517747 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,9 +1,9 @@ 'use strict'; import 'reflect-metadata'; -import { bootstrap } from 'angular2/angular2'; -import { Redoc, SideMenu } from './components/index'; -import { SchemaManager} from './utils/SchemaManager'; +import {bootstrap} from 'angular2/angular2'; +import {Redoc, SideMenu} from './components/index'; +import SchemaManager from './utils/SchemaManager'; export * from './components/index'; diff --git a/lib/utils/SchemaManager.js b/lib/utils/SchemaManager.js index 75b47b01..87f7524f 100644 --- a/lib/utils/SchemaManager.js +++ b/lib/utils/SchemaManager.js @@ -3,7 +3,7 @@ import SwaggerParser from 'swagger-parser'; import JsonPointer from './JsonPointer'; import {methods as swaggerMethods} from './swagger-defs'; -export class SchemaManager { +export default class SchemaManager { constructor() { if (SchemaManager.prototype._instance) { return SchemaManager.prototype._instance;