mirror of
https://github.com/Redocly/redoc.git
synced 2025-04-15 14:21:59 +03:00
Merge commit '36a81ed662c59fcc15ff1ac6116f33eebf81fbbc' into releases
This commit is contained in:
commit
21ba30f2f8
27
CHANGELOG.md
27
CHANGELOG.md
|
@ -1,3 +1,30 @@
|
|||
<a name="1.11.0"></a>
|
||||
# 1.11.0 (2017-03-09)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* do not hang when swagger doesn't contain any paths ([e4f5388](https://github.com/Rebilly/ReDoc/commit/e4f5388)), closes [#216](https://github.com/Rebilly/ReDoc/issues/216)
|
||||
[#201](https://github.com/Rebilly/ReDoc/issues/201)
|
||||
* optimize and support inherited discriminator ([64e5741](https://github.com/Rebilly/ReDoc/commit/64e5741))
|
||||
* redoc hangs when indexing recursive discriminator-based definitions ([1e96f88](https://github.com/Rebilly/ReDoc/commit/1e96f88))
|
||||
* wrong warnings for $ref not single ([193f4bf](https://github.com/Rebilly/ReDoc/commit/193f4bf)), closes [#221](https://github.com/Rebilly/ReDoc/issues/221)
|
||||
* x-extendedDiscriminator not working ([4899f3e](https://github.com/Rebilly/ReDoc/commit/4899f3e)), closes [#217](https://github.com/Rebilly/ReDoc/issues/217)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* copy pretty-printed JSON ([e99d66d](https://github.com/Rebilly/ReDoc/commit/e99d66d)), closes [#219](https://github.com/Rebilly/ReDoc/issues/219)
|
||||
* support for OpenAPI object as a parameter for `init` ([d99f256](https://github.com/Rebilly/ReDoc/commit/d99f256)), closes [#224](https://github.com/Rebilly/ReDoc/issues/224)
|
||||
|
||||
<a name="1.10.2"></a>
|
||||
## 1.10.2 (2017-03-01)
|
||||
|
||||
### Bug Fixes
|
||||
* clear page fragment when scroll to the beginning
|
||||
* update docs for x-tagGroup, add warning [#215](https://github.com/Rebilly/ReDoc/issues/215)
|
||||
* show warning for non-used in tagGroup tags
|
||||
|
||||
<a name="1.10.1"></a>
|
||||
## 1.10.1 (2017-02-27)
|
||||
|
||||
|
|
|
@ -123,6 +123,7 @@ ReDoc makes use of the following [vendor extensions](http://swagger.io/specifica
|
|||
* [`x-logo`](docs/redoc-vendor-extensions.md#x-logo) - is used to specify API logo
|
||||
* [`x-traitTag`](docs/redoc-vendor-extensions.md#x-traitTag) - useful for handling out common things like Pagination, Rate-Limits, etc
|
||||
* [`x-code-samples`](docs/redoc-vendor-extensions.md#x-code-samples) - specify operation code samples
|
||||
* [`x-examples`](docs/redoc-vendor-extensions.md#x-examples) - specify JSON example for requests
|
||||
* [`x-nullable`](docs/redoc-vendor-extensions.md#nullable) - mark schema param as a nullable
|
||||
* [`x-displayName`](docs/redoc-vendor-extensions.md#x-displayname) - specify human-friendly names for the menu categories
|
||||
* [`x-tagGroups`](docs/redoc-vendor-extensions.md#x-tagGroups) - group tags by categories in the side menu
|
||||
|
|
|
@ -3,7 +3,6 @@ const webpack = require('webpack');
|
|||
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
|
||||
const StringReplacePlugin = require("string-replace-webpack-plugin");
|
||||
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
|
||||
const ngcWebpack = require('ngc-webpack');
|
||||
|
||||
const VERSION = JSON.stringify(require('../package.json').version);
|
||||
|
||||
|
@ -123,15 +122,15 @@ module.exports = function (options) {
|
|||
}
|
||||
};
|
||||
|
||||
if (options.AOT) {
|
||||
conf.plugins.push(
|
||||
new ngcWebpack.NgcWebpackPlugin({
|
||||
disable: !options.AOT,
|
||||
tsConfig: root('tsconfig.webpack.json'),
|
||||
resourceOverride: root('build/resource-override.js')
|
||||
})
|
||||
);
|
||||
}
|
||||
// if (options.AOT) {
|
||||
// conf.plugins.push(
|
||||
// new ngcWebpack.NgcWebpackPlugin({
|
||||
// disable: !options.AOT,
|
||||
// tsConfig: root('tsconfig.webpack.json'),
|
||||
// resourceOverride: root('build/resource-override.js')
|
||||
// })
|
||||
// );
|
||||
// }
|
||||
|
||||
return conf;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const webpack = require('webpack');
|
||||
|
||||
const root = require('./helpers').root;
|
||||
const path = require('path');
|
||||
|
||||
const webpackMerge = require('webpack-merge'); // used to merge webpack configs
|
||||
const commonConfig = require('./webpack.common.js');
|
||||
|
@ -57,6 +58,10 @@ module.exports = webpackMerge(commonConfig({
|
|||
/\.tmp[\\\/].*$/,
|
||||
/dist[\\\/].*$/,
|
||||
/(?:[^\\\/]*(?:[\\\/]|$))*[^\\\/]*\.css$/ // ignore css files
|
||||
])
|
||||
]),
|
||||
new webpack.ContextReplacementPlugin(
|
||||
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
|
||||
path.resolve(__dirname, '../src')
|
||||
)
|
||||
],
|
||||
})
|
||||
|
|
10
manual-types/index.d.ts → custom.d.ts
vendored
10
manual-types/index.d.ts → custom.d.ts
vendored
|
@ -1,13 +1,3 @@
|
|||
declare module "dropkickjs"
|
||||
declare module "json-schema-ref-parser"
|
||||
declare module "openapi-sampler"
|
||||
declare module "remarkable"
|
||||
declare module "scrollparent"
|
||||
declare module "slugify"
|
||||
declare module "url"
|
||||
declare module "json-pointer";
|
||||
declare module "mark.js";
|
||||
|
||||
declare module "*.css" {
|
||||
const content: string;
|
||||
export default content;
|
|
@ -169,6 +169,17 @@ lang: JavaScript
|
|||
source: console.log('Hello World');
|
||||
```
|
||||
|
||||
### Parameter Object vendor extensions
|
||||
Extends OpenAPI [Parameter Object](http://swagger.io/specification/#parameterObject)
|
||||
#### x-examples
|
||||
| Field Name | Type | Description |
|
||||
| :------------- | :------: | :---------- |
|
||||
| x-examples | [Example Object](http://swagger.io/specification/#exampleObject) | Object that contains examples for the request. Applies when `in` is `body` and mime-type is `application/json` |
|
||||
|
||||
###### Usage in ReDoc
|
||||
`x-examples` are rendered in the JSON tab on the right panel of ReDoc.
|
||||
|
||||
|
||||
### Schema Object vendor extensions
|
||||
Extends OpenAPI [Schema Object](http://swagger.io/specification/#schemaObject)
|
||||
#### x-nullable
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
import { RedocModule } from './redoc.module';
|
||||
import { Redoc } from './components/index';
|
||||
|
||||
@NgModule({
|
||||
imports: [ BrowserModule, RedocModule ],
|
||||
imports: [ BrowserModule, BrowserAnimationsModule, RedocModule ],
|
||||
bootstrap: [ Redoc ],
|
||||
exports: [ Redoc ]
|
||||
})
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<ng-container [ngSwitch]="schema._widgetType">
|
||||
<template ngSwitchCase="file">
|
||||
<ng-template ngSwitchCase="file">
|
||||
<span class="param-wrap">
|
||||
<span class="param-type-file">file</span>
|
||||
<div *ngIf="schema._produces && !isRequestSchema" class="file produces">
|
||||
|
@ -13,8 +13,8 @@
|
|||
</ul>
|
||||
</div>
|
||||
</span>
|
||||
</template>
|
||||
<template ngSwitchCase="trivial">
|
||||
</ng-template>
|
||||
<ng-template ngSwitchCase="trivial">
|
||||
<span class="param-wrap">
|
||||
<span class="param-type param-type-trivial {{schema.type}}"
|
||||
[ngClass]="{'with-hint': schema._displayTypeHint, 'array': _isArray}"
|
||||
|
@ -27,10 +27,10 @@
|
|||
</div>
|
||||
<span *ngIf="schema.pattern" class="param-pattern">{{schema.pattern}}</span>
|
||||
</span>
|
||||
</template>
|
||||
<template ngSwitchCase="tuple">
|
||||
</ng-template>
|
||||
<ng-template ngSwitchCase="tuple">
|
||||
<div class="params-wrap params-array array-tuple">
|
||||
<template ngFor [ngForOf]="schema.items" let-item="$implicit" let-idx="index" [ngForTrackBy]="trackByIdx">
|
||||
<ng-template ngFor [ngForOf]="schema.items" let-item="$implicit" let-idx="index" [ngForTrackBy]="trackByIdx">
|
||||
<div class="tuple-item">
|
||||
<span class="tuple-item-index"> [{{idx}}]: </span>
|
||||
<json-schema class="nested-schema" [pointer]="item._pointer"
|
||||
|
@ -38,17 +38,17 @@
|
|||
[nestOdd]="!nestOdd" [isRequestSchema]="isRequestSchema">
|
||||
</json-schema>
|
||||
</div>
|
||||
</template>
|
||||
</ng-template>
|
||||
</div>
|
||||
</template>
|
||||
<template ngSwitchCase="array">
|
||||
</ng-template>
|
||||
<ng-template ngSwitchCase="array">
|
||||
<json-schema class="nested-schema" [pointer]="schema._pointer"
|
||||
[nestOdd]="!nestOdd" [isRequestSchema]="isRequestSchema"> </json-schema>
|
||||
</template>
|
||||
<template ngSwitchCase="object">
|
||||
</ng-template>
|
||||
<ng-template ngSwitchCase="object">
|
||||
<table class="params-wrap" [ngClass]="{'params-array': _isArray}">
|
||||
<!-- <caption> {{_displayType}} </caption> -->
|
||||
<template ngFor [ngForOf]="properties" let-prop="$implicit" let-last="last" [ngForTrackBy]="trackByName">
|
||||
<ng-template ngFor [ngForOf]="properties" let-prop="$implicit" let-last="last" [ngForTrackBy]="trackByName">
|
||||
<tr class="param" [ngClass]="{'last': last,
|
||||
'discriminator': prop.isDiscriminator,
|
||||
'complex': prop._pointer,
|
||||
|
@ -100,8 +100,8 @@
|
|||
</zippy>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
</ng-template>
|
||||
</table>
|
||||
</template>
|
||||
</ng-template>
|
||||
|
||||
</ng-container>
|
||||
|
|
|
@ -14,9 +14,9 @@ interface MethodInfo {
|
|||
description: string;
|
||||
};
|
||||
bodyParam: any;
|
||||
summary: any;
|
||||
anchor: any;
|
||||
externalDocs: {
|
||||
summary: string;
|
||||
anchor: string;
|
||||
externalDocs?: {
|
||||
url: string;
|
||||
description?: string;
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ export class Method extends BaseComponent implements OnInit {
|
|||
};
|
||||
}
|
||||
|
||||
buildAnchor() {
|
||||
this.menu.hashFor(this.pointer,
|
||||
buildAnchor():string {
|
||||
return this.menu.hashFor(this.pointer,
|
||||
{ type: 'method', operationId: this.operationId, pointer: this.pointer },
|
||||
this.parentTagId );
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<h5 class="param-list-header" *ngIf="params.length"> Parameters </h5>
|
||||
<template ngFor [ngForOf]="params" let-paramType="$implicit">
|
||||
<ng-template ngFor [ngForOf]="params" let-paramType="$implicit">
|
||||
<header class="paramType">
|
||||
{{paramType.place}} Parameters
|
||||
<span class="hint--top-right hint--large" [attr.data-hint]="paramType.placeHint">?</span>
|
||||
|
@ -30,7 +30,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</ng-template>
|
||||
|
||||
<div *ngIf="bodyParam">
|
||||
<h5 class="param-list-header" *ngIf="bodyParam"> Request Body </h5>
|
||||
|
|
|
@ -210,6 +210,8 @@ footer {
|
|||
padding: 0.1em 0 0.2em 0;
|
||||
font-size: 1em;
|
||||
border-radius: $border-radius;
|
||||
color: $red;
|
||||
border: 1px solid rgba(38,50,56,0.1);
|
||||
|
||||
&:before, &:after {
|
||||
letter-spacing: -0.2em;
|
||||
|
|
|
@ -101,9 +101,9 @@ export class Redoc extends BaseComponent implements OnInit {
|
|||
if (!spec) {
|
||||
this.appState.startLoading();
|
||||
} else {
|
||||
this.specLoaded = true;
|
||||
this.changeDetector.markForCheck();
|
||||
this.changeDetector.detectChanges();
|
||||
this.specLoaded = true;
|
||||
setTimeout(() => {
|
||||
this.hash.start();
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import { Component, Input, OnInit, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { BaseComponent, SpecManager } from '../base';
|
||||
import JsonPointer from '../../utils/JsonPointer';
|
||||
import { statusCodeType } from '../../utils/helpers';
|
||||
import { statusCodeType, getJsonLike } from '../../utils/helpers';
|
||||
|
||||
|
||||
function isNumeric(n) {
|
||||
|
@ -11,7 +11,7 @@ function isNumeric(n) {
|
|||
}
|
||||
|
||||
function hasExample(response) {
|
||||
return ((response.examples && response.examples['application/json']) ||
|
||||
return ((response.examples && getJsonLike(response.examples)) ||
|
||||
response.schema);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
import { Component, ElementRef, Input, ChangeDetectionStrategy, OnInit } from '@angular/core';
|
||||
|
||||
import * as OpenAPISampler from 'openapi-sampler';
|
||||
|
||||
import JsonPointer from '../../utils/JsonPointer';
|
||||
import { BaseComponent, SpecManager } from '../base';
|
||||
import { SchemaNormalizer } from '../../services/schema-normalizer.service';
|
||||
import { getJsonLike } from '../../utils/helpers';
|
||||
|
||||
@Component({
|
||||
selector: 'schema-sample',
|
||||
|
@ -42,8 +43,16 @@ export class SchemaSample extends BaseComponent implements OnInit {
|
|||
this.pointer += '/schema';
|
||||
}
|
||||
|
||||
if (base.examples && base.examples['application/json']) {
|
||||
sample = base.examples['application/json'];
|
||||
// Support x-examples, allowing requests to specify an example.
|
||||
let examplePointer:string = JsonPointer.join(JsonPointer.dirName(this.pointer), 'x-examples');
|
||||
let requestExamples:any = this.specMgr.byPointer(examplePointer);
|
||||
if (requestExamples) {
|
||||
base.examples = requestExamples;
|
||||
}
|
||||
|
||||
let jsonLikeSample = base.examples && getJsonLike(base.examples);
|
||||
if (jsonLikeSample) {
|
||||
sample = jsonLikeSample;
|
||||
} else {
|
||||
let selectedDescendant;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="search-input-wrap">
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve">
|
||||
<path d="M968.2,849.4L667.3,549c83.9-136.5,66.7-317.4-51.7-435.6C477.1-25,252.5-25,113.9,113.4c-138.5,138.3-138.5,362.6,0,501C219.2,730.1,413.2,743,547.6,666.5l301.9,301.4c43.6,43.6,76.9,14.9,104.2-12.4C981,928.3,1011.8,893,968.2,849.4z M524.5,522c-88.9,88.7-233,88.7-321.8,0c-88.9-88.7-88.9-232.6,0-321.3c88.9-88.7,233-88.7,321.8,0C613.4,289.4,613.4,433.3,524.5,522z"/>
|
||||
</svg>
|
||||
<input #search (keyup)="update($event, search.value)" [value]="searchTerm" placeholder="Search">
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<th> {{def.details.in}} parameter name:</th>
|
||||
<td> {{def.details.name}} </td>
|
||||
</tr>
|
||||
<template [ngIf]="def.details.type === 'oauth2'">
|
||||
<ng-template [ngIf]="def.details.type === 'oauth2'">
|
||||
<tr>
|
||||
<th> OAuth2 Flow</th>
|
||||
<td> {{def.details.flow}} </td>
|
||||
|
@ -24,9 +24,9 @@
|
|||
<th> Token URL </th>
|
||||
<td> {{def.details.tokenUrl}} </td>
|
||||
</tr>
|
||||
</template>
|
||||
</ng-template>
|
||||
</table>
|
||||
<template [ngIf]="def.details.type === 'oauth2'">
|
||||
<ng-template [ngIf]="def.details.type === 'oauth2'">
|
||||
<h3> OAuth2 Scopes </h3>
|
||||
<table class="security-scopes-details">
|
||||
<tr *ngFor="let scopeName of def.details.scopes | keys">
|
||||
|
@ -34,5 +34,5 @@
|
|||
<td> {{def.details.scopes[scopeName]}} </td>
|
||||
</tr>
|
||||
</table>
|
||||
</template>
|
||||
</ng-template>
|
||||
</div>
|
||||
|
|
|
@ -15,7 +15,6 @@ if (AOT) {
|
|||
}
|
||||
|
||||
if (IS_PRODUCTION) {
|
||||
disableDebugTools();
|
||||
enableProdMode();
|
||||
}
|
||||
|
||||
|
@ -35,6 +34,7 @@ export function init(specUrlOrSpec:string|any, options:any = {}) {
|
|||
return bootstrapRedoc()
|
||||
.then(appRef => {
|
||||
moduleRef = appRef;
|
||||
if (IS_PRODUCTION) disableDebugTools();
|
||||
console.log('ReDoc initialized!');
|
||||
}).catch(err => {
|
||||
throw err;
|
||||
|
|
|
@ -19,6 +19,7 @@ import {
|
|||
Marker,
|
||||
SearchService,
|
||||
COMPONENT_PARSER_ALLOWED } from './services/';
|
||||
|
||||
import { SpecManager } from './utils/spec-manager';
|
||||
|
||||
@NgModule({
|
||||
|
|
|
@ -28,14 +28,15 @@ export class ContentProjector {
|
|||
|
||||
let parentCompRef = parentView.createComponent(componentFactory, null, contextInjector, [projectedNodes]);
|
||||
|
||||
// using private property to get AppElement instance
|
||||
let viewContainer = (<any>parentView)._element;
|
||||
viewContainer.nestedViews = viewContainer.nestedViews || [];
|
||||
// using private property to get view instance
|
||||
let viewContainer = (<any>parentView)._view;
|
||||
let viewData = (<any>parentView)._data;
|
||||
viewData.viewContainer._embeddedViews = viewData.viewContainer.embeddedViews || [];
|
||||
for (let i=0; i < componentRefs.length; i++) {
|
||||
let compRef = componentRefs[i];
|
||||
// attach view to viewContainer change detector
|
||||
viewContainer.nestedViews.push((<any>compRef.hostView).internalView);
|
||||
(<any>compRef.hostView).internalView.viewContainer = viewContainer;
|
||||
// attach view to containter change detector
|
||||
viewData.viewContainer._embeddedViews.push((<any>compRef.hostView)._view);
|
||||
(<any>compRef.hostView).attachToViewContainerRef(viewContainer);
|
||||
}
|
||||
return parentCompRef;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ interface Schema {
|
|||
additionalProperties: any;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class SchemaNormalizer {
|
||||
_dereferencer:SchemaDereferencer;
|
||||
constructor(_schema:any) {
|
||||
|
|
|
@ -4,7 +4,7 @@ import { AppStateService } from '../services/app-state.service';
|
|||
@Injectable()
|
||||
export class CustomErrorHandler extends ErrorHandler {
|
||||
constructor(private appState: AppStateService) {
|
||||
super(true);
|
||||
super();
|
||||
}
|
||||
handleError(error) {
|
||||
this.appState.error.next(error && error.rejection || error);
|
||||
|
|
|
@ -114,3 +114,17 @@ export function snapshot(obj) {
|
|||
|
||||
return temp;
|
||||
}
|
||||
|
||||
export function isJsonLike(contentType: string): boolean {
|
||||
return contentType.search(/json/i) !== -1;
|
||||
}
|
||||
|
||||
export function getJsonLike(object: object) {
|
||||
const jsonLikeKeys = Object.keys(object).filter(isJsonLike);
|
||||
|
||||
if (!jsonLikeKeys.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return object[jsonLikeKeys.shift()];
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ export interface MarkdownHeading {
|
|||
children?: StringMap<MarkdownHeading>;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class MdRenderer {
|
||||
public headings: StringMap<MarkdownHeading> = {};
|
||||
currentTopHeading: MarkdownHeading;
|
||||
|
|
|
@ -44,8 +44,8 @@ export class SpecManager {
|
|||
this._schema = snapshot(schema);
|
||||
try {
|
||||
this.init();
|
||||
resolve(this._schema);
|
||||
this.spec.next(this._schema);
|
||||
resolve(this._schema);
|
||||
} catch(err) {
|
||||
reject(err);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ export class SpecManager {
|
|||
// check if parent definition name is in the enum of possible values
|
||||
if (definition.discriminator) {
|
||||
let prop = definition.properties[definition.discriminator];
|
||||
if (prop.enum && prop.enum.indexOf(JsonPointer.baseName(defPointer)) > -1) {
|
||||
if (prop && prop.enum && prop.enum.indexOf(JsonPointer.baseName(defPointer)) > -1) {
|
||||
res.push({
|
||||
name: JsonPointer.baseName(defPointer),
|
||||
$ref: defPointer
|
||||
|
|
82
package.json
82
package.json
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "redoc",
|
||||
"description": "Swagger-generated API Reference Documentation",
|
||||
"version": "1.11.0",
|
||||
"version": "1.12.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/Rebilly/ReDoc"
|
||||
|
@ -18,13 +18,13 @@
|
|||
"unit": "karma start",
|
||||
"e2e": "npm run build:prod && npm run e2e-copy && npm run webdriver && protractor",
|
||||
"deploy": "node ./build/prepare_deploy.js && deploy-to-gh-pages --update demo",
|
||||
"ngc": "ngc -p .",
|
||||
"ngc": "ngc -p tsconfig.webpack.json",
|
||||
"clean:dist": "npm run rimraf -- dist/",
|
||||
"clean:aot": "npm run rimraf -- .tmp compiled lib/**/*.css",
|
||||
"rimraf": "rimraf",
|
||||
"webpack:prod": "webpack --config build/webpack.prod.js --profile --bail",
|
||||
"build:sass": "node-sass -q -o lib lib",
|
||||
"build:prod": "npm run clean:aot && npm run build:sass && npm run webpack:prod",
|
||||
"build:prod": "npm run clean:aot && npm run build:sass && npm run ngc && npm run webpack:prod",
|
||||
"build-dist": "npm run build:prod",
|
||||
"stats": "webpack --config build/webpack.prod.js --json > stats.json",
|
||||
"start": "webpack-dev-server --config build/webpack.dev.js --content-base demo",
|
||||
|
@ -48,29 +48,29 @@
|
|||
"author": "Roman Hotsiy",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@angular/common": "^2.4.8",
|
||||
"@angular/compiler": "^2.4.8",
|
||||
"@angular/compiler-cli": "^2.4.8",
|
||||
"@angular/core": "^2.4.8",
|
||||
"@angular/platform-browser": "^2.4.8",
|
||||
"@angular/platform-browser-dynamic": "^2.4.8",
|
||||
"@angular/platform-server": "^2.4.8",
|
||||
"@types/core-js": "^0.9.31",
|
||||
"@types/jasmine": "^2.5.43",
|
||||
"@angular/animations": "^4.0.0",
|
||||
"@angular/common": "^4.0.0",
|
||||
"@angular/compiler": "^4.0.0",
|
||||
"@angular/compiler-cli": "^4.0.0",
|
||||
"@angular/core": "^4.0.0",
|
||||
"@angular/platform-browser": "^4.0.0",
|
||||
"@angular/platform-browser-dynamic": "^4.0.0",
|
||||
"@angular/platform-server": "^4.0.0",
|
||||
"@types/jasmine": "^2.5.46",
|
||||
"@types/requirejs": "^2.1.26",
|
||||
"@types/should": "^8.1.28",
|
||||
"@types/swagger-schema-official": "^2.0.0",
|
||||
"@types/webpack": "^2.2.6",
|
||||
"@types/swagger-schema-official": "^2.0.2",
|
||||
"@types/webpack": "^2.2.12",
|
||||
"angular2-template-loader": "^0.6.2",
|
||||
"awesome-typescript-loader": "^3.0.6",
|
||||
"awesome-typescript-loader": "^3.1.2",
|
||||
"branch-release": "^1.0.3",
|
||||
"chalk": "^1.1.3",
|
||||
"codelyzer": "^2.0.1",
|
||||
"conventional-changelog-cli": "^1.2.0",
|
||||
"codelyzer": "^3.0.0-beta.4",
|
||||
"conventional-changelog-cli": "^1.3.1",
|
||||
"core-js": "^2.4.1",
|
||||
"coveralls": "^2.11.16",
|
||||
"css-loader": "^0.26.0",
|
||||
"deploy-to-gh-pages": "^1.1.2",
|
||||
"coveralls": "^2.12.0",
|
||||
"css-loader": "^0.27.3",
|
||||
"deploy-to-gh-pages": "^1.3.3",
|
||||
"dropkickjs": "^2.1.10",
|
||||
"hint.css": "^2.3.2",
|
||||
"http-server": "^0.9.0",
|
||||
|
@ -84,42 +84,42 @@
|
|||
"karma-coverage": "^1.1.1",
|
||||
"karma-coveralls": "^1.1.2",
|
||||
"karma-jasmine": "^1.0.2",
|
||||
"karma-mocha-reporter": "^2.0.0",
|
||||
"karma-phantomjs-launcher": "^1.0.0",
|
||||
"karma-mocha-reporter": "^2.2.3",
|
||||
"karma-phantomjs-launcher": "^1.0.4",
|
||||
"karma-phantomjs-shim": "^1.1.2",
|
||||
"karma-remap-coverage": "^0.1.4",
|
||||
"karma-should": "^1.0.0",
|
||||
"karma-sinon": "^1.0.4",
|
||||
"karma-sourcemap-loader": "^0.3.7",
|
||||
"karma-webpack": "^2.0.1",
|
||||
"karma-webpack": "^2.0.3",
|
||||
"lunr": "^1.0.0",
|
||||
"mark.js": "github:julmot/mark.js",
|
||||
"ngc-webpack": "^1.2.0",
|
||||
"node-sass": "^4.5.0",
|
||||
"openapi-sampler": "^0.4.0",
|
||||
"node-sass": "^4.5.2",
|
||||
"openapi-sampler": "^0.4.1",
|
||||
"phantomjs-prebuilt": "^2.1.7",
|
||||
"prismjs": "^1.5.1",
|
||||
"protractor": "^5.1.1",
|
||||
"raw-loader": "^0.5.1",
|
||||
"remarkable": "^1.6.2",
|
||||
"rimraf": "^2.6.0",
|
||||
"rimraf": "^2.6.1",
|
||||
"rxjs": "^5.2.0",
|
||||
"sass-loader": "^6.0.2",
|
||||
"sass-loader": "^6.0.3",
|
||||
"scrollparent": "^1.0.0",
|
||||
"shelljs": "^0.7.0",
|
||||
"should": "^11.1.0",
|
||||
"sinon": "^1.17.2",
|
||||
"shelljs": "^0.7.7",
|
||||
"should": "^11.2.1",
|
||||
"sinon": "^2.1.0",
|
||||
"slugify": "^1.0.2",
|
||||
"source-map-loader": "^0.1.5",
|
||||
"source-map-loader": "^0.2.0",
|
||||
"stream-http": "^2.6.1",
|
||||
"string-replace-webpack-plugin": "0.0.5",
|
||||
"style-loader": "^0.13.1",
|
||||
"string-replace-webpack-plugin": "^0.1.3",
|
||||
"style-loader": "^0.16.1",
|
||||
"ts-helpers": "^1.1.1",
|
||||
"tslint": "^4.3.1",
|
||||
"typescript": "^2.1.5",
|
||||
"webpack": "^2.2.1",
|
||||
"webpack-dev-server": "^2.4.1",
|
||||
"webpack-merge": "^3.0.0",
|
||||
"zone.js": "^0.7.7"
|
||||
}
|
||||
"tslint": "^4.5.1",
|
||||
"typescript": "^2.2.2",
|
||||
"webpack": "^2.3.2",
|
||||
"webpack-dev-server": "^2.4.2",
|
||||
"webpack-merge": "^4.1.0",
|
||||
"zone.js": "^0.8.5"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { getDOM } from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
|
||||
/** Gets a child DebugElement by tag name. */
|
||||
export function getChildDebugElement(parent, tagName) {
|
||||
|
@ -20,7 +19,13 @@ export function getChildDebugElementAll(parent, tagName) {
|
|||
|
||||
export function mouseclick( element ) {
|
||||
// create a mouse click event
|
||||
var dispatchedEvent = getDOM().createMouseEvent('click');
|
||||
var dispatchedEvent
|
||||
try {
|
||||
dispatchedEvent = new MouseEvent('click', true);
|
||||
} catch (e) {
|
||||
dispatchedEvent = document.createEvent('MouseEvent');
|
||||
dispatchedEvent.initEvent('click', true, false);
|
||||
}
|
||||
// send click to element
|
||||
getDOM().dispatchEvent(element, dispatchedEvent);
|
||||
element.dispatchEvent(dispatchedEvent);
|
||||
}
|
||||
|
|
|
@ -20,9 +20,10 @@ require('../lib/vendor');
|
|||
|
||||
var TestBed = require('@angular/core/testing').TestBed;
|
||||
var ErrorHandler = require('@angular/core').ErrorHandler;
|
||||
var forwardRef = require('@angular/core').forwardRef;
|
||||
var BrowserDynamicTestingModule = require('@angular/platform-browser-dynamic/testing').BrowserDynamicTestingModule;
|
||||
var platformBrowserDynamicTesting = require('@angular/platform-browser-dynamic/testing').platformBrowserDynamicTesting;
|
||||
|
||||
var BrowserAnimationsModule = require('@angular/platform-browser/animations').BrowserAnimationsModule;
|
||||
var SpecManager = require('../lib/utils/spec-manager').SpecManager;
|
||||
var services = require('../lib/services/index');
|
||||
var REDOC_PIPES = require('../lib/utils/pipes').REDOC_PIPES;
|
||||
|
@ -38,6 +39,7 @@ TestBed.initTestEnvironment(
|
|||
|
||||
beforeEach(function() {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [BrowserAnimationsModule],
|
||||
providers: [
|
||||
SpecManager,
|
||||
services.AppStateService,
|
||||
|
@ -51,7 +53,7 @@ beforeEach(function() {
|
|||
services.Marker,
|
||||
services.SearchService,
|
||||
{ provide: sharedComponents.LazyTasksService, useClass: sharedComponents.LazyTasksServiceSync },
|
||||
{ provide: ErrorHandler, useClass: services.CustomErrorHandler },
|
||||
//{ provide: ErrorHandler, useClass: forwardRef(function() {return services.CustomErrorHandler}) },
|
||||
{ provide: services.COMPONENT_PARSER_ALLOWED, useValue: { 'security-definitions': components.SecurityDefinitions }}
|
||||
],
|
||||
declarations: [REDOC_PIPES, REDOC_DIRECTIVES, REDOC_COMMON_DIRECTIVES]
|
||||
|
|
|
@ -15,14 +15,6 @@ describe('Utils', () => {
|
|||
specMgr.load('/tests/schemas/extended-petstore.yml').should.be.instanceof(Promise);
|
||||
});
|
||||
|
||||
it('load should reject promise for invalid url', (done)=> {
|
||||
specMgr.load('/nonexisting/schema.json').then(() => {
|
||||
throw new Error('Success handler should not be called');
|
||||
}, () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('load should resolve promise for valid url', (done)=> {
|
||||
specMgr.load('/tests/schemas/extended-petstore.yml').then(() => {
|
||||
done();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
import {statusCodeType} from '../../lib/utils/helpers';
|
||||
import {statusCodeType, isJsonLike, getJsonLike } from '../../lib/utils/helpers';
|
||||
|
||||
describe('Utils', () => {
|
||||
describe('statusCodeType', () => {
|
||||
it('Should return info for status codes within 100 and 200', ()=> {
|
||||
|
@ -30,4 +31,34 @@ describe('Utils', () => {
|
|||
(() => statusCodeType(600)).should.throw('invalid HTTP code');
|
||||
});
|
||||
});
|
||||
|
||||
describe('isJsonLike', () => {
|
||||
it('Should return true for a string that contains `json`', () => {
|
||||
isJsonLike('application/json').should.be.equal(true);
|
||||
});
|
||||
it('Should return false for a string that does not contain `json`', () => {
|
||||
isJsonLike('application/xml').should.be.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getJsonLike', () => {
|
||||
it('Should return a value when a JSON-like key exists', () => {
|
||||
const examples = {
|
||||
"application/vnd.api+json": {
|
||||
"message": "Hello World"
|
||||
},
|
||||
"application/xml": "<message>Hello World</message>"
|
||||
};
|
||||
|
||||
(getJsonLike(examples).message).should.be.equal("Hello World");
|
||||
});
|
||||
|
||||
it('Should return undefined when no JSON-like key exists', () => {
|
||||
const examples = {
|
||||
"application/xml": "<message>Hello World</message>"
|
||||
};
|
||||
|
||||
getJsonLike(examples).should.be.equal(false);
|
||||
});
|
||||
})
|
||||
});
|
||||
|
|
|
@ -9,10 +9,12 @@
|
|||
"pretty": true,
|
||||
"moduleResolution": "node",
|
||||
"types": [
|
||||
"core-js",
|
||||
"jasmine",
|
||||
"should",
|
||||
"requirejs"
|
||||
"webpack"
|
||||
],
|
||||
"lib": [
|
||||
"DOM", "ES2016", "DOM.Iterable"
|
||||
],
|
||||
"noEmitHelpers": true
|
||||
},
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
{
|
||||
"linterOptions": {
|
||||
"typeCheck": true
|
||||
},
|
||||
"rulesDirectory": ["node_modules/codelyzer"],
|
||||
"rules": {
|
||||
"class-name": true,
|
||||
|
@ -42,7 +45,6 @@
|
|||
"no-input-rename": true,
|
||||
"no-output-rename": true,
|
||||
"pipe-naming": [true, "camelCase"],
|
||||
"import-destructuring-spacing": true,
|
||||
"use-life-cycle-interface": true,
|
||||
"use-pipe-transform-interface": true,
|
||||
"templates-use-public": true,
|
||||
|
|
Loading…
Reference in New Issue
Block a user