Merge commit '822d84c9f82c27f3f9c22f5b7b0483a792748ef4' into releases

This commit is contained in:
RedocBot 2016-09-12 21:17:57 +00:00 committed by travis@localhost
commit 8579f39117
39 changed files with 280 additions and 186 deletions

View File

@ -1,3 +1,12 @@
# 1.3.0 (2014-08-31)
### Bug fixes
* Fix code samples are not shown for operations without body param (#93)
* Fixed side menu overlapped site footer (#75)
* Fix broken order in discriminator dropdown
### Features/Improvements
* Support "x-nullable" property by @kedashoe (#92)
# 1.2.0 (2016-08-30)
### Bug fixes
* Fix sticky sidebar top sticking (#75)

View File

@ -1,7 +1,7 @@
# ReDoc
**OpenAPI/Swagger-generated API Reference Documentation**
[![Build Status](https://travis-ci.org/Rebilly/ReDoc.svg?branch=master)](https://travis-ci.org/Rebilly/ReDoc) [![Coverage Status](https://coveralls.io/repos/Rebilly/ReDoc/badge.svg?branch=master&service=github)](https://coveralls.io/github/Rebilly/ReDoc?branch=master) [![Tested on APIs.guru](http://api.apis.guru/badges/tested_on.svg)](https://APIs.guru) [![Code Climate](https://codeclimate.com/github/Rebilly/ReDoc/badges/gpa.svg)](https://codeclimate.com/github/Rebilly/ReDoc) [![David](https://david-dm.org/Rebilly/ReDoc/dev-status.svg)](https://david-dm.org/Rebilly/ReDoc#info=devDependencies) [![Stories in Ready](https://badge.waffle.io/Rebilly/ReDoc.png?label=ready&title=Ready)](https://waffle.io/Rebilly/ReDoc)
[![Build Status](https://travis-ci.org/Rebilly/ReDoc.svg?branch=master)](https://travis-ci.org/Rebilly/ReDoc) [![Coverage Status](https://coveralls.io/repos/Rebilly/ReDoc/badge.svg?branch=master&service=github)](https://coveralls.io/github/Rebilly/ReDoc?branch=master) [![Tested on APIs.guru](http://api.apis.guru/badges/tested_on.svg)](https://APIs.guru) [![Code Climate](https://codeclimate.com/github/Rebilly/ReDoc/badges/gpa.svg)](https://codeclimate.com/github/Rebilly/ReDoc) [![dependencies Status](https://david-dm.org/Rebilly/ReDoc/status.svg)](https://david-dm.org/Rebilly/ReDoc) [![devDependencies Status](https://david-dm.org/Rebilly/ReDoc/dev-status.svg)](https://david-dm.org/Rebilly/ReDoc#info=devDependencies) [![Stories in Ready](https://badge.waffle.io/Rebilly/ReDoc.png?label=ready&title=Ready)](https://waffle.io/Rebilly/ReDoc)
[![npm](http://img.shields.io/npm/v/redoc.svg)](https://www.npmjs.com/package/redoc) [![Bower](http://img.shields.io/bower/v/redoc.svg)](http://bower.io/) [![License](https://img.shields.io/npm/l/redoc.svg)](https://github.com/Rebilly/ReDoc/blob/master/LICENSE)

View File

@ -12,13 +12,9 @@ module.exports = {
debug: false,
resolve: {
extensions: ['', '.ts', '.js', '.json', '.css', '.scss', '.html'],
extensions: ['', '.ts', '.js', '.json', '.css'],
root: root('lib'),
descriptionFiles: ['package.json'],
modules: [
'node_modules',
root('lib')
],
modulesDirectories: ['node_modules'],
alias: {
'./lib/bootstrap': root('lib/bootstrap.dev'),
http: 'stream-http',
@ -26,10 +22,17 @@ module.exports = {
}
},
externals: {
"jquery": "jQuery"
"jquery": "jQuery",
'esprima': 'esprima' // optional dep of ys-yaml not needed for redoc
},
node: {
fs: "empty"
fs: "empty",
crypto: "empty",
global: "window",
process: true,
module: false,
clearImmediate: false,
setImmediate: false
},
entry: {
'redoc': './lib/index.ts',
@ -57,7 +60,10 @@ module.exports = {
module: {
preLoaders: [{
test: /\.js$/,
loader: 'source-map'
loader: 'source-map-loader',
exclude: [
/node_modules/
]
}],
loaders: [{
test: /\.ts$/,

View File

@ -12,26 +12,29 @@ const BANNER =
module.exports = {
context: root(),
devtool: 'cheap-module-source-map',
devtool: 'source-map',
resolve: {
extensions: ['', '.ts', '.js', '.json', '.css', '.scss', '.html'],
extensions: ['', '.ts', '.js', '.json', '.css'],
root: root('lib'),
descriptionFiles: ['package.json'],
modules: [
'node_modules',
root('lib')
],
modulesDirectories: ['node_modules'],
alias: {
http: 'stream-http',
https: 'stream-http'
}
},
externals: {
"jquery": "jQuery"
'jquery': 'jQuery',
'esprima': 'esprima' // optional dep of ys-yaml not needed for redoc
},
node: {
fs: "empty"
fs: "empty",
crypto: "empty",
global: "window",
process: true,
module: false,
clearImmediate: false,
setImmediate: false
},
entry: {
'redoc': ['./lib/polyfills.ts', './lib/vendor.ts', './lib/index.ts']
@ -49,7 +52,10 @@ module.exports = {
module: {
preLoaders: [{
test: /\.js$/,
loader: 'source-map'
loader: 'source-map-loader',
exclude: [
/node_modules/
]
}],
loaders: [{
test: /\.ts$/,

View File

@ -8,13 +8,9 @@ module.exports = {
devtool: 'inline-source-map',
resolve: {
extensions: ['', '.ts', '.js', '.json', '.css', '.scss', '.html'],
extensions: ['', '.ts', '.js', '.json', '.css'],
root: root('lib'),
descriptionFiles: ['package.json'],
modules: [
'node_modules',
root('lib'),
],
modulesDirectories: ['node_modules'],
alias: {
'./lib/bootstrap': root('lib/bootstrap.dev'),
http: 'stream-http',
@ -22,10 +18,17 @@ module.exports = {
}
},
externals: {
"jquery": "jQuery"
"jquery": "jQuery",
'esprima': 'esprima' // optional dep of ys-yaml not needed for redoc
},
node: {
fs: "empty"
fs: "empty",
crypto: "empty",
global: "window",
process: true,
module: false,
clearImmediate: false,
setImmediate: false
},
output: {
@ -38,7 +41,10 @@ module.exports = {
module: {
preLoaders: [{
test: /\.js$/,
loader: 'source-map'
loader: 'source-map-loader',
exclude: [
/node_modules/
]
}],
loaders: [ {
test: /\.ts$/,

View File

@ -12,13 +12,13 @@ info:
For this sample, you can use the api key `special-key` to test the authorization filters.
# Introduction
This API is documented in **OpenAPI format** and is based on
[Pestore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team.
[Petstore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team.
It was **extended** to illustrate features of [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo)
tool and [ReDoc](https://github.com/Rebilly/ReDoc) documentation. In addition to standard
OpenAPI syntax we use a few [vendor extensions](https://github.com/Rebilly/ReDoc/blob/master/docs/redoc-vendor-extensions.md).
# OpenAPI Specification
This API is documented in **OpenAPI format** and is based on
[Pestore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team.
[Petstore sample](http://petstore.swagger.io/) provided by [swagger.io](http://swagger.io) team.
It was **extended** to illustrate features of [generator-openapi-repo](https://github.com/Rebilly/generator-openapi-repo)
tool and [ReDoc](https://github.com/Rebilly/ReDoc) documentation. In addition to standard
OpenAPI syntax we use a few [vendor extensions](https://github.com/Rebilly/ReDoc/blob/master/docs/redoc-vendor-extensions.md).

View File

@ -22,7 +22,7 @@ a.openapi-button {
font-weight: normal;
}
:host [section] {
:host /deep/ [section] {
padding-top: 60px;
margin-top: 20px;
}

View File

@ -7,7 +7,7 @@ import { OptionsService } from '../../services/index';
import {
inject,
async,
TestComponentBuilder
TestBed
} from '@angular/core/testing';
import { ApiInfo } from './api-info';
@ -15,23 +15,23 @@ import { SpecManager } from '../../utils/SpecManager';
describe('Redoc components', () => {
describe('ApiInfo Component', () => {
let builder;
let component;
let fixture;
let opts;
beforeEach(async(inject([TestComponentBuilder, SpecManager, OptionsService], (tcb, specMgr, _opts) => {
beforeEach(() => {
TestBed.configureTestingModule({ declarations: [ TestAppComponent ] });
});
beforeEach(async(inject([SpecManager, OptionsService], (specMgr, _opts) => {
opts = _opts;
opts.options = {
scrollYOffset: () => 0,
$scrollParent: window
};
builder = tcb;
return specMgr.load('/tests/schemas/api-info-test.json');
})));
beforeEach(() => {
fixture = builder.createSync(TestAppComponent);
fixture = TestBed.createComponent(TestAppComponent);
component = getChildDebugElement(fixture.debugElement, 'api-info').componentInstance;
fixture.detectChanges();
});
@ -55,7 +55,6 @@ describe('Redoc components', () => {
/** Test component that contains an ApiInfo. */
@Component({
selector: 'test-app',
directives: [ApiInfo],
template:
`<api-info></api-info>`
})

View File

@ -6,7 +6,7 @@ import { Component } from '@angular/core';
import {
inject,
async,
TestComponentBuilder
TestBed
} from '@angular/core/testing';
import { ApiLogo } from './api-logo';
@ -21,13 +21,15 @@ describe('Redoc components', () => {
let specMgr;
let schemaUrl = '/tests/schemas/api-info-test.json';
beforeEach(async(inject([TestComponentBuilder, SpecManager], (tcb, _specMgr) => {
builder = tcb;
beforeEach(() => {
TestBed.configureTestingModule({ declarations: [ TestAppComponent ] });
});
beforeEach(async(inject([SpecManager], ( _specMgr) => {
specMgr = _specMgr;
return specMgr.load(schemaUrl);
})));
beforeEach(() => {
fixture = builder.createSync(TestAppComponent);
fixture = TestBed.createComponent(TestAppComponent);
component = getChildDebugElement(fixture.debugElement, 'api-logo').componentInstance;
fixture.detectChanges();
});
@ -59,7 +61,6 @@ describe('Redoc components', () => {
/** Test component that contains an ApiInfo. */
@Component({
selector: 'test-app',
directives: [ApiLogo],
providers: [SpecManager],
template:
`<api-logo></api-logo>`

View File

@ -5,22 +5,26 @@ import { Component } from '@angular/core';
import {
inject,
TestComponentBuilder
TestBed
} from '@angular/core/testing';
import { JsonSchemaLazy } from './json-schema-lazy';
describe('Redoc components', () => {
beforeEach(() => {
TestBed.configureTestingModule({ declarations: [ TestAppComponent ] });
});
describe('JsonSchemaLazy Component', () => {
let builder;
let component;
let fixture;
beforeEach(inject([TestComponentBuilder], (tcb) => {
builder = tcb;
beforeEach(inject([TestBed], (tcb) => {
}));
beforeEach(() => {
fixture = builder.createSync(TestAppComponent);
fixture = TestBed.createComponent(TestAppComponent);
let debugEl = getChildDebugElement(fixture.debugElement, 'json-schema-lazy');
component = <JsonSchemaLazy>debugEl.componentInstance;
spyOn(component, '_loadAfterSelf').and.stub();
@ -47,7 +51,6 @@ describe('Redoc components', () => {
/** Test component that contains a Method. */
@Component({
selector: 'test-app',
directives: [JsonSchemaLazy],
template:
`<json-schema-lazy></json-schema-lazy>`
})

View File

@ -72,7 +72,7 @@
</span>
<span *ngIf="prop._required" class="param-required">Required</span>
<span *ngIf="prop['x-nullable']" class="param-nullable">Nullable</span>
<div *ngIf="prop.default">Default: {{prop.default | json}}</div>
<div *ngIf="prop.default != null">Default: {{prop.default | json}}</div>
<div *ngIf="prop.enum && !prop.isDiscriminator" class="param-enum">
<span *ngFor="let enumItem of prop.enum" class="enum-value {{enumItem.type}}"> {{enumItem.val | json}} </span>
</div>

View File

@ -3,7 +3,7 @@
import { Component } from '@angular/core';
import {
inject,
TestComponentBuilder
TestBed
} from '@angular/core/testing';
import { getChildDebugElement } from '../../../tests/helpers';
@ -13,19 +13,22 @@ import { JsonSchema } from './json-schema';
import { SpecManager } from '../../utils/SpecManager';;
describe('Redoc components', () => {
beforeEach(() => {
TestBed.configureTestingModule({ declarations: [ TestAppComponent ] });
});
describe('JsonSchema Component', () => {
let builder;
let component;
let fixture;
let specMgr;
beforeEach(inject([TestComponentBuilder, SpecManager], (tcb, _spec) => {
builder = tcb;
beforeEach(inject([SpecManager], ( _spec) => {
specMgr = _spec;
}));
beforeEach(() => {
fixture = builder.createSync(TestAppComponent);
fixture = TestBed.createComponent(TestAppComponent);
let debugEl = getChildDebugElement(fixture.debugElement, 'json-schema');
component = debugEl.componentInstance;
});
@ -59,7 +62,6 @@ describe('Redoc components', () => {
/** Test component that contains a Method. */
@Component({
selector: 'test-app',
directives: [JsonSchema],
providers: [SpecManager],
template:
`<json-schema></json-schema>`

View File

@ -47,6 +47,7 @@ export class JsonSchema extends BaseComponent implements OnInit {
this.pointer = activeDescendant.$ref;
this.schema = this.specMgr.byPointer(this.pointer);
this.normalizer.reset();
this.schema = this.normalizer.normalize(this.schema, this.normPointer,
{resolved: true});
this.preprocessSchema();
@ -119,7 +120,7 @@ export class JsonSchema extends BaseComponent implements OnInit {
}
trackByName(index: number, item: any): number {
return item.name;
return item.name + (item._pointer || '');
}
ngOnInit() {

View File

@ -4,7 +4,7 @@ import { Component } from '@angular/core';
import {
inject,
async,
TestComponentBuilder
TestBed
} from '@angular/core/testing';
import { getChildDebugElement } from '../../../tests/helpers';
@ -13,17 +13,20 @@ import { Method } from './method';
import { SpecManager } from '../../utils/SpecManager';;
describe('Redoc components', () => {
beforeEach(() => {
TestBed.configureTestingModule({ declarations: [ TestAppComponent ] });
});
describe('Method Component', () => {
let builder;
let component;
beforeEach(async(inject([TestComponentBuilder, SpecManager], (tcb, specMgr) => {
builder = tcb;
beforeEach(async(inject([SpecManager], ( specMgr) => {
return specMgr.load('/tests/schemas/extended-petstore.yml');
})));
beforeEach(() => {
let fixture = builder.createSync(TestAppComponent);
let fixture = TestBed.createComponent(TestAppComponent);
component = getChildDebugElement(fixture.debugElement, 'method').componentInstance;
fixture.detectChanges();
});
@ -50,7 +53,6 @@ describe('Redoc components', () => {
/** Test component that contains a Method. */
@Component({
selector: 'test-app',
directives: [Method],
providers: [SpecManager],
template:
`<method pointer='#/paths/~1user~1{username}/put'></method>`

View File

@ -4,7 +4,7 @@ import { Component } from '@angular/core';
import {
inject,
async,
TestComponentBuilder
TestBed
} from '@angular/core/testing';
import { getChildDebugElement } from '../../../tests/helpers';
@ -14,17 +14,20 @@ import { MethodsList } from './methods-list';
import { SpecManager } from '../../utils/SpecManager';
describe('Redoc components', () => {
beforeEach(() => {
TestBed.configureTestingModule({ declarations: [ TestAppComponent ] });
});
describe('MethodsList Component', () => {
let builder;
let component;
let fixture;
beforeEach(async(inject([TestComponentBuilder, SpecManager], (tcb, specMgr) => {
builder = tcb;
beforeEach(async(inject([SpecManager], ( specMgr) => {
return specMgr.load('/tests/schemas/methods-list-component.json');
})));
beforeEach(() => {
fixture = builder.createSync(TestAppComponent);
fixture = TestBed.createComponent(TestAppComponent);
component = getChildDebugElement(fixture.debugElement, 'methods-list').componentInstance;
fixture.detectChanges();
});
@ -47,7 +50,6 @@ describe('Redoc components', () => {
@Component({
selector: 'test-app',
directives: [ MethodsList ],
template:
`<methods-list></methods-list>`
})

View File

@ -16,7 +16,7 @@
title="{{param._displayTypeHint}}"> {{param._displayType}} {{param._displayFormat}}</span>
<span class="param-range" *ngIf="param._range"> {{param._range}} </span>
<span *ngIf="param.required" class="param-required">Required</span>
<div class="default" *ngIf="param.default">Default: {{param.default | json}}</div>
<div class="default" *ngIf="param.default != null">Default: {{param.default | json}}</div>
<div *ngIf="param.enum" class="param-enum">
<span *ngFor="let enumItem of param.enum" class="enum-value {{enumItem.type}}"> {{enumItem.val | json}} </span>
</div>

View File

@ -103,7 +103,7 @@ api-logo {
/* global redoc styles */
@for $index from 1 through 5 {
:host h#{$index}{
:host /deep/ h#{$index}{
margin-top: 0;
font-family: $headers-font, $headers-font-family;
color: $headers-color;
@ -111,7 +111,7 @@ api-logo {
}
}
:host {
:host /deep/ {
h1 { font-size: $h1; }
h2 { font-size: $h2; }
h3 { font-size: $h3; }
@ -168,7 +168,7 @@ footer {
/* markdown elements */
:host .redoc-markdown-block {
:host /deep/ .redoc-markdown-block {
pre {
font-family: Courier, monospace;
white-space: pre-wrap;

View File

@ -8,7 +8,7 @@ import {
async
} from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { Redoc } from './redoc';
import { SpecManager } from '../../utils/SpecManager';
@ -17,28 +17,31 @@ import { OptionsService } from '../../services/index';
let optsMgr:OptionsService;
describe('Redoc components', () => {
beforeEach(() => {
TestBed.configureTestingModule({ declarations: [ TestAppComponent ] });
});
describe('Redoc Component', () => {
let builder;
let specMgr;
beforeEach(async(inject([TestComponentBuilder, SpecManager, OptionsService],
(tcb, _specMgr, _optsMgr) => {
beforeEach(async(inject([SpecManager, OptionsService],
( _specMgr, _optsMgr) => {
optsMgr = _optsMgr;
builder = tcb;
specMgr = _specMgr;
return specMgr.load('/tests/schemas/extended-petstore.yml');
})));
it('should init component', () => {
let fixture = builder.createSync(TestAppComponent);
let fixture = TestBed.createComponent(TestAppComponent);
let component = getChildDebugElement(fixture.debugElement, 'redoc').componentInstance;
expect(component).not.toBeNull();
fixture.destroy();
});
it('should init components tree without errors', () => {
let fixture = builder.createSync(TestAppComponent);
let fixture = TestBed.createComponent(TestAppComponent);
(() => fixture.detectChanges()).should.not.throw();
fixture.destroy();
});
@ -89,16 +92,16 @@ describe('Redoc components', () => {
// let dom;
// let destroySpy;
//
// beforeEach(async(inject([TestComponentBuilder, SpecManager, OptionsService, BrowserDomAdapter],
// (tcb, specMgr, opts, _dom) => {
// builder = tcb;
// beforeEach(async(inject([SpecManager, OptionsService, BrowserDomAdapter],
// ( specMgr, opts, _dom) => {
//
// optsMgr = opts;
// dom = _dom;
// return specMgr.load('/tests/schemas/extended-petstore.yml');
// })));
//
// beforeEach(() => {
// fixture = builder.createSync(TestAppComponent);
// fixture = TestBed.createComponent(TestAppComponent);
// element = getChildDebugElement(fixture.debugElement, 'methods-list').nativeElement;
// destroySpy = jasmine.createSpy('spy');
// Redoc.appRef = <ComponentRef<any>>{
@ -165,7 +168,6 @@ describe('Redoc components', () => {
/** Test component that contains a Redoc. */
@Component({
selector: 'test-app',
directives: [Redoc],
template:
`<redoc disable-lazy-schemas></redoc>`
})

View File

@ -46,7 +46,7 @@ header {
font-weight: normal;
}
:host > tabs > ul li {
:host /deep/ > tabs > ul li {
font-family: $headers-font;
font-size: .9em;
border-radius: $border-radius;
@ -66,7 +66,7 @@ header {
}
}
:host tabs ul {
:host /deep/ tabs ul {
padding-top: 10px;
}

View File

@ -55,7 +55,7 @@ pre {
opacity: 1;
}
:host {
:host /deep/ {
.property {
//font-weight: bold;
}

View File

@ -5,13 +5,11 @@ import { Component, ElementRef, Input, ChangeDetectionStrategy, OnInit } from '@
import * as OpenAPISampler from 'openapi-sampler';
import { BaseComponent, SpecManager } from '../base';
import { JsonFormatter } from '../../utils/JsonFormatterPipe';
import { SchemaNormalizer } from '../../services/schema-normalizer.service';
@Component({
selector: 'schema-sample',
templateUrl: './schema-sample.html',
pipes: [JsonFormatter],
styleUrls: ['./schema-sample.css'],
changeDetection: ChangeDetectionStrategy.OnPush
})

View File

@ -9,7 +9,7 @@ import {
async
} from '@angular/core/testing';
import { TestComponentBuilder } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { MethodsList, SideMenu } from '../index';
@ -18,14 +18,17 @@ import { SpecManager } from '../../utils/SpecManager';
let testOptions;
describe('Redoc components', () => {
beforeEach(() => {
TestBed.configureTestingModule({ declarations: [ TestAppComponent ] });
});
describe('SideMenu Component', () => {
let builder;
let component;
let fixture;
beforeEach(async(inject([TestComponentBuilder, SpecManager, OptionsService],
(tcb, specMgr, opts) => {
builder = tcb;
beforeEach(async(inject([SpecManager, OptionsService],
( specMgr, opts) => {
testOptions = opts;
testOptions.options = {
scrollYOffset: () => 0,
@ -35,7 +38,7 @@ describe('Redoc components', () => {
})));
beforeEach(() => {
fixture = builder.createSync(TestAppComponent);
fixture = TestBed.createComponent(TestAppComponent);
component = getChildDebugElement(fixture.debugElement, 'side-menu').componentInstance;
fixture.detectChanges();
});
@ -54,7 +57,6 @@ describe('Redoc components', () => {
/** Test component that contains an ApiInfo. */
@Component({
selector: 'test-app',
directives: [MethodsList, SideMenu],
template:
`<side-menu></side-menu>
<methods-list></methods-list>`

View File

@ -2,13 +2,15 @@
import { Component, ElementRef, ChangeDetectorRef, OnInit } from '@angular/core';
import { global } from '@angular/core/src/facade/lang';
//import { global } from '@angular/core/src/facade/lang';
import { trigger, state, animate, transition, style } from '@angular/core';
import { BaseComponent, SpecManager } from '../base';
import { ScrollService, Hash, MenuService, OptionsService } from '../../services/index';
import { BrowserDomAdapter as DOM } from '../../utils/browser-adapter';
import { MenuCategory } from '../../services/schema-helper.service';
const global = window;
@Component({
selector: 'side-menu',
templateUrl: './side-menu.html',

View File

@ -1,4 +1,30 @@
import 'core-js/es6';
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/set';
import 'core-js/es6/weak-map';
import 'core-js/es6/weak-set';
import 'core-js/es6/typed';
import 'core-js/es6/reflect';
// see issue https://github.com/AngularClass/angular2-webpack-starter/issues/709
// import 'core-js/es6/promise';
import 'core-js/es7/reflect';
import 'ts-helpers';
import 'zone.js/dist/zone';
// Typescript emit helpers polyfill
import 'ts-helpers';
if (!IS_PRODUCTION) {
Error.stackTraceLimit = Infinity;
require('zone.js/dist/long-stack-trace-zone');
}

View File

@ -3,32 +3,34 @@ import { Component } from '@angular/core';
import {
inject,
async,
TestComponentBuilder
TestBed
} from '@angular/core/testing';
import { MenuService } from './menu.service';
import { Hash } from './hash.service';
import { ScrollService } from './scroll.service';
import { MethodsList } from '../components/index';
import { SpecManager } from '../utils/SpecManager';;
describe('Menu service', () => {
beforeEach(() => {
TestBed.configureTestingModule({ declarations: [ TestAppComponent ] });
});
let menu, hashService, scroll;
let builder;
let specMgr;
beforeEach(async(inject([TestComponentBuilder, SpecManager, Hash, ScrollService],
(tcb, _specMgr, _hash, _scroll, _menu) => {
beforeEach(async(inject([SpecManager, Hash, ScrollService],
( _specMgr, _hash, _scroll, _menu) => {
hashService = _hash;
scroll = _scroll;
builder = tcb;
specMgr = _specMgr;
return specMgr.load('/tests/schemas/extended-petstore.yml');
})));
beforeEach(() => {
menu = new MenuService(hashService, scroll, specMgr);
let fixture = builder.createSync(TestAppComponent);
let fixture = TestBed.createComponent(TestAppComponent);
fixture.detectChanges();
});
@ -91,7 +93,6 @@ describe('Menu service', () => {
@Component({
selector: 'test-app',
directives: [ MethodsList ],
template:
`<div id='parent' style='height: 500px; overflow:auto'>
<methods-list></methods-list>

View File

@ -41,6 +41,10 @@ export class SchemaNormalizer {
res['x-redoc-normalized'] = true;
return res;
}
reset() {
this._dereferencer.reset();
}
}
class SchemaWalker {
@ -178,6 +182,9 @@ class SchemaDereferencer {
constructor(private _spec: SpecManager, private normalizator: SchemaNormalizer) {
}
reset() {
this._refCouner.reset();
}
visit($ref) {
this._refCouner.visit($ref);
@ -208,7 +215,7 @@ class SchemaDereferencer {
let keysCount = Object.keys(schema).length;
if ( keysCount > 2 || (keysCount === 2 && !schema.description) ) {
WarningsService.warn(`Other properties are defined at the same level as $ref at "#${pointer}". ` +
'They are IGNORRED according to the JsonSchema spec');
'They are IGNORED according to the JsonSchema spec');
resolved.description = resolved.description || schema.description;
}

View File

@ -1,6 +1,6 @@
@import '../../styles/variables';
:host {
:host /deep/ {
.dk-select {
max-width: 100%;
font-family: $headers-font, $headers-font-family;

View File

@ -4,20 +4,23 @@ import { getChildDebugElementByType } from '../../../../tests/helpers';
import { Component } from '@angular/core';
import {
inject,
TestComponentBuilder
TestBed
} from '@angular/core/testing';
import { StickySidebar } from '../index';
describe('Common components', () => {
beforeEach(() => {
TestBed.configureTestingModule({ declarations: [ TestApp ] });
});
describe('StickySidebar Component', () => {
let builder;
let component;
let fixture;
beforeEach(inject([TestComponentBuilder], (tcb) => {
builder = tcb;
fixture = builder.createSync(TestApp);
beforeEach(inject([TestBed], (tcb) => {
fixture = TestBed.createComponent(TestApp);
let debugEl = getChildDebugElementByType(fixture.debugElement, StickySidebar);
component = debugEl.injector.get(StickySidebar);
}));
@ -64,7 +67,6 @@ describe('Common components', () => {
/** Test component that contains an ApiInfo. */
@Component({
selector: 'test-app',
directives: [StickySidebar],
template:
`<div style="padding-top: 20px">
<div style="height: 20px; position: fixed; top: 0;"> </div>

View File

@ -5,12 +5,15 @@ import { Component } from '@angular/core';
import {
inject,
TestComponentBuilder
TestBed
} from '@angular/core/testing';
import {Tabs, Tab} from '../index';
describe('Common components', () => {
beforeEach(() => {
TestBed.configureTestingModule({ declarations: [ TestApp ] });
});
describe('Tabs Component', () => {
let builder;
let component;
@ -19,9 +22,9 @@ describe('Common components', () => {
let fixture;
let hostComponent;
beforeEach(inject([TestComponentBuilder], (tcb) => {
builder = tcb;
fixture = builder.createSync(TestApp);
beforeEach(inject([TestBed], (tcb) => {
fixture = TestBed.createComponent(TestApp);
hostComponent = fixture.debugElement.componentInstance;
debugEl = getChildDebugElement(fixture.debugElement, 'tabs');
childDebugEls = getChildDebugElementAll(debugEl, 'tab');
@ -131,7 +134,6 @@ describe('Common components', () => {
/** Test component that contains an ApiInfo. */
@Component({
selector: 'test-app',
directives: [Tabs, Tab],
template:
`<tabs (change)="onEvent($event)">
<tab tabTitle="Tab1" tabStatus="test">Test</tab>

View File

@ -21,7 +21,7 @@ $zippy-redirect-bg-color: rgba($zippy-redirect-color, .08);
.zippy-title {
padding: 10px;
border-radius: 2px;
margin: 2px 0;
margin-bottom: 4px;
line-height: 1.5em;
background-color: #f2f2f2;
cursor: pointer;
@ -46,16 +46,12 @@ $zippy-redirect-bg-color: rgba($zippy-redirect-color, .08);
background-color: $zippy-info-bg-color;
}
}
.zippy-indicator svg {
height: 1.2em;
vertical-align: middle;
transition: all 0.3s ease;
transform: rotateZ(-180deg);
}
.zippy-hidden > .zippy-title svg {
transform: rotateZ(0);
}
.zippy-title polygon {
.zippy-success > & {

View File

@ -5,21 +5,23 @@ import { getChildDebugElement, mouseclick } from '../../../../tests/helpers';
import { Component } from '@angular/core';
import {
inject,
TestComponentBuilder
TestBed
} from '@angular/core/testing';
import { Zippy } from '../index';
describe('Common components', () => {
beforeEach(() => {
TestBed.configureTestingModule({ declarations: [ TestApp ] });
});
describe('Zippy Component', () => {
let builder;
let component;
let nativeElement;
let fixture;
beforeEach(inject([TestComponentBuilder], (tcb) => {
builder = tcb;
fixture = builder.createSync(TestApp);
beforeEach(inject([TestBed], (tcb) => {
fixture = TestBed.createComponent(TestApp);
let debugEl = getChildDebugElement(fixture.debugElement, 'zippy');
component = debugEl.componentInstance;
nativeElement = debugEl.nativeElement;
@ -92,7 +94,6 @@ describe('Common components', () => {
/** Test component that contains an ApiInfo. */
@Component({
selector: 'test-app',
directives: [Zippy],
template:
`<zippy title="Zippy" type="test" [visible]="true" [empty]="true" (open)="open()" (close)="close()">test</zippy>`
})

View File

@ -1,14 +1,18 @@
'use strict';
import { Pipe, PipeTransform } from '@angular/core';
import { isBlank } from '@angular/core/src/facade/lang';
import { DomSanitizationService } from '@angular/platform-browser';
//import { isBlank } from '@angular/core/src/facade/lang';
import { DomSanitizer } from '@angular/platform-browser';
function isBlank(obj) {
return obj === undefined || obj === null;
}
var level = 1;
const COLLAPSE_LEVEL = 2;
@Pipe({ name: 'jsonFormatter' })
export class JsonFormatter implements PipeTransform {
constructor(private sanitizer: DomSanitizationService) {}
constructor(private sanitizer: DomSanitizer) {}
transform(value) {
if (isBlank(value)) return value;
return this.sanitizer.bypassSecurityTrustHtml(jsonToHTML(value));

View File

@ -4,7 +4,7 @@ import * as JsonSchemaRefParser from 'json-schema-ref-parser';
import { JsonPointer } from './JsonPointer';
import { renderMd, safePush } from './helpers';
import * as slugify from 'slugify';
import { parse as urlParse } from 'url';
import { parse as urlParse, resolve as urlResolve } from 'url';
export class SpecManager {
public _schema: any = {};
@ -42,7 +42,7 @@ export class SpecManager {
/* calculate common used values */
init() {
let urlParts = this._url ? urlParse(this._url) : {};
let urlParts = this._url ? urlParse(urlResolve(window.location.href, this._url)) : {};
let schemes = this._schema.schemes;
let protocol;
if (!schemes || !schemes.length) {
@ -56,7 +56,8 @@ export class SpecManager {
}
let host = this._schema.host || urlParts.host;
this.apiUrl = protocol + '://' + host + this._schema.basePath;
let basePath = this._schema.basePath || '/';
this.apiUrl = protocol + '://' + host + basePath;
if (this.apiUrl.endsWith('/')) {
this.apiUrl = this.apiUrl.substr(0, this.apiUrl.length - 1);
}

View File

@ -1,15 +1,21 @@
'use strict';
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizationService } from '@angular/platform-browser';
import { DomSanitizer } from '@angular/platform-browser';
import { isString, stringify, isBlank } from '@angular/core/src/facade/lang';
import { BaseException } from '@angular/core/src/facade/exceptions';
import JsonPointer from './JsonPointer';
import { renderMd } from './helpers';
import { JsonFormatter } from './JsonFormatterPipe';
declare var Prism: any;
class BaseException {
message: string;
constructor(message) {
this.message = message;
}
}
class InvalidPipeArgumentException extends BaseException {
constructor(type, value) {
@ -52,7 +58,7 @@ export class JsonPointerEscapePipe implements PipeTransform {
@Pipe({ name: 'marked' })
export class MarkedPipe implements PipeTransform {
constructor(private sanitizer: DomSanitizationService) {}
constructor(private sanitizer: DomSanitizer) {}
transform(value:string) {
if (isBlank(value)) return value;
if (!isString(value)) {
@ -67,7 +73,7 @@ export class MarkedPipe implements PipeTransform {
@Pipe({ name: 'safe' })
export class SafePipe implements PipeTransform {
constructor(private sanitizer: DomSanitizationService) {}
constructor(private sanitizer: DomSanitizer) {}
transform(value:string) {
if (isBlank(value)) return value;
if (!isString(value)) {
@ -88,7 +94,7 @@ const langMap = {
@Pipe({ name: 'prism' })
export class PrismPipe implements PipeTransform {
constructor(private sanitizer: DomSanitizationService) {}
constructor(private sanitizer: DomSanitizer) {}
transform(value, args) {
if (isBlank(args) || args.length === 0) {
throw new BaseException('Prism pipe requires one argument');
@ -119,5 +125,5 @@ export class EncodeURIComponentPipe implements PipeTransform {
}
export const REDOC_PIPES = [
JsonPointerEscapePipe, MarkedPipe, SafePipe, PrismPipe, EncodeURIComponentPipe
JsonPointerEscapePipe, MarkedPipe, SafePipe, PrismPipe, EncodeURIComponentPipe, JsonFormatter
];

View File

@ -23,9 +23,12 @@ import 'dropkickjs/build/css/dropkick.css';
import 'prismjs/themes/prism-dark.css';
import 'hint.css/hint.base.css';
import '@angular/common';
import '@angular/core';
import '@angular/platform-browser';
if (!IS_PRODUCTION) {
require('@angular/platform-browser');
require('@angular/platform-browser-dynamic');
require('@angular/core');
require('@angular/common');
// RxJS
import 'rxjs/Rx';
// RxJS
require('rxjs/Rx');
}

View File

@ -14,3 +14,8 @@ declare module "*.css" {
declare var LIB_VERSION: any;
declare var IS_PRODUCTION: any;
interface ErrorStackTraceLimit {
stackTraceLimit: number;
}
interface ErrorConstructor extends ErrorStackTraceLimit {}

View File

@ -1,7 +1,7 @@
{
"name": "redoc",
"description": "Swagger-generated API Reference Documentation",
"version": "1.3.0",
"version": "1.3.1",
"repository": {
"type": "git",
"url": "git://github.com/Rebilly/ReDoc"
@ -40,6 +40,7 @@
"author": "Roman Hotsiy",
"license": "MIT",
"devDependencies": {
"@angular/compiler-cli": "^0.6.0",
"@types/core-js": "^0.9.31",
"@types/jasmine": "^2.2.32",
"@types/requirejs": "^2.1.26",
@ -57,8 +58,8 @@
"istanbul-instrumenter-loader": "^0.2.0",
"jasmine-core": "^2.4.1",
"jasmine-spec-reporter": "^2.4.0",
"karma": "^0.13.15",
"karma-chrome-launcher": "^1.0.1",
"karma": "^1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-coverage": "github:douglasduteil/karma-coverage#next",
"karma-coveralls": "^1.1.2",
"karma-jasmine": "^1.0.2",
@ -71,29 +72,27 @@
"karma-webpack": "^1.8.0",
"node-sass": "^3.8.0",
"phantomjs-prebuilt": "^2.1.7",
"protractor": "^3.3.0",
"protractor": "^4.0.4",
"raw-loader": "^0.5.1",
"shelljs": "^0.7.0",
"should": "^9.0.2",
"should": "^11.1.0",
"sinon": "^1.17.2",
"source-map-loader": "^0.1.5",
"style-loader": "^0.13.1",
"ts-helpers": "^1.1.1",
"tslint": "^3.15.0-dev.0",
"tslint-stylish": "^2.1.0-beta",
"typescript": "^2.0.0",
"typescript": "^2.0.2",
"webpack": "^2.1.0-beta.21",
"webpack-dev-server": "^1.15.0",
"yargs": "^4.7.1"
"webpack-dev-server": "^2.1.0-beta.2"
},
"dependencies": {
"@angular/common": "^2.0.0-rc.5",
"@angular/compiler": "^2.0.0-rc.5",
"@angular/compiler-cli": "^0.5.0",
"@angular/core": "^2.0.0-rc.5",
"@angular/platform-browser": "^2.0.0-rc.5",
"@angular/platform-browser-dynamic": "^2.0.0-rc.5",
"@angular/platform-server": "^2.0.0-rc.5",
"@angular/common": "^2.0.0-rc.6",
"@angular/compiler": "^2.0.0-rc.6",
"@angular/core": "^2.0.0-rc.6",
"@angular/platform-browser": "^2.0.0-rc.6",
"@angular/platform-browser-dynamic": "^2.0.0-rc.6",
"@angular/platform-server": "^2.0.0-rc.6",
"core-js": "^2.4.1",
"dropkickjs": "^2.1.10",
"hint.css": "^2.3.2",
@ -102,10 +101,10 @@
"openapi-sampler": "^0.3.0",
"prismjs": "^1.5.1",
"remarkable": "^1.6.2",
"rxjs": "5.0.0-beta.6",
"rxjs": "^5.0.0-beta.11",
"scrollparent": "^1.0.0",
"slugify": "^0.1.1",
"slugify": "^1.0.2",
"stream-http": "^2.3.1",
"zone.js": "^0.6.15"
"zone.js": "^0.6.17"
}
}

View File

@ -14,7 +14,6 @@
}
},
"host": "petstore.swagger.io",
"basePath": "/v2/",
"schemes": ["http"],
"paths": {
"/pet": {

View File

@ -1,30 +1,31 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"module": "es6",
"target": "es5",
"noImplicitAny": false,
"sourceMap": true,
"outDir": ".tmp/lib",
"pretty": true,
"moduleResolution": "node",
"types": [
"core-js",
"jasmine",
"should",
"requirejs"
],
"noEmitHelpers": true
},
"compileOnSave": false,
"exclude": [
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"module": "commonjs",
"target": "es5",
"noImplicitAny": false,
"sourceMap": true,
"outDir": ".tmp",
"pretty": true,
"moduleResolution": "node",
"types": [
"core-js",
"jasmine",
"should",
"requirejs"
],
"noEmitHelpers": true
},
"compileOnSave": false,
"exclude": [
"node_modules",
".tmp"
".tmp",
"dist"
],
"awesomeTypescriptLoaderOptions": {
"awesomeTypescriptLoaderOptions": {
"resolveGlobs": true,
"forkChecker": true
"forkChecker": true,
"useWebpackText": true
}
}