Merge branch 'master' into css-changes

This commit is contained in:
Roman Hotsiy 2016-03-13 02:49:15 +02:00
commit 2e53b9fa50
9 changed files with 29 additions and 20 deletions

View File

@ -1,7 +1,7 @@
# 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) [![Code Climate](https://codeclimate.com/github/Rebilly/ReDoc/badges/gpa.svg)](https://codeclimate.com/github/Rebilly/ReDoc) [![David](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)
[![npm](http://img.shields.io/npm/v/redoc.svg)](https://www.npmjs.com/package/swagger-parser) [![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)

View File

@ -73,13 +73,10 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin;
}
.param-type.with-hint {
&:before, &:after {
content: "\\00a0";
}
background-color: rgba(0, 50, 159, 0.1);
padding: 0.2em 0;
font-size: 0.85em;
border-radius: 3px;
display: inline-block;
margin-bottom: 0.4em;
border-bottom: 1px dotted rgba(38,50,56,0.4);
padding: 0;
cursor: help;
}

View File

@ -59,14 +59,13 @@ export default class JsonSchema extends BaseComponent {
this.pointer = schema._pointer || this.pointer;
this.requiredMap = {};
if (this.schema.required) {
this.schema.required.forEach(prop => this.requiredMap[prop] = true);
if (this.componentSchema.required) {
this.componentSchema.required.forEach(prop => this.requiredMap[prop] = true);
}
if (!schema.properties) {
this.isTrivial = true;
this._displayType = schema.type;
this._displayTypeHint = 'This field may contain data of any type';
return;
}
@ -108,13 +107,13 @@ export default class JsonSchema extends BaseComponent {
propData.format = itemFormat;
propData._isArray = true;
propData.type = 'array ' + propData.items.type;
} else if (propData.type === 'object') {
} else if (propData.type === 'object' && propData.properties) {
propData._displayType = propData.title || 'object';
} else if (!propData.type) {
propData._displayType = '< * >';
propData._displayTypeHint = 'This field may contain data of any type';
} else {
// here we are sure that property has simple type
// here we are sure that property has simple type (integer, string, object withou properties)
// delete pointer for simple types to not show it as subschema
if (propData._pointer) {
propData._pointer = undefined;

View File

@ -30,9 +30,9 @@ export default class Method extends BaseComponent {
this.data.methodInfo.tags = this.filterMainTags(this.data.methodInfo.tags);
this.data.bodyParam = this.findBodyParam();
if (this.componentSchema.operationId) {
this.data.methodAnchor = 'operation/' + this.componentSchema.operationId;
this.data.methodAnchor = 'operation/' + encodeURIComponent(this.componentSchema.operationId);
} else {
this.data.methodAnchor = 'tag/' + this.tag + this.pointer;
this.data.methodAnchor = 'tag/' + encodeURIComponent(this.tag + this.pointer);
}
}

View File

@ -1,7 +1,7 @@
<div class="methods">
<div class="tag" *ngFor="#tag of data.tags">
<div class="tag-info" [attr.tag]="tag.name">
<h1 class="sharable-header"> <a class="share-link" href="#tag/{{tag.name}}"></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>
</div>
<method *ngFor="#method of tag.methods" [pointer]="method.pointer" [attr.pointer]="method.pointer"

View File

@ -2,12 +2,14 @@
import {RedocComponent, BaseComponent} from '../base';
import Method from '../Method/method';
import {EncodeURIComponentPipe} from '../../utils/pipes';
@RedocComponent({
selector: 'methods-list',
templateUrl: './lib/components/MethodsList/methods-list.html',
styleUrls: ['./lib/components/MethodsList/methods-list.css'],
directives: [Method]
directives: [Method],
pipes: [EncodeURIComponentPipe]
})
export default class MethodsList extends BaseComponent {

View File

@ -62,7 +62,7 @@ export default class SideMenu extends BaseComponent {
let $el;
hash = hash.substr(1);
let namespace = hash.split('/')[0];
let ptr = hash.substr(namespace.length + 1);
let ptr = decodeURIComponent(hash.substr(namespace.length + 1));
if (namespace === 'operation') {
$el = this.getMethodElByOperId(ptr);
} else if (namespace === 'tag') {

View File

@ -118,3 +118,14 @@ export class PrismPipe {
return Prism.highlight(value, grammar);
}
}
@Pipe({ name: 'encodeURIComponent' })
export class EncodeURIComponentPipe {
transform(value) {
if (isBlank(value)) return value;
if (!isString(value)) {
throw new InvalidPipeArgumentException(EncodeURIComponentPipe, value);
}
return encodeURIComponent(value);
}
}

View File

@ -1,7 +1,7 @@
{
"name": "redoc",
"description": "Swagger-generated API Reference Documentation",
"version": "0.6.2",
"version": "0.6.6",
"repository": {
"type": "git",
"url": "git://github.com/Rebilly/ReDoc"
@ -56,7 +56,7 @@
"devDependencies": {
"babel-eslint": "^4.1.6",
"babel-polyfill": "^6.3.14",
"branch-release": "^0.3.1",
"branch-release": "^0.3.2",
"browser-sync": "^2.10.1",
"del": "^2.2.0",
"deploy-to-gh-pages": "^1.0.0",