mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-27 19:13:44 +03:00
Merge commit '41dcaaafd0e4ee37f9018bd4f885c5e552617eda' into releases
This commit is contained in:
commit
1c17f94621
|
@ -46,6 +46,7 @@ $sub-schema-offset: ($bullet-size/2) + $bullet-margin;
|
|||
border-radius: $border-radius;
|
||||
background-color: rgba($primary-color, .1);
|
||||
margin-left: 6px;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.param-description {
|
||||
|
|
|
@ -23,11 +23,15 @@ describe('Redoc components', () => {
|
|||
fixture = builder.createSync(TestAppComponent);
|
||||
let debugEl = getChildDebugElement(fixture.debugElement, 'json-schema-lazy');
|
||||
component = <JsonSchemaLazy>debugEl.componentInstance;
|
||||
spyOn(component, '_loadAfterSelf').and.stub();
|
||||
spyOn(component, '_loadAfterSelf').and.callThrough();
|
||||
spyOn(component.resolver, 'resolveComponent').and.returnValue({ then: () => {
|
||||
return { catch: () => {/**/} };
|
||||
}});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
component._loadAfterSelf.and.callThrough();
|
||||
component.resolver.resolveComponent.and.callThrough();
|
||||
});
|
||||
|
||||
it('should init component', () => {
|
||||
|
|
|
@ -34,7 +34,7 @@ export class JsonSchemaLazy implements OnDestroy, AfterViewInit {
|
|||
}
|
||||
|
||||
_loadAfterSelf() {
|
||||
// FIXME: get rid of DynamicComponentLoader as it is deprecated
|
||||
this.loaded = true;
|
||||
return this.resolver.resolveComponent(JsonSchema).then(componentFactory => {
|
||||
let contextInjector = this.location.parentInjector;
|
||||
let compRef = this.location.createComponent(
|
||||
|
@ -55,7 +55,6 @@ export class JsonSchemaLazy implements OnDestroy, AfterViewInit {
|
|||
if (this.pointer) {
|
||||
this._loadAfterSelf();
|
||||
}
|
||||
this.loaded = true;
|
||||
}
|
||||
|
||||
// cache JsonSchema view
|
||||
|
@ -73,7 +72,8 @@ export class JsonSchemaLazy implements OnDestroy, AfterViewInit {
|
|||
return;
|
||||
}
|
||||
insertAfter($element.cloneNode(true), this.elementRef.nativeElement);
|
||||
} );
|
||||
this.loaded = true;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
cache[this.pointer] = this._loadAfterSelf();
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
'expanded': subSchema.visible
|
||||
}">
|
||||
<td class="param-name">
|
||||
<span class="param-name-wrap">
|
||||
<span (click)="subSchema.toggle()" class="param-name-content" >{{prop._name}}</span>
|
||||
<span class="param-name-wrap" (click)="subSchema.toggle()">
|
||||
<span class="param-name-content" >{{prop._name}}</span>
|
||||
<svg *ngIf="prop._pointer" xmlns="http://www.w3.org/2000/svg" version="1.1" x="0" y="0" viewBox="0 0 24 24" xml:space="preserve">
|
||||
<polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "/>
|
||||
</svg>
|
||||
|
@ -62,8 +62,8 @@
|
|||
</tr>
|
||||
<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'
|
||||
<zippy #subSchema title="Expand" [headless]="true" (open)="lazySchema.load()" [visible]="autoExpand">
|
||||
<json-schema-lazy #lazySchema [auto]="autoExpand" class="nested-schema" [pointer]="prop._pointer" [isArray]='prop._isArray'
|
||||
[nestOdd]="!nestOdd" [isRequestSchema]="isRequestSchema">
|
||||
</json-schema-lazy>
|
||||
</zippy>
|
||||
|
|
|
@ -69,6 +69,10 @@ $array-marker-line-height: 1.5;
|
|||
}
|
||||
}
|
||||
|
||||
zippy {
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.zippy-content-wrap {
|
||||
padding: 0;
|
||||
}
|
||||
|
@ -77,9 +81,10 @@ $array-marker-line-height: 1.5;
|
|||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.param.complex > .param-name .param-name-content {
|
||||
.param.complex > .param-name .param-name-wrap {
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
color: $black;
|
||||
}
|
||||
|
||||
.param.complex > .param-name svg {
|
||||
|
@ -97,10 +102,13 @@ $array-marker-line-height: 1.5;
|
|||
}
|
||||
|
||||
.params-wrap {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table {
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
.params-wrap.params-array:before, .params-wrap.params-array:after {
|
||||
display: block;
|
||||
font-weight: $base-font-weight;
|
||||
|
|
|
@ -28,6 +28,7 @@ export class JsonSchema extends BaseComponent {
|
|||
@Input() childFor: string;
|
||||
@Input() isRequestSchema: boolean;
|
||||
normalizer: SchemaNormalizer;
|
||||
autoExpand = false;
|
||||
|
||||
constructor(specMgr:SpecManager, private _renderer: Renderer, private _elementRef: ElementRef) {
|
||||
super(specMgr);
|
||||
|
@ -100,6 +101,8 @@ export class JsonSchema extends BaseComponent {
|
|||
}
|
||||
return (propSchema && propSchema.type === 'object' && propSchema._pointer);
|
||||
});
|
||||
|
||||
this.autoExpand = this.properties && this.properties.length === 1;
|
||||
}
|
||||
|
||||
trackByIdx(index: number, item: any): number {
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
border-bottom: 1px solid rgba(127, 127, 127, 0.25);
|
||||
}
|
||||
|
||||
:host:last-of-type {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
responses-list, params-list {
|
||||
display: block;
|
||||
}
|
||||
|
|
|
@ -142,14 +142,17 @@ api-logo {
|
|||
}
|
||||
|
||||
footer {
|
||||
position: relative;
|
||||
text-align: right;
|
||||
padding: 10px;
|
||||
padding: 10px 40px;
|
||||
font-size: 15px;
|
||||
background-color: white;
|
||||
|
||||
margin-top: -35px;
|
||||
color: white;
|
||||
a {
|
||||
color: white;
|
||||
}
|
||||
strong {
|
||||
font-size: 18px;
|
||||
color: $headers-color;
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<div class="header-description" [innerHtml]="header.description | marked"> </div>
|
||||
</div>
|
||||
</div>
|
||||
<header *ngIf="response.headers">
|
||||
<header *ngIf="response.schema">
|
||||
Response Schema
|
||||
</header>
|
||||
<json-schema-lazy #lazySchema pointer="{{response.schema ? response.pointer + '/schema' : null}}">
|
||||
|
|
|
@ -43,7 +43,21 @@ export class SchemaSample extends BaseComponent {
|
|||
if (base.examples && base.examples['application/json']) {
|
||||
sample = base.examples['application/json'];
|
||||
} else {
|
||||
let selectedDescendant;
|
||||
|
||||
this.componentSchema = this._normalizer.normalize(this.componentSchema, this.pointer);
|
||||
|
||||
let discriminator = this.componentSchema.discriminator;
|
||||
if (discriminator) {
|
||||
let descendants = this.specMgr.findDerivedDefinitions(this.componentSchema._pointer || this.pointer);
|
||||
if (descendants.length) {
|
||||
// TODO: sync up with dropdown
|
||||
selectedDescendant = descendants[0];
|
||||
let descSchema = this.specMgr.byPointer(selectedDescendant.$ref);
|
||||
this.componentSchema = this._normalizer.normalize(Object.assign({}, descSchema), selectedDescendant.$ref,
|
||||
{omitParent: false});
|
||||
}
|
||||
}
|
||||
if (this.fromCache()) {
|
||||
return;
|
||||
}
|
||||
|
@ -54,6 +68,9 @@ export class SchemaSample extends BaseComponent {
|
|||
} catch(e) {
|
||||
// no sample available
|
||||
}
|
||||
if (selectedDescendant) {
|
||||
sample[discriminator] = selectedDescendant.name;
|
||||
}
|
||||
}
|
||||
this.cache(sample);
|
||||
this.data.sample = sample;
|
||||
|
|
|
@ -21,7 +21,7 @@ import { ScrollService, Hash, MenuService, OptionsService } from '../../services
|
|||
state('expanded',
|
||||
style({ height: '*' })),
|
||||
transition('collapsed <=> expanded', [
|
||||
animate(200)
|
||||
animate('200ms ease')
|
||||
])
|
||||
])
|
||||
],
|
||||
|
|
|
@ -221,7 +221,8 @@ export class SchemaHelper {
|
|||
}
|
||||
|
||||
static methodSummary(method) {
|
||||
return method.summary || method.operationId || method.description.substring(0, 50);
|
||||
return method.summary || method.operationId ||
|
||||
(method.description && method.description.substring(0, 50)) || '<no description>';
|
||||
}
|
||||
|
||||
static buildMenuTree(schema) {
|
||||
|
|
|
@ -22,13 +22,14 @@ export class SchemaNormalizer {
|
|||
constructor(private _schema:any) {
|
||||
this._dereferencer = new SchemaDereferencer(_schema, this);
|
||||
}
|
||||
normalize(schema, ptr) {
|
||||
normalize(schema, ptr, opts:any ={}) {
|
||||
opts.omitParent = opts.omitParent !== false;
|
||||
if (schema['x-redoc-normalized']) return schema;
|
||||
let res = SchemaWalker.walk(schema, ptr, (subSchema, ptr) => {
|
||||
let resolved = this._dereferencer.dereference(subSchema, ptr);
|
||||
if (resolved.allOf) {
|
||||
resolved._pointer = resolved._pointer || ptr;
|
||||
AllOfMerger.merge(resolved, resolved.allOf, {omitParent: true});
|
||||
AllOfMerger.merge(resolved, resolved.allOf, {omitParent: opts.omitParent});
|
||||
}
|
||||
return resolved;
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
.dk-selected {
|
||||
color: $secondary-color;
|
||||
border-color: rgba($secondary-color, .5);
|
||||
padding: 0.15em 0.6em 0.2em 0.5em;
|
||||
padding: 0.15em 1.5em 0.2em 0.5em;
|
||||
border-radius: $border-radius;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,9 @@
|
|||
margin-top: 0.2em;
|
||||
padding: 0;
|
||||
border-radius: $border-radius;
|
||||
box-shadow: 0px 2px 4px 0px rgba(34, 36, 38, 0.12), 0px 2px 10px 0px rgba(34, 36, 38, 0.08) !important
|
||||
box-shadow: 0px 2px 4px 0px rgba(34, 36, 38, 0.12), 0px 2px 10px 0px rgba(34, 36, 38, 0.08) !important;
|
||||
right: auto;
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
.dk-option {
|
||||
|
|
|
@ -10,6 +10,14 @@ $zippy-info-bg-color: rgba($zippy-info-color, .08);
|
|||
$zippy-redirect-color: #263238;
|
||||
$zippy-redirect-bg-color: rgba($zippy-redirect-color, .08);
|
||||
|
||||
:host {
|
||||
// performance optimization
|
||||
transform: translate3d(0, 0, 0);
|
||||
backface-visibility: hidden;
|
||||
overflow: hidden;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.zippy-title {
|
||||
padding: 10px;
|
||||
border-radius: 2px;
|
||||
|
@ -98,8 +106,5 @@ span.zippy-indicator {
|
|||
}
|
||||
|
||||
.zippy-hidden > .zippy-content {
|
||||
overflow: hidden;
|
||||
visibility: hidden;
|
||||
height: 0;
|
||||
padding: 0;
|
||||
display: none;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ export class SpecManager {
|
|||
if (!globalDefs[defName].allOf &&
|
||||
!globalDefs[defName]['x-derived-from']) continue;
|
||||
let subTypes = globalDefs[defName]['x-derived-from'] ||
|
||||
globalDefs[defName].allOf.map(subType => subType.$ref);
|
||||
globalDefs[defName].allOf.map(subType => subType._pointer || subType.$ref);
|
||||
let idx = subTypes.findIndex(ref => ref === defPointer);
|
||||
if (idx < 0) continue;
|
||||
|
||||
|
|
12
package.json
12
package.json
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "redoc",
|
||||
"description": "Swagger-generated API Reference Documentation",
|
||||
"version": "0.15.2",
|
||||
"version": "0.15.3",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/Rebilly/ReDoc"
|
||||
|
@ -43,7 +43,7 @@
|
|||
"json": "github:systemjs/plugin-json@^0.1.0",
|
||||
"json-pointer": "npm:json-pointer@^0.3.0",
|
||||
"json-schema-ref-parser": "npm:json-schema-ref-parser@^3.1.2",
|
||||
"openapi-sampler": "npm:openapi-sampler@0.2.0",
|
||||
"openapi-sampler": "npm:openapi-sampler@^0.3.0",
|
||||
"prismjs": "npm:prismjs@^1.3.0",
|
||||
"remarkable": "npm:remarkable@^1.6.2",
|
||||
"rxjs": "npm:rxjs@5.0.0-beta.6",
|
||||
|
@ -60,10 +60,6 @@
|
|||
"systemjs/plugin-json": "github:systemjs/plugin-json@^0.1.0"
|
||||
},
|
||||
"overrides": {
|
||||
"npm:openapi-sampler@0.2.0": {
|
||||
"main": "src/openapi-sampler",
|
||||
"format": "esm"
|
||||
},
|
||||
"npm:dropkickjs@2.1.8": {
|
||||
"format": "global"
|
||||
},
|
||||
|
@ -72,6 +68,10 @@
|
|||
"http": "stream-http",
|
||||
"https": "stream-http"
|
||||
}
|
||||
},
|
||||
"npm:openapi-sampler@0.3.0": {
|
||||
"main": "src/openapi-sampler",
|
||||
"format": "esm"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
import nodeResolve from 'rollup-plugin-node-resolve';
|
||||
import commonjs from 'rollup-plugin-commonjs';
|
||||
|
||||
class RollupNG2 {
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
}
|
||||
resolveId(id, from) {
|
||||
if (id.startsWith('rxjs/')) {
|
||||
return `${__dirname}/node_modules/rxjs-es/${id.replace('rxjs/', '')}.js`;
|
||||
}
|
||||
|
||||
if(id.startsWith('@angular/core')){
|
||||
if(id === '@angular/core'){
|
||||
return `${__dirname}/node_modules/@angular/core/esm/index.js`;
|
||||
}
|
||||
return `${__dirname}/node_modules/@angular/core/esm/${id.split('@angular/core').pop()}.js`;
|
||||
}
|
||||
if(id.startsWith('@angular/common')){
|
||||
if(id === '@angular/common'){
|
||||
return `${__dirname}/node_modules/@angular/common/esm/index.js`;
|
||||
}
|
||||
return `${__dirname}/node_modules/@angular/common/esm/${id.split('@angular/common').pop()}.js`;
|
||||
}
|
||||
if(id.startsWith('@angular/platform-browser-dynamic')){
|
||||
if(id === '@angular/platform-browser-dynamic'){
|
||||
return `${__dirname}/node_modules/@angular/platform-browser-dynamic/esm/index.js`;
|
||||
}
|
||||
return `${__dirname}/node_modules/@angular/platform-browser-dynamic/esm/${id.split('@angular/platform-browser-dynamic').pop()}.js`;
|
||||
}
|
||||
if(id.startsWith('@angular/platform-browser')){
|
||||
if(id === '@angular/platform-browser'){
|
||||
return `${__dirname}/node_modules/@angular/platform-browser/esm/index.js`;
|
||||
}
|
||||
return `${__dirname}/node_modules/@angular/platform-browser/esm/${id.split('@angular/platform-browser').pop()}.js`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const rollupNG2 = (config) => new RollupNG2(config);
|
||||
export default {
|
||||
entry: './.tmp-es/index.js',
|
||||
dest: 'dist/vendor.es2015.js',
|
||||
format: 'iife',
|
||||
moduleName: 'ReDoc',
|
||||
plugins: [
|
||||
//typescript(),
|
||||
rollupNG2(),
|
||||
nodeResolve({ jsnext: true, main: true, browser: true }),
|
||||
commonjs({
|
||||
// non-CommonJS modules will be ignored, but you can also
|
||||
// specifically include/exclude files
|
||||
include: 'node_modules/**', // Default: undefined
|
||||
exclude: [ 'node_modules/@angular/**', 'node_modules/rxjs/**', 'node_modules/rxjs-es/**' ], // Default: undefined
|
||||
namedExports: { 'marked': ['marked'] } // Default: undefined
|
||||
})
|
||||
]
|
||||
}
|
|
@ -19,8 +19,8 @@ System.config({
|
|||
"@angular/common": "npm:@angular/common@2.0.0-rc.4",
|
||||
"@angular/compiler": "npm:@angular/compiler@2.0.0-rc.4",
|
||||
"@angular/core": "npm:@angular/core@2.0.0-rc.4",
|
||||
"@angular/platform-browser-dynamic": "npm:@angular/platform-browser-dynamic@2.0.0-rc.4",
|
||||
"@angular/platform-browser": "npm:@angular/platform-browser@2.0.0-rc.4",
|
||||
"@angular/platform-browser-dynamic": "npm:@angular/platform-browser-dynamic@2.0.0-rc.4",
|
||||
"babel": "npm:babel-core@5.8.34",
|
||||
"babel-runtime": "npm:babel-runtime@5.8.34",
|
||||
"clean-css": "npm:clean-css@3.4.17",
|
||||
|
@ -33,7 +33,7 @@ System.config({
|
|||
"json-formatter-js": "npm:json-formatter-js@0.2.0",
|
||||
"json-pointer": "npm:json-pointer@0.3.0",
|
||||
"json-schema-ref-parser": "npm:json-schema-ref-parser@3.1.2",
|
||||
"openapi-sampler": "npm:openapi-sampler@0.2.0",
|
||||
"openapi-sampler": "npm:openapi-sampler@0.3.0",
|
||||
"prismjs": "npm:prismjs@1.3.0",
|
||||
"remarkable": "npm:remarkable@1.6.2",
|
||||
"rxjs": "npm:rxjs@5.0.0-beta.6",
|
||||
|
@ -654,9 +654,6 @@ System.config({
|
|||
"process": "github:jspm/nodelibs-process@0.1.2",
|
||||
"util": "github:jspm/nodelibs-util@0.1.0"
|
||||
},
|
||||
"npm:openapi-sampler@0.2.0": {
|
||||
"process": "github:jspm/nodelibs-process@0.1.2"
|
||||
},
|
||||
"npm:os-browserify@0.1.2": {
|
||||
"os": "github:jspm/nodelibs-os@0.1.0"
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user