Merge commit '0ad7f4fdc9c40e9bd8008ac7861033421271e09a' into releases

This commit is contained in:
RedocBot 2016-11-28 18:25:00 +00:00 committed by travis@localhost
commit c9807fc889
13 changed files with 92 additions and 33 deletions

View File

@ -3,6 +3,8 @@
[![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) [![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) [![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) [![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)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/Rebilly/redoc.svg)](http://isitmaintained.com/project/Rebilly/redoc "Average time to resolve an issue") [![Percentage of issues still open](http://isitmaintained.com/badge/open/REBILLY/REDOC.svg)](http://isitmaintained.com/project/REBILLY/REDOC "Percentage of issues still open")
[![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) [![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)
[![Browser Compatibility](https://saucelabs.com/browser-matrix/redoc.svg)](https://saucelabs.com/u/redoc) [![Browser Compatibility](https://saucelabs.com/browser-matrix/redoc.svg)](https://saucelabs.com/u/redoc)

View File

@ -1,5 +1,5 @@
<div class="api-info-wrapper"> <div class="api-info-wrapper">
<h1>{{info.title}} ({{info.version}})</h1> <h1>{{info.title}} <span class="api-info-version">({{info.version}})</span></h1>
<p> <p>
Download OpenAPI (fka Swagger) specification: Download OpenAPI (fka Swagger) specification:
<a class="openapi-button" target="_blank" attr.href='{{specUrl}}'> Download </a> <a class="openapi-button" target="_blank" attr.href='{{specUrl}}'> Download </a>

View File

@ -60,23 +60,27 @@ $sub-schema-offset: ($bullet-size / 2) + $bullet-margin;
font-weight: bold; font-weight: bold;
} }
.param-type { .param-type, .param-array-format {
vertical-align: middle; vertical-align: middle;
line-height: $param-name-height; line-height: $param-name-height;
color: rgba($black, 0.4); color: rgba($black, 0.4);
font-size: 0.929em; font-size: 0.929em;
}
.param-type {
font-weight: normal; font-weight: normal;
&.array::before, &.tuple::before {
color: $black;
font-weight: $base-font-weight;
.param-collection-format-multi + & {
content: none;
}
}
&.array::before { &.array::before {
content: $array-text; content: $array-text;
color: $black;
font-weight: $base-font-weight;
} }
&.tuple::before { &.tuple::before {
content: $tuple-text; content: $tuple-text;
color: $black;
font-weight: $base-font-weight;
} }
&.with-hint { &.with-hint {
@ -193,6 +197,19 @@ $sub-schema-offset: ($bullet-size / 2) + $bullet-margin;
} }
} }
.param-enum {
color: $text-color;
font-size: 0.95em;
&::before {
content: 'Valid values: ';
}
.param-type.array ~ &::before {
content: 'Valid items values: ';
}
}
.param-pattern { .param-pattern {
color: $nullable-color; color: $nullable-color;
white-space: nowrap; white-space: nowrap;

View File

@ -17,7 +17,7 @@
<template ngSwitchCase="trivial"> <template ngSwitchCase="trivial">
<span class="param-wrap"> <span class="param-wrap">
<span class="param-type param-type-trivial {{schema.type}}" <span class="param-type param-type-trivial {{schema.type}}"
[ngClass]="{'with-hint': schema._displayTypeHint}" [ngClass]="{'with-hint': schema._displayTypeHint, 'array': _isArray}"
title="{{schema._displayTypeHint}}">{{schema._displayType}} {{schema._displayFormat}} title="{{schema._displayTypeHint}}">{{schema._displayType}} {{schema._displayFormat}}
<span class="param-range" *ngIf="schema._range"> {{schema._range}} </span> <span class="param-range" *ngIf="schema._range"> {{schema._range}} </span>
</span> </span>
@ -45,7 +45,7 @@
[nestOdd]="!nestOdd" [isRequestSchema]="isRequestSchema"> </json-schema> [nestOdd]="!nestOdd" [isRequestSchema]="isRequestSchema"> </json-schema>
</template> </template>
<template ngSwitchCase="object"> <template ngSwitchCase="object">
<table class="params-wrap" [ngClass]="{'params-array': schema._isArray}"> <table class="params-wrap" [ngClass]="{'params-array': _isArray}">
<!-- <caption> {{_displayType}} </caption> --> <!-- <caption> {{_displayType}} </caption> -->
<template ngFor [ngForOf]="properties" let-prop="$implicit" let-last="last" [ngForTrackBy]="trackByName"> <template ngFor [ngForOf]="properties" let-prop="$implicit" let-last="last" [ngForTrackBy]="trackByName">
<tr class="param" [ngClass]="{'last': last, <tr class="param" [ngClass]="{'last': last,

View File

@ -84,6 +84,7 @@ export class JsonSchema extends BaseComponent implements OnInit {
this.schema = this.normalizer.normalize(this.schema, this.normPointer, {resolved: true}); this.schema = this.normalizer.normalize(this.schema, this.normPointer, {resolved: true});
this.schema = SchemaHelper.unwrapArray(this.schema, this.normPointer); this.schema = SchemaHelper.unwrapArray(this.schema, this.normPointer);
this._isArray = this.schema._isArray;
this.initDescendants(); this.initDescendants();
this.preprocessSchema(); this.preprocessSchema();
} }

View File

@ -12,6 +12,9 @@
</div> </div>
<div class="param-info"> <div class="param-info">
<div> <div>
<span *ngIf='param.type === "array"' class="param-array-format param-collection-format-{{param.collectionFormat}}">
{{param | collectionFormat}}
</span>
<span class="param-type {{param.type}}" [ngClass]="{'with-hint': param._displayTypeHint}" <span class="param-type {{param.type}}" [ngClass]="{'with-hint': param._displayTypeHint}"
title="{{param._displayTypeHint}}"> {{param._displayType}} {{param._displayFormat}}</span> title="{{param._displayTypeHint}}"> {{param._displayType}} {{param._displayFormat}}</span>
<span class="param-range" *ngIf="param._range"> {{param._range}} </span> <span class="param-range" *ngIf="param._range"> {{param._range}} </span>

View File

@ -18,6 +18,11 @@ header.paramType {
text-transform: capitalize; text-transform: capitalize;
} }
.param-array-format {
color: black;
font-weight: 300;
}
// paramters can't be multilevel so table representation works for it without javascript // paramters can't be multilevel so table representation works for it without javascript
.params-wrap { .params-wrap {
display: table; display: table;

View File

@ -35,10 +35,11 @@ export class SchemaSample extends BaseComponent implements OnInit {
let base:any = {}; let base:any = {};
let sample; let sample;
// got pointer not directly to the schema but e.g. to response obj // got pointer not directly to the schema but e.g. to the response obj
if (this.componentSchema.schema) { if (this.componentSchema.schema) {
base = this.componentSchema; base = this.componentSchema;
this.componentSchema = this.componentSchema.schema; this.componentSchema = this.componentSchema.schema;
this.pointer += '/schema';
} }
if (base.examples && base.examples['application/json']) { if (base.examples && base.examples['application/json']) {
@ -48,7 +49,7 @@ export class SchemaSample extends BaseComponent implements OnInit {
this.componentSchema = this._normalizer.normalize(this.componentSchema, this.pointer); this.componentSchema = this._normalizer.normalize(this.componentSchema, this.pointer);
let discriminator = this.componentSchema.discriminator || this.componentSchema['x-extendedDiscriminator']; let discriminator = this.componentSchema.discriminator || this.componentSchema['x-discriminatorBasePointer'];
if (discriminator) { if (discriminator) {
let descendants = this.specMgr.findDerivedDefinitions(this.componentSchema._pointer || this.pointer); let descendants = this.specMgr.findDerivedDefinitions(this.componentSchema._pointer || this.pointer);
if (descendants.length) { if (descendants.length) {

View File

@ -114,6 +114,7 @@ const injectors = {
injectTo._displayTypeHint = 'This field may contain data of any type'; injectTo._displayTypeHint = 'This field may contain data of any type';
injectTo.isTrivial = true; injectTo.isTrivial = true;
injectTo._widgetType = 'trivial'; injectTo._widgetType = 'trivial';
injectTo._pointer = undefined;
} }
}, },
simpleType: { simpleType: {
@ -262,8 +263,9 @@ export class SchemaHelper {
static unwrapArray(schema, pointer) { static unwrapArray(schema, pointer) {
var res = schema; var res = schema;
if (schema && schema.type === 'array' && !Array.isArray(schema.items)) { if (schema && schema.type === 'array' && !Array.isArray(schema.items)) {
let ptr = schema.items._pointer || JsonPointer.join(pointer, ['items']); let items = schema.items = schema.items || {};
res = schema.items; let ptr = items._pointer || JsonPointer.join(pointer, ['items']);
res = Object.assign({}, items);
res._isArray = true; res._isArray = true;
res._pointer = ptr; res._pointer = ptr;
res = SchemaHelper.unwrapArray(res, ptr); res = SchemaHelper.unwrapArray(res, ptr);

View File

@ -116,6 +116,25 @@ export class EncodeURIComponentPipe implements PipeTransform {
} }
} }
const COLLECTION_FORMATS = {
csv: 'Comma Separated',
ssv: 'Space Separated',
tsv: 'Tab Separated',
pipes: 'Pipe Separated'
};
@Pipe({ name: 'collectionFormat' })
export class CollectionFormatPipe implements PipeTransform {
transform(param:any) {
let format = param.collectionFormat;
if (!format) format = 'csv';
if (format === 'multi') {
return 'Multiple ' + param.in + ' params of';
}
return COLLECTION_FORMATS[format];
}
}
export const REDOC_PIPES = [ export const REDOC_PIPES = [
JsonPointerEscapePipe, MarkedPipe, SafePipe, PrismPipe, EncodeURIComponentPipe, JsonFormatter, KeysPipe JsonPointerEscapePipe, MarkedPipe, SafePipe, PrismPipe, EncodeURIComponentPipe, JsonFormatter, KeysPipe, CollectionFormatPipe
]; ];

View File

@ -15,6 +15,7 @@ export class SpecManager {
public spec = new BehaviorSubject<any|null>(null); public spec = new BehaviorSubject<any|null>(null);
private _instance: any; private _instance: any;
private _url: string; private _url: string;
private parser: any;
static instance() { static instance() {
return new SpecManager(); return new SpecManager();
@ -31,7 +32,8 @@ export class SpecManager {
load(urlOrObject: string|Object) { load(urlOrObject: string|Object) {
this.schema = null; this.schema = null;
let promise = new Promise((resolve, reject) => { let promise = new Promise((resolve, reject) => {
JsonSchemaRefParser.bundle(urlOrObject, {http: {withCredentials: false}}) this.parser = new JsonSchemaRefParser();
this.parser.bundle(urlOrObject, {http: {withCredentials: false}})
.then(schema => { .then(schema => {
if (typeof urlOrObject === 'string') { if (typeof urlOrObject === 'string') {
this._url = urlOrObject; this._url = urlOrObject;
@ -97,9 +99,16 @@ export class SpecManager {
byPointer(pointer) { byPointer(pointer) {
let res = null; let res = null;
if (pointer == undefined) return null;
try { try {
res = JsonPointer.get(this._schema, decodeURIComponent(pointer)); res = JsonPointer.get(this._schema, decodeURIComponent(pointer));
} catch(e) {/*skip*/ } } catch(e) {
// if resolved from outer files simple jsonpointer.get fails to get correct schema
if (pointer.charAt(0) !== '#') pointer = '#' + pointer;
try {
res = this.parser.$refs.get(decodeURIComponent(pointer));
} catch(e) { /* skip */ }
}
return res; return res;
} }

View File

@ -1,7 +1,7 @@
{ {
"name": "redoc", "name": "redoc",
"description": "Swagger-generated API Reference Documentation", "description": "Swagger-generated API Reference Documentation",
"version": "1.5.1", "version": "1.5.2",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/Rebilly/ReDoc" "url": "git://github.com/Rebilly/ReDoc"
@ -45,13 +45,13 @@
"author": "Roman Hotsiy", "author": "Roman Hotsiy",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"@angular/common": "^2.1.2", "@angular/common": "~2.1.2",
"@angular/compiler": "^2.1.2", "@angular/compiler": "~2.1.2",
"@angular/compiler-cli": "^2.1.2", "@angular/compiler-cli": "~2.1.2",
"@angular/core": "^2.1.2", "@angular/core": "~2.1.2",
"@angular/platform-browser": "^2.1.2", "@angular/platform-browser": "~2.1.2",
"@angular/platform-browser-dynamic": "^2.1.2", "@angular/platform-browser-dynamic": "~2.1.2",
"@angular/platform-server": "^2.1.2", "@angular/platform-server": "~2.1.2",
"@types/core-js": "^0.9.31", "@types/core-js": "^0.9.31",
"@types/jasmine": "^2.2.32", "@types/jasmine": "^2.2.32",
"@types/requirejs": "^2.1.26", "@types/requirejs": "^2.1.26",
@ -81,7 +81,7 @@
"karma-sinon": "^1.0.4", "karma-sinon": "^1.0.4",
"karma-sourcemap-loader": "^0.3.7", "karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.8.0", "karma-webpack": "^1.8.0",
"node-sass": "^3.10.1", "node-sass": "^3.11.2",
"phantomjs-prebuilt": "^2.1.7", "phantomjs-prebuilt": "^2.1.7",
"protractor": "^4.0.10", "protractor": "^4.0.10",
"raw-loader": "^0.5.1", "raw-loader": "^0.5.1",
@ -105,7 +105,7 @@
"hint.css": "^2.3.2", "hint.css": "^2.3.2",
"json-pointer": "^0.6.0", "json-pointer": "^0.6.0",
"json-schema-ref-parser": "^3.1.2", "json-schema-ref-parser": "^3.1.2",
"openapi-sampler": "^0.3.2", "openapi-sampler": "^0.3.3",
"prismjs": "^1.5.1", "prismjs": "^1.5.1",
"remarkable": "^1.6.2", "remarkable": "^1.6.2",
"scrollparent": "^1.0.0", "scrollparent": "^1.0.0",
@ -113,12 +113,12 @@
"stream-http": "^2.3.1" "stream-http": "^2.3.1"
}, },
"peerDependencies": { "peerDependencies": {
"@angular/common": "^2.1.2", "@angular/common": "~2.1.2",
"@angular/compiler": "^2.1.2", "@angular/compiler": "~2.1.2",
"@angular/core": "^2.1.2", "@angular/core": "~2.1.2",
"@angular/platform-browser": "^2.1.2", "@angular/platform-browser": "~2.1.2",
"@angular/platform-browser-dynamic": "^2.1.2", "@angular/platform-browser-dynamic": "~2.1.2",
"@angular/platform-server": "^2.1.2", "@angular/platform-server": "~2.1.2",
"core-js": "^2.4.1", "core-js": "^2.4.1",
"rxjs": "5.0.0-beta.12", "rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.25" "zone.js": "^0.6.25"