mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-28 03:23:44 +03:00
Merge branch 'master' into releases
This commit is contained in:
commit
159320da36
|
@ -1,5 +1,5 @@
|
|||
# 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)
|
||||
[![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) [![Tested on APIs.guru](http://apis-guru.github.io/api-models/banners/tested_on_banner.svg)](https://github.com/APIs-guru/api-models) [![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/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)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ cd -
|
|||
# build
|
||||
gulp build
|
||||
cd demo
|
||||
cp -R ../dist ./dist
|
||||
cp -R ../dist/* ./dist/
|
||||
mkdir -p releases
|
||||
cp -R ../.ghpages-tmp/* ./releases/
|
||||
cd -
|
||||
|
|
|
@ -14,7 +14,7 @@ var cache = {};
|
|||
|
||||
@Component({
|
||||
selector: 'json-schema-lazy',
|
||||
inputs: ['pointer', 'auto', 'skipReadOnly'],
|
||||
inputs: ['pointer', 'auto', 'isRequestSchema'],
|
||||
template: '',
|
||||
directives: [CORE_DIRECTIVES]
|
||||
})
|
||||
|
@ -91,7 +91,7 @@ export class JsonSchemaLazy {
|
|||
|
||||
initComponent(compRef) {
|
||||
compRef.instance.pointer = this.pointer;
|
||||
compRef.instance.skipReadOnly = this.skipReadOnly;
|
||||
compRef.instance.isRequestSchema = this.isRequestSchema;
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
<span *ngIf="schema.isTrivial" class="param-wrap">
|
||||
<span *ngIf="schema.isFile" class="param-wrap">
|
||||
<span class="param-file">file</span>
|
||||
<div *ngIf="schema._produces && !isRequestSchema" class="file produces">
|
||||
Produces: {{ schema._produces | json }}
|
||||
</div>
|
||||
<div *ngIf="schema._consumes && isRequestSchema" class="file consume">
|
||||
Consumes: {{ schema._consumes | json }}
|
||||
</div>
|
||||
</span>
|
||||
<span *ngIf="schema.isTrivial && !schema.isFile" class="param-wrap">
|
||||
<span class="param-type param-type-trivial {{schema.type}}"
|
||||
[ngClass]="{'with-hint': schema._displayTypeHint}"
|
||||
title="{{schema._displayTypeHint}}">{{schema._displayType}} {{schema._displayFormat}}
|
||||
|
@ -43,7 +52,7 @@
|
|||
<tr class="param-schema" [ngClass]="{'param-array': prop._isArray, 'last': last}" *ngIf="prop._pointer">
|
||||
<td colspan="2">
|
||||
<json-schema class="nested-schema" pointer="{{prop._pointer}}" [isArray]='prop._isArray'
|
||||
[nestOdd]="!nestOdd" [skipReadOnly]="skipReadOnly" [attr.nesteven]="!nestOdd">
|
||||
[nestOdd]="!nestOdd" [isRequestSchema]="isRequestSchema" [attr.nesteven]="!nestOdd">
|
||||
</json-schema>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -52,7 +61,7 @@
|
|||
<td colspan="2">
|
||||
<div class="derived-schema" *ngFor="let derived of schema.derived" [ngClass]="{active: derived.active}">
|
||||
<json-schema class="discriminator-part" *ngIf="!derived.empty" [childFor]="pointer"
|
||||
pointer="{{derived.$ref}}" [final]="derived.final" [skipReadOnly]="skipReadOnly">
|
||||
pointer="{{derived.$ref}}" [final]="derived.final" [isRequestSchema]="isRequestSchema">
|
||||
</json-schema>
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
@ -11,7 +11,7 @@ import JsonPointer from '../../utils/JsonPointer';
|
|||
templateUrl: './lib/components/JsonSchema/json-schema.html',
|
||||
styleUrls: ['./lib/components/JsonSchema/json-schema.css'],
|
||||
directives: [JsonSchema, DropDown],
|
||||
inputs: ['isArray', 'final', 'nestOdd', 'childFor', 'skipReadOnly']
|
||||
inputs: ['isArray', 'final', 'nestOdd', 'childFor', 'isRequestSchema']
|
||||
})
|
||||
@Reflect.metadata('parameters', [[SchemaManager], [ElementRef]])
|
||||
export class JsonSchema extends BaseComponent {
|
||||
|
@ -53,8 +53,8 @@ export class JsonSchema extends BaseComponent {
|
|||
|
||||
let schema = this.componentSchema;
|
||||
BaseComponent.joinAllOf(schema, {omitParent: true});
|
||||
schema = this.unwrapArray(schema);
|
||||
runInjectors(schema, schema, schema._pointer || this.pointer);
|
||||
this.schema = schema = this.unwrapArray(schema);
|
||||
runInjectors(schema, schema, schema._pointer || this.pointer, this.pointer);
|
||||
|
||||
schema.derived = schema.derived || [];
|
||||
|
||||
|
@ -62,7 +62,6 @@ export class JsonSchema extends BaseComponent {
|
|||
this.prepareObjectPropertiesData(schema);
|
||||
}
|
||||
|
||||
this.schema = schema;
|
||||
this.initDerived();
|
||||
}
|
||||
|
||||
|
@ -119,7 +118,8 @@ export class JsonSchema extends BaseComponent {
|
|||
let discrProp = props.splice(discriminatorFieldIdx, 1);
|
||||
props.push(discrProp[0]);
|
||||
}
|
||||
if (this.skipReadOnly) {
|
||||
// filter readOnly props for request schemas
|
||||
if (this.isRequestSchema) {
|
||||
props = props.filter(prop => !prop.readOnly);
|
||||
}
|
||||
schema.properties = props;
|
||||
|
@ -131,21 +131,21 @@ export class JsonSchema extends BaseComponent {
|
|||
JsonPointer.join(addProps._pointer || schema._pointer || this.pointer, ['additionalProperties']));
|
||||
}
|
||||
|
||||
static injectPropertyData(propertySchema, propertyName, propPointer) {
|
||||
static injectPropertyData(propertySchema, propertyName, propPointer, hostPointer) {
|
||||
propertySchema = Object.assign({}, propertySchema);
|
||||
|
||||
propertySchema._name = propertyName;
|
||||
runInjectors(propertySchema, propertySchema, propPointer);
|
||||
runInjectors(propertySchema, propertySchema, propPointer, hostPointer);
|
||||
|
||||
return propertySchema;
|
||||
}
|
||||
}
|
||||
|
||||
function runInjectors(injectTo, propertySchema, propertyPointer) {
|
||||
function runInjectors(injectTo, propertySchema, propertyPointer, hostPointer) {
|
||||
for (var injName in injectors) {
|
||||
let injector = injectors[injName];
|
||||
if (injector.check(propertySchema)) {
|
||||
injector.inject(injectTo, propertySchema, propertyPointer);
|
||||
injector.inject(injectTo, propertySchema, propertyPointer, hostPointer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +183,6 @@ const injectors = {
|
|||
runInjectors(injectTo, propertySchema.items, propPointer);
|
||||
}
|
||||
},
|
||||
|
||||
object: {
|
||||
check: (propertySchema) => {
|
||||
return propertySchema.type === 'object' && propertySchema.properties;
|
||||
|
@ -201,7 +200,6 @@ const injectors = {
|
|||
injectTo.isTrivial = true;
|
||||
}
|
||||
},
|
||||
|
||||
simpleType: {
|
||||
check: (propertySchema) => {
|
||||
if (propertySchema.type === 'object') {
|
||||
|
@ -258,5 +256,23 @@ const injectors = {
|
|||
injectTo._range = range + ' characters';
|
||||
}
|
||||
}
|
||||
},
|
||||
file: {
|
||||
check: propertySchema => (propertySchema.type === 'file'),
|
||||
inject: (injectTo, propertySchema = injectTo, propPointer, hostPointer) => {
|
||||
injectTo.isFile = true;
|
||||
let parentPtr;
|
||||
if (propertySchema.in === 'formData') {
|
||||
parentPtr = JsonPointer.dirName(hostPointer, 1);
|
||||
} else {
|
||||
parentPtr = JsonPointer.dirName(hostPointer, 3);
|
||||
}
|
||||
|
||||
let parentParam = SchemaManager.instance().byPointer(parentPtr);
|
||||
let root = SchemaManager.instance().schema;
|
||||
injectTo._produces = parentParam && parentParam.produces || root.produces;
|
||||
injectTo._consumes = parentParam && parentParam.consumes || root.consumes;
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<div class="body-param-description" innerHtml="{{data.bodyParam.description | marked}}"></div>
|
||||
<div>
|
||||
<br>
|
||||
<json-schema-lazy [skipReadOnly]="true" [auto]="true" pointer="{{data.bodyParam.pointer}}/schema">
|
||||
<json-schema-lazy [isRequestSchema]="true" [auto]="true" pointer="{{data.bodyParam.pointer}}/schema">
|
||||
</json-schema-lazy>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -27,7 +27,7 @@ export class ParamsList extends BaseComponent {
|
|||
paramsList = paramsList.map((paramData) => {
|
||||
let propPointer = paramData._pointer;
|
||||
if (paramData.in === 'body') return paramData;
|
||||
return JsonSchema.injectPropertyData(paramData, paramData.name, propPointer);
|
||||
return JsonSchema.injectPropertyData(paramData, paramData.name, propPointer, this.pointer);
|
||||
});
|
||||
|
||||
let paramsMap = this.orderParams(paramsList);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "redoc",
|
||||
"description": "Swagger-generated API Reference Documentation",
|
||||
"version": "0.9.0",
|
||||
"version": "0.10.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/Rebilly/ReDoc"
|
||||
|
|
Loading…
Reference in New Issue
Block a user