mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-10 23:10:34 +03:00
Merge commit '77877381a872c21ad1bf39feb4399b8fe989ba9b' into releases
This commit is contained in:
commit
50bcc40345
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -26,7 +26,7 @@ lib/**/*.css
|
|||
# files produced by ngc
|
||||
lib/**/*.ngfactory.ts
|
||||
lib/**/*.css.shim.ts
|
||||
lib/**/*.ngsummary.json
|
||||
**/*.ngsummary.json
|
||||
lib/**/*.shim.ngstyle.ts
|
||||
|
||||
# other
|
||||
|
|
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -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)
|
||||
### Bug fixes
|
||||
* Use markdown in responses description ([#158](https://github.com/Rebilly/ReDoc/issues/158))
|
||||
|
|
|
@ -75,13 +75,13 @@ module.exports = {
|
|||
loader: StringReplacePlugin.replace({
|
||||
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) {
|
||||
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) {
|
||||
return p1.replace('.css', '.scss');
|
||||
}
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
|
||||
<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="/webpack-dev-server.js"></script>
|
||||
<script src="/polyfills.js"></script>
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
var url = window.location.search.match(/url=([^&]+)/);
|
||||
if (url && url.length > 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) {
|
||||
|
|
|
@ -45,8 +45,8 @@ export class JsonSchema extends BaseComponent implements OnInit {
|
|||
});
|
||||
activeDescendant.active = true;
|
||||
|
||||
this.pointer = activeDescendant.$ref;
|
||||
this.schema = this.specMgr.byPointer(this.pointer);
|
||||
this.schema = this.specMgr.getDescendant(activeDescendant, this.componentSchema);
|
||||
this.pointer = this.schema._pointer || activeDescendant.$ref;
|
||||
this.normalizer.reset();
|
||||
this.schema = this.normalizer.normalize(this.schema, this.normPointer,
|
||||
{resolved: true});
|
||||
|
@ -54,19 +54,22 @@ export class JsonSchema extends BaseComponent implements OnInit {
|
|||
}
|
||||
|
||||
initDescendants() {
|
||||
this.descendants = this.specMgr.findDerivedDefinitions(this.normPointer);
|
||||
this.descendants = this.specMgr.findDerivedDefinitions(this.normPointer, this.schema);
|
||||
if (!this.descendants.length) return;
|
||||
this.hasDescendants = true;
|
||||
let discriminator = this.schema.discriminator || this.schema['x-extendedDiscriminator'];
|
||||
let discrProperty = this.schema._properties &&
|
||||
this.schema._properties.filter((prop) => prop.name === discriminator)[0];
|
||||
let discrProperty = this.schema.properties &&
|
||||
this.schema.properties[discriminator];
|
||||
if (discrProperty && discrProperty.enum) {
|
||||
let enumOrder = {};
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -51,11 +51,11 @@ export class SchemaSample extends BaseComponent implements OnInit {
|
|||
|
||||
let discriminator = this.componentSchema.discriminator || this.componentSchema['x-discriminatorBasePointer'];
|
||||
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) {
|
||||
// TODO: sync up with dropdown
|
||||
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,
|
||||
{omitParent: false});
|
||||
}
|
||||
|
|
|
@ -21,10 +21,9 @@ const global = window;
|
|||
style({ height: '0px' })),
|
||||
state('expanded',
|
||||
style({ height: '*' })),
|
||||
// https://github.com/Rebilly/ReDoc/issues/162
|
||||
// transition('collapsed <=> expanded', [
|
||||
// animate('200ms ease')
|
||||
// ])
|
||||
transition('collapsed <=> expanded', [
|
||||
animate('200ms ease')
|
||||
])
|
||||
])
|
||||
],
|
||||
})
|
||||
|
|
|
@ -7,6 +7,10 @@ import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
|||
|
||||
import { MdRenderer } from './md-renderer';
|
||||
|
||||
function getDiscriminator(obj) {
|
||||
return obj.discriminator || obj['x-extendedDiscriminator'];
|
||||
}
|
||||
|
||||
export class SpecManager {
|
||||
public _schema: any = {};
|
||||
public apiUrl: string;
|
||||
|
@ -158,8 +162,8 @@ export class SpecManager {
|
|||
return tagsMap;
|
||||
}
|
||||
|
||||
findDerivedDefinitions(defPointer) {
|
||||
let definition = this.byPointer(defPointer);
|
||||
findDerivedDefinitions(defPointer, schema) {
|
||||
let definition = schema || this.byPointer(defPointer);
|
||||
if (!definition) throw new Error(`Can't load schema at ${defPointer}`);
|
||||
if (!definition.discriminator && !definition['x-extendedDiscriminator']) return [];
|
||||
|
||||
|
@ -172,7 +176,20 @@ export class SpecManager {
|
|||
!def['x-derived-from']) continue;
|
||||
let subTypes = def['x-derived-from'] ||
|
||||
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;
|
||||
|
||||
let derivedName = defName;
|
||||
|
@ -188,4 +205,19 @@ export class SpecManager {
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
38
package.json
38
package.json
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "redoc",
|
||||
"description": "Swagger-generated API Reference Documentation",
|
||||
"version": "1.6.3",
|
||||
"version": "1.6.4",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/Rebilly/ReDoc"
|
||||
|
@ -45,13 +45,13 @@
|
|||
"author": "Roman Hotsiy",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@angular/common": "^2.3.1",
|
||||
"@angular/compiler": "^2.3.1",
|
||||
"@angular/compiler-cli": "^2.3.1",
|
||||
"@angular/core": "^2.3.1",
|
||||
"@angular/platform-browser": "^2.3.1",
|
||||
"@angular/platform-browser-dynamic": "^2.3.1",
|
||||
"@angular/platform-server": "^2.3.1",
|
||||
"@angular/common": "^2.4.0",
|
||||
"@angular/compiler": "^2.4.0",
|
||||
"@angular/compiler-cli": "^2.4.0",
|
||||
"@angular/core": "^2.4.0",
|
||||
"@angular/platform-browser": "^2.4.0",
|
||||
"@angular/platform-browser-dynamic": "^2.4.0",
|
||||
"@angular/platform-server": "^2.4.0",
|
||||
"@types/core-js": "^0.9.31",
|
||||
"@types/jasmine": "^2.2.32",
|
||||
"@types/requirejs": "^2.1.26",
|
||||
|
@ -60,7 +60,7 @@
|
|||
"awesome-typescript-loader": "^2.2.4",
|
||||
"branch-release": "^1.0.3",
|
||||
"chalk": "^1.1.3",
|
||||
"codelyzer": "^2.0.0-beta.3",
|
||||
"codelyzer": "^2.0.0-beta.4",
|
||||
"core-js": "^2.4.1",
|
||||
"coveralls": "^2.11.9",
|
||||
"css-loader": "^0.26.0",
|
||||
|
@ -81,11 +81,11 @@
|
|||
"karma-sinon": "^1.0.4",
|
||||
"karma-sourcemap-loader": "^0.3.7",
|
||||
"karma-webpack": "^1.8.0",
|
||||
"node-sass": "^3.11.2",
|
||||
"node-sass": "^4.1.1",
|
||||
"phantomjs-prebuilt": "^2.1.7",
|
||||
"protractor": "^4.0.10",
|
||||
"raw-loader": "^0.5.1",
|
||||
"rxjs": "^5.0.0-rc.4",
|
||||
"rxjs": "^5.0.1",
|
||||
"sass-loader": "^4.0.2",
|
||||
"shelljs": "^0.7.0",
|
||||
"should": "^11.1.0",
|
||||
|
@ -110,17 +110,17 @@
|
|||
"remarkable": "^1.6.2",
|
||||
"scrollparent": "^1.0.0",
|
||||
"slugify": "^1.0.2",
|
||||
"stream-http": "^2.3.1"
|
||||
"stream-http": "^2.5.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@angular/common": "^2.3.1",
|
||||
"@angular/compiler": "^2.3.1",
|
||||
"@angular/core": "^2.3.1",
|
||||
"@angular/platform-browser": "^2.3.1",
|
||||
"@angular/platform-browser-dynamic": "^2.3.1",
|
||||
"@angular/platform-server": "^2.3.1",
|
||||
"@angular/common": "^2.4.0",
|
||||
"@angular/compiler": "^2.4.0",
|
||||
"@angular/core": "^2.4.0",
|
||||
"@angular/platform-browser": "^2.4.0",
|
||||
"@angular/platform-browser-dynamic": "^2.4.0",
|
||||
"@angular/platform-server": "^2.4.0",
|
||||
"core-js": "^2.4.1",
|
||||
"rxjs": "5.0.0-rc.4",
|
||||
"rxjs": "^5.0.1",
|
||||
"zone.js": "^0.7.2"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user