From f98cb9a3fe021f7268948439eca0984b50519322 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Thu, 28 Jul 2016 07:24:12 +0300 Subject: [PATCH] Render json-schema constrains for headers (fixes #47) --- lib/components/ParamsList/params-list.html | 1 + lib/components/ParamsList/params-list.ts | 2 +- .../ResponsesList/responses-list.html | 7 ++++++- .../ResponsesList/responses-list.scss | 17 +++++++++++++++++ lib/components/ResponsesList/responses-list.ts | 3 ++- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib/components/ParamsList/params-list.html b/lib/components/ParamsList/params-list.html index 36cc6f28..6601e4dc 100644 --- a/lib/components/ParamsList/params-list.html +++ b/lib/components/ParamsList/params-list.html @@ -14,6 +14,7 @@
{{param._displayType}} {{param._displayFormat}} + {{param._range}} Required
Default: {{param.default | json}}
diff --git a/lib/components/ParamsList/params-list.ts b/lib/components/ParamsList/params-list.ts index 9165e26b..98116eef 100644 --- a/lib/components/ParamsList/params-list.ts +++ b/lib/components/ParamsList/params-list.ts @@ -34,7 +34,7 @@ export class ParamsList extends BaseComponent { let propPointer = paramSchema._pointer; if (paramSchema.in === 'body') return paramSchema; paramSchema._name = paramSchema.name; - return SchemaHelper.preprocess(paramSchema,propPointer, this.pointer); + return SchemaHelper.preprocess(paramSchema, propPointer, this.pointer); }); let paramsMap = this.orderParams(paramsList); diff --git a/lib/components/ResponsesList/responses-list.html b/lib/components/ResponsesList/responses-list.html index 2e1cd65e..853c1de1 100644 --- a/lib/components/ResponsesList/responses-list.html +++ b/lib/components/ResponsesList/responses-list.html @@ -7,8 +7,13 @@
{{header.name}}
-
{{header.type}}
+
{{header._displayType}} {{header._displayFormat}} + {{header._range}} +
Default: {{header.default}}
+
+ {{enumItem.val | json}} +
diff --git a/lib/components/ResponsesList/responses-list.scss b/lib/components/ResponsesList/responses-list.scss index 49cab871..34063c49 100644 --- a/lib/components/ResponsesList/responses-list.scss +++ b/lib/components/ResponsesList/responses-list.scss @@ -38,3 +38,20 @@ header { .header { margin-bottom: 10px; } + +.header-range { + position: relative; + top: 1px; + margin-right: 6px; + margin-left: 6px; + border-radius: $border-radius; + background-color: rgba($primary-color, .1); + padding: 0 4px; + color: rgba($primary-color, 0.7); +} + +.header-type.array:before { + content: "Array of "; + color: $black; + font-weight: $base-font-weight; +} diff --git a/lib/components/ResponsesList/responses-list.ts b/lib/components/ResponsesList/responses-list.ts index 9d4d91e8..a9227672 100644 --- a/lib/components/ResponsesList/responses-list.ts +++ b/lib/components/ResponsesList/responses-list.ts @@ -7,6 +7,7 @@ import { JsonSchemaLazy } from '../JsonSchema/json-schema-lazy'; import { Zippy } from '../../shared/components/index'; import { statusCodeType } from '../../utils/helpers'; import { OptionsService } from '../../services/index'; +import { SchemaHelper } from '../../services/schema-helper.service'; function isNumeric(n) { return (!isNaN(parseFloat(n)) && isFinite(n)); @@ -52,7 +53,7 @@ export class ResponsesList extends BaseComponent { resp.headers = Object.keys(resp.headers).map((k) => { let respInfo = resp.headers[k]; respInfo.name = k; - return respInfo; + return SchemaHelper.preprocess(respInfo, this.pointer, this.pointer); }); resp.empty = false; }