From 7278110e5806582deeb75fa104135121ea02de1c Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Tue, 10 May 2016 12:32:54 +0300 Subject: [PATCH 1/3] minor fix deploy to gh-pages --- build/prepare_deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/prepare_deploy.sh b/build/prepare_deploy.sh index 71a8562b..1854e62c 100755 --- a/build/prepare_deploy.sh +++ b/build/prepare_deploy.sh @@ -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 - From 3f725056ed3cedc22ff00351f488ce081e65f1fe Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 11 May 2016 15:41:35 +0300 Subject: [PATCH 2/3] Add tested on APIs.guru badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e8376d83..a4c4908a 100644 --- a/README.md +++ b/README.md @@ -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) From 547cf0ceab84d2bbe782bcc4b30d045c67184acb Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Mon, 16 May 2016 23:02:23 +0300 Subject: [PATCH 3/3] Add type:file support for payloads --- lib/components/JsonSchema/json-schema-lazy.js | 4 +- lib/components/JsonSchema/json-schema.html | 15 ++++++-- lib/components/JsonSchema/json-schema.js | 38 +++++++++++++------ lib/components/ParamsList/params-list.html | 2 +- lib/components/ParamsList/params-list.js | 2 +- package.json | 2 +- 6 files changed, 44 insertions(+), 19 deletions(-) diff --git a/lib/components/JsonSchema/json-schema-lazy.js b/lib/components/JsonSchema/json-schema-lazy.js index d532ef6a..b03b66ec 100644 --- a/lib/components/JsonSchema/json-schema-lazy.js +++ b/lib/components/JsonSchema/json-schema-lazy.js @@ -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() { diff --git a/lib/components/JsonSchema/json-schema.html b/lib/components/JsonSchema/json-schema.html index 17f56144..b0d735e8 100644 --- a/lib/components/JsonSchema/json-schema.html +++ b/lib/components/JsonSchema/json-schema.html @@ -1,4 +1,13 @@ - + + file +
+ Produces: {{ schema._produces | json }} +
+
+ Consumes: {{ schema._consumes | json }} +
+
+ {{schema._displayType}} {{schema._displayFormat}} @@ -43,7 +52,7 @@ + [nestOdd]="!nestOdd" [isRequestSchema]="isRequestSchema" [attr.nesteven]="!nestOdd"> @@ -52,7 +61,7 @@
+ pointer="{{derived.$ref}}" [final]="derived.final" [isRequestSchema]="isRequestSchema">
diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index a4deef6c..2b399a10 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -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; + + } } }; diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html index fa673090..62117c4c 100644 --- a/lib/components/ParamsList/params-list.html +++ b/lib/components/ParamsList/params-list.html @@ -31,7 +31,7 @@

- +
diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.js index 51486cfc..99b147c2 100644 --- a/lib/components/ParamsList/params-list.js +++ b/lib/components/ParamsList/params-list.js @@ -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); diff --git a/package.json b/package.json index 718acfda..51f333c6 100644 --- a/package.json +++ b/package.json @@ -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"