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 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 #### 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: 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'> <input id="schema-url-input" value='http://rebilly.github.io/SwaggerTemplateRepo/swagger.yaml'>
<button type="submit"> Explore </button> <button type="submit"> Explore </button>
</form> </form>
<!--<iframe src="https://ghbtns.com/github-btn.html?user=Rebilly&repo=ReDoc&type=star&count=true&size=large" <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>--> frameborder="0" scrolling="0" width="130px" height="30px"></iframe>
</nav> </nav>
<redoc scroll-y-offset="body > nav" spec-url='swagger.yaml'></redoc> <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> <span *ngFor="let enumItem of schema.enum" class="enum-value {{enumItem.type}}"> {{enumItem.val | json}} </span>
</div> </div>
</span> </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> --> <!-- <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, <tr class="param" [ngClass]="{'last': last,
'discriminator': prop.isDiscriminator, 'discriminator': prop.isDiscriminator && !activeDescendant.empty,
'complex': prop._pointer, 'complex': prop._pointer,
'additional': prop._additional, 'additional': prop._additional,
'expanded': subSchema.visible 'expanded': subSchema.visible
@ -59,16 +59,16 @@
<tr class="param-schema" [ngClass]="{'param-array': prop._isArray, 'last': last}" [hidden]="!prop._pointer"> <tr class="param-schema" [ngClass]="{'param-array': prop._isArray, 'last': last}" [hidden]="!prop._pointer">
<td colspan="2"> <td colspan="2">
<zippy #subSchema title="test" [headless]="true" (open)="lazySchema.load()"> <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"> [nestOdd]="!nestOdd" [isRequestSchema]="isRequestSchema">
</json-schema-lazy> </json-schema-lazy>
</zippy> </zippy>
</td> </td>
</tr> </tr>
</template> </template>
<tr *ngIf="hasDescendants" class="param-wrap discriminator-wrap"> <tr *ngIf="hasDescendants" class="param-wrap discriminator-wrap" [ngClass]="{empty:activeDescendant.empty}">
<td colspan="2"> <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" <json-schema class="discriminator-part" *ngIf="!descendant.empty" [childFor]="pointer"
pointer="{{descendant.$ref}}" [final]="descendant.final" [isRequestSchema]="isRequestSchema"> pointer="{{descendant.$ref}}" [final]="descendant.final" [isRequestSchema]="isRequestSchema">
</json-schema> </json-schema>

View File

@ -20,6 +20,8 @@ export class JsonSchema extends BaseComponent {
activeDescendant:any = {}; activeDescendant:any = {};
hasDescendants: boolean = false; hasDescendants: boolean = false;
_hasSubSchemas: boolean = false; _hasSubSchemas: boolean = false;
properties: any;
_isArray: boolean;
@Input() isArray: boolean; @Input() isArray: boolean;
@Input() final: boolean = false; @Input() final: boolean = false;
@Input() nestOdd: boolean; @Input() nestOdd: boolean;
@ -80,17 +82,27 @@ export class JsonSchema extends BaseComponent {
if (!this.schema.isTrivial) { if (!this.schema.isTrivial) {
SchemaHelper.preprocessProperties(this.schema, this.normPointer, { SchemaHelper.preprocessProperties(this.schema, this.normPointer, {
childFor: this.childFor, childFor: this.childFor
skipReadOnly: this.isRequestSchema
}); });
} }
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.initDescendants();
this._hasSubSchemas = this.schema._properties && this.schema._properties.some( this._hasSubSchemas = this.properties && this.properties.some(
propSchema => propSchema.type === 'object' && propSchema._pointer); propSchema => {
if (propSchema.type === 'array') {
propSchema = propSchema.items;
}
return (propSchema && propSchema.type === 'object' && propSchema._pointer);
});
} }
trackByName(index: number, item: any): string { trackByIdx(index: number, item: any): number {
return item['name']; 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> <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> <p *ngIf="tag.description" [innerHtml]="tag.description | marked"> </p>
</div> </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> [attr.tag]="method.tag" [tag]="method.tag" [attr.operation-id]="method.operationId"></method>
</div> </div>
</div> </div>

View File

@ -42,4 +42,8 @@ export class MethodsList extends BaseComponent {
this.data.tags = tags; this.data.tags = tags;
// TODO: check $ref field // 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> <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()"> [type]="response.type" [empty]="response.empty" (open)="lazySchema.load()">
<div *ngIf="response.headers" class="response-headers"> <div *ngIf="response.headers" class="response-headers">
<header> <header>

View File

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

View File

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

View File

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