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)
[![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)
[![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">
<h1>{{info.title}} ({{info.version}})</h1>
<h1>{{info.title}} <span class="api-info-version">({{info.version}})</span></h1>
<p>
Download OpenAPI (fka Swagger) specification:
<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;
}
.param-type {
.param-type, .param-array-format {
vertical-align: middle;
line-height: $param-name-height;
color: rgba($black, 0.4);
font-size: 0.929em;
}
.param-type {
font-weight: normal;
&.array::before, &.tuple::before {
color: $black;
font-weight: $base-font-weight;
.param-collection-format-multi + & {
content: none;
}
}
&.array::before {
content: $array-text;
color: $black;
font-weight: $base-font-weight;
}
&.tuple::before {
content: $tuple-text;
color: $black;
font-weight: $base-font-weight;
}
&.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 {
color: $nullable-color;
white-space: nowrap;

View File

@ -17,7 +17,7 @@
<template ngSwitchCase="trivial">
<span class="param-wrap">
<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}}
<span class="param-range" *ngIf="schema._range"> {{schema._range}} </span>
</span>
@ -45,7 +45,7 @@
[nestOdd]="!nestOdd" [isRequestSchema]="isRequestSchema"> </json-schema>
</template>
<template ngSwitchCase="object">
<table class="params-wrap" [ngClass]="{'params-array': schema._isArray}">
<table class="params-wrap" [ngClass]="{'params-array': _isArray}">
<!-- <caption> {{_displayType}} </caption> -->
<template ngFor [ngForOf]="properties" let-prop="$implicit" let-last="last" [ngForTrackBy]="trackByName">
<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 = SchemaHelper.unwrapArray(this.schema, this.normPointer);
this._isArray = this.schema._isArray;
this.initDescendants();
this.preprocessSchema();
}

View File

@ -12,6 +12,9 @@
</div>
<div class="param-info">
<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}"
title="{{param._displayTypeHint}}"> {{param._displayType}} {{param._displayFormat}}</span>
<span class="param-range" *ngIf="param._range"> {{param._range}} </span>

View File

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

View File

@ -35,10 +35,11 @@ export class SchemaSample extends BaseComponent implements OnInit {
let base:any = {};
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) {
base = this.componentSchema;
this.componentSchema = this.componentSchema.schema;
this.pointer += '/schema';
}
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);
let discriminator = this.componentSchema.discriminator || this.componentSchema['x-extendedDiscriminator'];
let discriminator = this.componentSchema.discriminator || this.componentSchema['x-discriminatorBasePointer'];
if (discriminator) {
let descendants = this.specMgr.findDerivedDefinitions(this.componentSchema._pointer || this.pointer);
if (descendants.length) {

View File

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

View File

@ -28,7 +28,7 @@ export class SchemaNormalizer {
if (opts.resolved && !hasPtr) this._dereferencer.visit(ptr);
if (schema['x-redoc-normalized']) return schema;
let res = SchemaWalker.walk(schema, ptr, (subSchema, ptr) => {
let res = SchemaWalker.walk(schema, ptr, (subSchema, ptr) => {
let resolved = this._dereferencer.dereference(subSchema, ptr);
if (resolved.allOf) {
resolved._pointer = resolved._pointer || 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 = [
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);
private _instance: any;
private _url: string;
private parser: any;
static instance() {
return new SpecManager();
@ -31,7 +32,8 @@ export class SpecManager {
load(urlOrObject: string|Object) {
this.schema = null;
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 => {
if (typeof urlOrObject === 'string') {
this._url = urlOrObject;
@ -97,9 +99,16 @@ export class SpecManager {
byPointer(pointer) {
let res = null;
if (pointer == undefined) return null;
try {
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;
}

View File

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