From 3f698caabe6a8544c62d457ff94041a052c0ba17 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 2 Mar 2016 08:56:09 +0400 Subject: [PATCH 1/4] Fix required for JsonSchema component (fixes #28) --- lib/components/JsonSchema/json-schema.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index b8d0dbb1..c946a96c 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -59,8 +59,8 @@ export default class JsonSchema extends BaseComponent { this.pointer = schema._pointer || this.pointer; this.requiredMap = {}; - if (this.schema.required) { - this.schema.required.forEach(prop => this.requiredMap[prop] = true); + if (this.componentSchema.required) { + this.componentSchema.required.forEach(prop => this.requiredMap[prop] = true); } if (!schema.properties) { From 0a8440f44ba02e0866e28f35281eb40887e926ec Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 9 Mar 2016 00:28:55 +0200 Subject: [PATCH 2/4] Fix treating refereced schemas with simple types (string, integer) as nested --- lib/components/JsonSchema/json-schema.js | 15 +++++++++------ lib/components/ParamsList/params-list.js | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/lib/components/JsonSchema/json-schema.js b/lib/components/JsonSchema/json-schema.js index c946a96c..fcb9acb8 100644 --- a/lib/components/JsonSchema/json-schema.js +++ b/lib/components/JsonSchema/json-schema.js @@ -108,15 +108,18 @@ export default class JsonSchema extends BaseComponent { propData.format = itemFormat; propData._isArray = true; propData.type = 'array ' + propData.items.type; - } - - if (propData.type === 'object') { + } else if (propData.type === 'object') { propData._displayType = propData.title || 'object'; - } - - if (!propData.type) { + } else if (!propData.type) { propData._displayType = '< * >'; propData._displayTypeHint = 'This field may contain data of any type'; + } else { + // here we are sure that property has simple type + // delete pointer for simple types to not show it as subschema + if (propData._pointer) { + propData._pointer = undefined; + propData._displayType = propData.title ? `${propData.title} (${propData.type})` : propData.type; + } } if (propData.format) propData._displayFormat = `<${propData.format}>`; diff --git a/lib/components/ParamsList/params-list.js b/lib/components/ParamsList/params-list.js index 1a053b5b..957d18b4 100644 --- a/lib/components/ParamsList/params-list.js +++ b/lib/components/ParamsList/params-list.js @@ -26,6 +26,7 @@ export default class ParamsList extends BaseComponent { paramsList = paramsList.map((paramData) => { let propPointer = paramData._pointer; + if (paramData.in === 'body') return paramData; return JsonSchema.injectPropData(paramData, paramData.name, propPointer); }); @@ -35,7 +36,7 @@ export default class ParamsList extends BaseComponent { let bodyParam = paramsMap.body[0]; bodyParam.pointer = bodyParam._pointer; this.data.bodyParam = bodyParam; - delete paramsMap.body; + paramsMap.body = undefined; } this.data.noParams = !(Object.keys(paramsMap).length || this.data.bodyParam); From 7d7877da2e71c976aa1b79916822b83520ca77d9 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Wed, 9 Mar 2016 20:44:20 +0200 Subject: [PATCH 3/4] Fix links with spaces --- lib/components/Method/method.html | 2 +- lib/components/Method/method.js | 4 +++- lib/components/MethodsList/methods-list.html | 2 +- lib/components/MethodsList/methods-list.js | 4 +++- lib/components/SideMenu/side-menu.js | 2 +- lib/utils/pipes.js | 11 +++++++++++ 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/components/Method/method.html b/lib/components/Method/method.html index 1a428a93..c8fc86c2 100644 --- a/lib/components/Method/method.html +++ b/lib/components/Method/method.html @@ -1,7 +1,7 @@

- {{data.methodInfo.summary}} + {{data.methodInfo.summary}}

{{data.httpMethod}} diff --git a/lib/components/Method/method.js b/lib/components/Method/method.js index fdad9d66..5a8ea3c3 100644 --- a/lib/components/Method/method.js +++ b/lib/components/Method/method.js @@ -8,13 +8,15 @@ import ResponsesList from '../ResponsesList/responses-list'; import ResponsesSamples from '../ResponsesSamples/responses-samples'; import SchemaSample from '../SchemaSample/schema-sample'; import RequestSamples from '../RequestSamples/request-samples'; +import {EncodeURIComponentPipe} from '../../utils/pipes'; @RedocComponent({ selector: 'method', templateUrl: './lib/components/Method/method.html', styleUrls: ['./lib/components/Method/method.css'], directives: [ParamsList, ResponsesList, ResponsesSamples, SchemaSample, RequestSamples], - inputs: ['tag'] + inputs: ['tag'], + pipes: [EncodeURIComponentPipe] }) export default class Method extends BaseComponent { constructor(schemaMgr) { diff --git a/lib/components/MethodsList/methods-list.html b/lib/components/MethodsList/methods-list.html index 10e0ccf6..86a00c90 100644 --- a/lib/components/MethodsList/methods-list.html +++ b/lib/components/MethodsList/methods-list.html @@ -1,7 +1,7 @@
-

{{tag.name}}

+

{{tag.name}}

Date: Wed, 9 Mar 2016 20:49:54 +0200 Subject: [PATCH 4/4] v0.6.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3941db64..bcf3fe6d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "redoc", "description": "Swagger-generated API Reference Documentation", - "version": "0.6.2", + "version": "0.6.3", "repository": { "type": "git", "url": "git://github.com/Rebilly/ReDoc"