Merge commit '77877381a872c21ad1bf39feb4399b8fe989ba9b' into releases

This commit is contained in:
RedocBot 2016-12-28 13:19:41 +00:00 committed by travis@localhost
commit 50bcc40345
10 changed files with 87 additions and 39 deletions

2
.gitignore vendored
View File

@ -26,7 +26,7 @@ lib/**/*.css
# files produced by ngc # files produced by ngc
lib/**/*.ngfactory.ts lib/**/*.ngfactory.ts
lib/**/*.css.shim.ts lib/**/*.css.shim.ts
lib/**/*.ngsummary.json **/*.ngsummary.json
lib/**/*.shim.ngstyle.ts lib/**/*.shim.ngstyle.ts
# other # other

View File

@ -1,3 +1,13 @@
# 1.6.3 (2016-12-19)
### Bug fixes
* Disable side-menu animation (workaround for [#162](https://github.com/Rebilly/ReDoc/issues/162))
* Use markdown for response description (fixes [#158](https://github.com/Rebilly/ReDoc/issues/158))
* Fix leaks (fixes [#167](https://github.com/Rebilly/ReDoc/issues/167))
* Update webpack and stick to ts@2.0.9 (fixes [#169](https://github.com/Rebilly/ReDoc/issues/169), [#168](https://github.com/Rebilly/ReDoc/issues/168))
### Features/Improvements
* add `expand-responses` option - specify which responses are expand by default ([#165](https://github.com/Rebilly/ReDoc/issues/165)).
# 1.6.2 (2016-12-11) # 1.6.2 (2016-12-11)
### Bug fixes ### Bug fixes
* Use markdown in responses description ([#158](https://github.com/Rebilly/ReDoc/issues/158)) * Use markdown in responses description ([#158](https://github.com/Rebilly/ReDoc/issues/158))

View File

@ -75,13 +75,13 @@ module.exports = {
loader: StringReplacePlugin.replace({ loader: StringReplacePlugin.replace({
replacements: [ replacements: [
{ {
pattern: /styleUrls:\s*\[\s*'([\w\.\/-]*)\.css'\s*\][\s,]*$/m, pattern: /styleUrls:\s*\[\s*'([\w\.\/-]*)\.css'\s*\][\s,]*$/gm,
replacement: function (match, p1, offset, string) { replacement: function (match, p1, offset, string) {
return `styleUrls: ['${p1}.scss'],`; return `styleUrls: ['${p1}.scss'],`;
} }
}, },
{ {
pattern: /(\.\/components\/Redoc\/redoc-initial-styles\.css)/m, pattern: /(\.\/components\/Redoc\/redoc-initial-styles\.css)/gm,
replacement: function (match, p1, offset, string) { replacement: function (match, p1, offset, string) {
return p1.replace('.css', '.scss'); return p1.replace('.css', '.scss');
} }

View File

@ -24,6 +24,9 @@
<redoc scroll-y-offset="body > nav" spec-url='swagger.yaml' lazy-rendering></redoc> <redoc scroll-y-offset="body > nav" spec-url='swagger.yaml' lazy-rendering></redoc>
<script>
window.__REDOC_DEV__ = true;
</script>
<script src="main.js"> </script> <script src="main.js"> </script>
<script src="/webpack-dev-server.js"></script> <script src="/webpack-dev-server.js"></script>
<script src="/polyfills.js"></script> <script src="/polyfills.js"></script>

View File

@ -7,7 +7,8 @@
var url = window.location.search.match(/url=([^&]+)/); var url = window.location.search.match(/url=([^&]+)/);
if (url && url.length > 1) { if (url && url.length > 1) {
url = decodeURIComponent(url[1]); url = decodeURIComponent(url[1]);
document.getElementsByTagName('redoc')[0].setAttribute('spec-url', '\\\\cors.apis.guru/' + url); url = window.__REDOC_DEV__ ? url : '\\\\cors.apis.guru/' + url;
document.getElementsByTagName('redoc')[0].setAttribute('spec-url', url);
} }
function updateQueryStringParameter(uri, key, value) { function updateQueryStringParameter(uri, key, value) {

View File

@ -45,8 +45,8 @@ export class JsonSchema extends BaseComponent implements OnInit {
}); });
activeDescendant.active = true; activeDescendant.active = true;
this.pointer = activeDescendant.$ref; this.schema = this.specMgr.getDescendant(activeDescendant, this.componentSchema);
this.schema = this.specMgr.byPointer(this.pointer); this.pointer = this.schema._pointer || activeDescendant.$ref;
this.normalizer.reset(); this.normalizer.reset();
this.schema = this.normalizer.normalize(this.schema, this.normPointer, this.schema = this.normalizer.normalize(this.schema, this.normPointer,
{resolved: true}); {resolved: true});
@ -54,19 +54,22 @@ export class JsonSchema extends BaseComponent implements OnInit {
} }
initDescendants() { initDescendants() {
this.descendants = this.specMgr.findDerivedDefinitions(this.normPointer); this.descendants = this.specMgr.findDerivedDefinitions(this.normPointer, this.schema);
if (!this.descendants.length) return; if (!this.descendants.length) return;
this.hasDescendants = true; this.hasDescendants = true;
let discriminator = this.schema.discriminator || this.schema['x-extendedDiscriminator']; let discriminator = this.schema.discriminator || this.schema['x-extendedDiscriminator'];
let discrProperty = this.schema._properties && let discrProperty = this.schema.properties &&
this.schema._properties.filter((prop) => prop.name === discriminator)[0]; this.schema.properties[discriminator];
if (discrProperty && discrProperty.enum) { if (discrProperty && discrProperty.enum) {
let enumOrder = {}; let enumOrder = {};
discrProperty.enum.forEach((enumItem, idx) => { discrProperty.enum.forEach((enumItem, idx) => {
enumOrder[enumItem.val] = idx; enumOrder[enumItem] = idx;
}); });
this.schema._descendants.sort((a, b) => { this.descendants = this.descendants
.filter(a => {
return enumOrder[a.name] != undefined;
}).sort((a, b) => {
return enumOrder[a.name] > enumOrder[b.name] ? 1 : -1; return enumOrder[a.name] > enumOrder[b.name] ? 1 : -1;
}); });
} }

View File

@ -51,11 +51,11 @@ export class SchemaSample extends BaseComponent implements OnInit {
let discriminator = this.componentSchema.discriminator || this.componentSchema['x-discriminatorBasePointer']; 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, this.componentSchema);
if (descendants.length) { if (descendants.length) {
// TODO: sync up with dropdown // TODO: sync up with dropdown
selectedDescendant = descendants[0]; selectedDescendant = descendants[0];
let descSchema = this.specMgr.byPointer(selectedDescendant.$ref); let descSchema = this.specMgr.getDescendant(selectedDescendant, this.componentSchema);
this.componentSchema = this._normalizer.normalize(Object.assign({}, descSchema), selectedDescendant.$ref, this.componentSchema = this._normalizer.normalize(Object.assign({}, descSchema), selectedDescendant.$ref,
{omitParent: false}); {omitParent: false});
} }

View File

@ -21,10 +21,9 @@ const global = window;
style({ height: '0px' })), style({ height: '0px' })),
state('expanded', state('expanded',
style({ height: '*' })), style({ height: '*' })),
// https://github.com/Rebilly/ReDoc/issues/162 transition('collapsed <=> expanded', [
// transition('collapsed <=> expanded', [ animate('200ms ease')
// animate('200ms ease') ])
// ])
]) ])
], ],
}) })

View File

@ -7,6 +7,10 @@ import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { MdRenderer } from './md-renderer'; import { MdRenderer } from './md-renderer';
function getDiscriminator(obj) {
return obj.discriminator || obj['x-extendedDiscriminator'];
}
export class SpecManager { export class SpecManager {
public _schema: any = {}; public _schema: any = {};
public apiUrl: string; public apiUrl: string;
@ -158,8 +162,8 @@ export class SpecManager {
return tagsMap; return tagsMap;
} }
findDerivedDefinitions(defPointer) { findDerivedDefinitions(defPointer, schema) {
let definition = this.byPointer(defPointer); let definition = schema || this.byPointer(defPointer);
if (!definition) throw new Error(`Can't load schema at ${defPointer}`); if (!definition) throw new Error(`Can't load schema at ${defPointer}`);
if (!definition.discriminator && !definition['x-extendedDiscriminator']) return []; if (!definition.discriminator && !definition['x-extendedDiscriminator']) return [];
@ -172,7 +176,20 @@ export class SpecManager {
!def['x-derived-from']) continue; !def['x-derived-from']) continue;
let subTypes = def['x-derived-from'] || let subTypes = def['x-derived-from'] ||
def.allOf.map(subType => subType._pointer || subType.$ref); def.allOf.map(subType => subType._pointer || subType.$ref);
let idx = subTypes.findIndex(ref => ref === defPointer);
let pointers;
if (definition['x-derived-from']) {
pointers = [defPointer, ...definition['x-derived-from']];
} else {
pointers = [defPointer];
}
let idx = -1;
for (let ptr of pointers) {
idx = subTypes.findIndex(ref => ptr && ref === ptr);
if (idx >= 0) break;
}
if (idx < 0) continue; if (idx < 0) continue;
let derivedName = defName; let derivedName = defName;
@ -188,4 +205,19 @@ export class SpecManager {
return res; return res;
} }
getDescendant(descendant, componentSchema) {
let res;
if (!getDiscriminator(componentSchema) && componentSchema.allOf) {
// discriminator inherited from parents
// only one discriminator and only one level of inheritence is supported at the moment
res = Object.assign({}, componentSchema);
let idx = res.allOf.findIndex(subSpec => !!getDiscriminator(subSpec));
res.allOf[idx] = this.byPointer(descendant.$ref);
} else {
// this.pointer = activeDescendant.$ref;
res = this.byPointer(descendant.$ref);
}
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.6.3", "version": "1.6.4",
"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.3.1", "@angular/common": "^2.4.0",
"@angular/compiler": "^2.3.1", "@angular/compiler": "^2.4.0",
"@angular/compiler-cli": "^2.3.1", "@angular/compiler-cli": "^2.4.0",
"@angular/core": "^2.3.1", "@angular/core": "^2.4.0",
"@angular/platform-browser": "^2.3.1", "@angular/platform-browser": "^2.4.0",
"@angular/platform-browser-dynamic": "^2.3.1", "@angular/platform-browser-dynamic": "^2.4.0",
"@angular/platform-server": "^2.3.1", "@angular/platform-server": "^2.4.0",
"@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",
@ -60,7 +60,7 @@
"awesome-typescript-loader": "^2.2.4", "awesome-typescript-loader": "^2.2.4",
"branch-release": "^1.0.3", "branch-release": "^1.0.3",
"chalk": "^1.1.3", "chalk": "^1.1.3",
"codelyzer": "^2.0.0-beta.3", "codelyzer": "^2.0.0-beta.4",
"core-js": "^2.4.1", "core-js": "^2.4.1",
"coveralls": "^2.11.9", "coveralls": "^2.11.9",
"css-loader": "^0.26.0", "css-loader": "^0.26.0",
@ -81,11 +81,11 @@
"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.11.2", "node-sass": "^4.1.1",
"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",
"rxjs": "^5.0.0-rc.4", "rxjs": "^5.0.1",
"sass-loader": "^4.0.2", "sass-loader": "^4.0.2",
"shelljs": "^0.7.0", "shelljs": "^0.7.0",
"should": "^11.1.0", "should": "^11.1.0",
@ -110,17 +110,17 @@
"remarkable": "^1.6.2", "remarkable": "^1.6.2",
"scrollparent": "^1.0.0", "scrollparent": "^1.0.0",
"slugify": "^1.0.2", "slugify": "^1.0.2",
"stream-http": "^2.3.1" "stream-http": "^2.5.0"
}, },
"peerDependencies": { "peerDependencies": {
"@angular/common": "^2.3.1", "@angular/common": "^2.4.0",
"@angular/compiler": "^2.3.1", "@angular/compiler": "^2.4.0",
"@angular/core": "^2.3.1", "@angular/core": "^2.4.0",
"@angular/platform-browser": "^2.3.1", "@angular/platform-browser": "^2.4.0",
"@angular/platform-browser-dynamic": "^2.3.1", "@angular/platform-browser-dynamic": "^2.4.0",
"@angular/platform-server": "^2.3.1", "@angular/platform-server": "^2.4.0",
"core-js": "^2.4.1", "core-js": "^2.4.1",
"rxjs": "5.0.0-rc.4", "rxjs": "^5.0.1",
"zone.js": "^0.7.2" "zone.js": "^0.7.2"
} }
} }