Merge commit 'ad52726b908feb34723ef57e5f6d514ac2af1358' into releases

This commit is contained in:
RedocBot 2016-06-30 13:55:35 +00:00 committed by travis@localhost
commit 5b75e699b9
10 changed files with 42 additions and 20 deletions

View File

@ -51,7 +51,9 @@ or using [npm](https://docs.npmjs.com/getting-started/what-is-npm):
npm install redoc --save
Alternatively you can just download [`redoc.min.js`](https://raw.githubusercontent.com/Rebilly/ReDoc/releases/dist/redoc.min.js).
Alternatively, you can **reference redoc directly** from CDN:
- latest release: https://rebilly.github.io/ReDoc/releases/latest/redoc.min.js
- particular release, e.g. v0.14.0: https://rebilly.github.io/ReDoc/releases/v0.14.0/redoc.min.js
#### 2. Reference redoc script in HTML
Then reference [`redoc.min.js`](https://raw.githubusercontent.com/Rebilly/ReDoc/releases/dist/redoc.min.js) in your HTML page:

View File

@ -17,8 +17,8 @@
<input id="schema-url-input" value='http://rebilly.github.io/SwaggerTemplateRepo/swagger.yaml'>
<button type="submit"> Explore </button>
</form>
<!--<iframe src="https://ghbtns.com/github-btn.html?user=Rebilly&repo=ReDoc&type=star&count=true&size=large"
frameborder="0" scrolling="0" width="130px" height="30px"></iframe>-->
<iframe src="https://ghbtns.com/github-btn.html?user=Rebilly&repo=ReDoc&type=star&count=true&size=large"
frameborder="0" scrolling="0" width="130px" height="30px"></iframe>
</nav>
<redoc scroll-y-offset="body > nav" spec-url='swagger.yaml'></redoc>

View File

@ -17,11 +17,11 @@
<span *ngFor="let enumItem of schema.enum" class="enum-value {{enumItem.type}}"> {{enumItem.val | json}} </span>
</div>
</span>
<table *ngIf="!schema.isTrivial" class="params-wrap" [ngClass]="{'params-array': schema._isArray}">
<table *ngIf="!schema.isTrivial" class="params-wrap" [ngClass]="{'params-array': _isArray}">
<!-- <caption> {{_displayType}} </caption> -->
<template ngFor [ngForOf]="schema._properties" let-prop="$implicit" let-last="last" [ngForTrackBy]="trackByName">
<template ngFor [ngForOf]="properties" let-prop="$implicit" let-last="last" [ngForTrackBy]="trackByIdx">
<tr class="param" [ngClass]="{'last': last,
'discriminator': prop.isDiscriminator,
'discriminator': prop.isDiscriminator && !activeDescendant.empty,
'complex': prop._pointer,
'additional': prop._additional,
'expanded': subSchema.visible
@ -59,16 +59,16 @@
<tr class="param-schema" [ngClass]="{'param-array': prop._isArray, 'last': last}" [hidden]="!prop._pointer">
<td colspan="2">
<zippy #subSchema title="test" [headless]="true" (open)="lazySchema.load()">
<json-schema-lazy #lazySchema class="nested-schema" pointer="{{prop._pointer}}" [isArray]='prop._isArray'
<json-schema-lazy #lazySchema class="nested-schema" [pointer]="prop._pointer" [isArray]='prop._isArray'
[nestOdd]="!nestOdd" [isRequestSchema]="isRequestSchema">
</json-schema-lazy>
</zippy>
</td>
</tr>
</template>
<tr *ngIf="hasDescendants" class="param-wrap discriminator-wrap">
<tr *ngIf="hasDescendants" class="param-wrap discriminator-wrap" [ngClass]="{empty:activeDescendant.empty}">
<td colspan="2">
<div class="derived-schema" *ngFor="let descendant of schema._descendants" [ngClass]="{active: descendant.active, empty: activeDescendant.empty}">
<div class="derived-schema" *ngFor="let descendant of schema._descendants" [ngClass]="{active: descendant.active, empty: descendant.empty}">
<json-schema class="discriminator-part" *ngIf="!descendant.empty" [childFor]="pointer"
pointer="{{descendant.$ref}}" [final]="descendant.final" [isRequestSchema]="isRequestSchema">
</json-schema>

View File

@ -20,6 +20,8 @@ export class JsonSchema extends BaseComponent {
activeDescendant:any = {};
hasDescendants: boolean = false;
_hasSubSchemas: boolean = false;
properties: any;
_isArray: boolean;
@Input() isArray: boolean;
@Input() final: boolean = false;
@Input() nestOdd: boolean;
@ -80,17 +82,27 @@ export class JsonSchema extends BaseComponent {
if (!this.schema.isTrivial) {
SchemaHelper.preprocessProperties(this.schema, this.normPointer, {
childFor: this.childFor,
skipReadOnly: this.isRequestSchema
childFor: this.childFor
});
}
this.properties = this.schema._properties;
this._isArray = this.isArray || this.schema._isArray;
if (this.isRequestSchema) {
this.properties = this.properties && this.properties.filter(prop => !prop.readOnly);
}
this.initDescendants();
this._hasSubSchemas = this.schema._properties && this.schema._properties.some(
propSchema => propSchema.type === 'object' && propSchema._pointer);
this._hasSubSchemas = this.properties && this.properties.some(
propSchema => {
if (propSchema.type === 'array') {
propSchema = propSchema.items;
}
return (propSchema && propSchema.type === 'object' && propSchema._pointer);
});
}
trackByName(index: number, item: any): string {
return item['name'];
trackByIdx(index: number, item: any): number {
return index;
}
}

View File

@ -4,7 +4,7 @@
<h1 class="sharable-header"> <a class="share-link" href="#tag/{{tag.name | encodeURIComponent}}"></a>{{tag.name}} </h1>
<p *ngIf="tag.description" [innerHtml]="tag.description | marked"> </p>
</div>
<method *ngFor="let method of tag.methods" [pointer]="method.pointer" [attr.pointer]="method.pointer"
<method *ngFor="let method of tag.methods;trackBy:trackByPointer" [pointer]="method.pointer" [attr.pointer]="method.pointer"
[attr.tag]="method.tag" [tag]="method.tag" [attr.operation-id]="method.operationId"></method>
</div>
</div>

View File

@ -42,4 +42,8 @@ export class MethodsList extends BaseComponent {
this.data.tags = tags;
// TODO: check $ref field
}
trackByPointer(idx, el) {
return el.pointer;
}
}

View File

@ -1,5 +1,5 @@
<h2 class="responses-list-header" *ngIf="data.responses.length"> Responses </h2>
<zippy *ngFor="let response of data.responses" title="{{response.code}} {{response.description}}"
<zippy *ngFor="let response of data.responses;trackBy:trackByCode" title="{{response.code}} {{response.description}}"
[type]="response.type" [empty]="response.empty" (open)="lazySchema.load()">
<div *ngIf="response.headers" class="response-headers">
<header>

View File

@ -49,7 +49,7 @@ export class ResponsesList extends BaseComponent {
resp.empty = !resp.schema;
resp.code = respCode;
resp.type = statusCodeType(resp.code);
if (resp.headers) {
if (resp.headers && !(resp.headers instanceof Array)) {
resp.headers = Object.keys(resp.headers).map((k) => {
let respInfo = resp.headers[k];
respInfo.name = k;
@ -62,4 +62,8 @@ export class ResponsesList extends BaseComponent {
});
this.data.responses = responses;
}
trackByCode(idx, el) {
return el.code;
}
}

View File

@ -4,7 +4,7 @@ import { SpecManager } from '../utils/SpecManager';
interface PropertyPreprocessOptions {
childFor: string;
skipReadOnly: boolean;
skipReadOnly?: boolean;
}
const injectors = {

View File

@ -1,7 +1,7 @@
{
"name": "redoc",
"description": "Swagger-generated API Reference Documentation",
"version": "0.15.0",
"version": "0.15.1",
"repository": {
"type": "git",
"url": "git://github.com/Rebilly/ReDoc"