Add support for collectionFormat

This commit is contained in:
Roman Hotsiy 2016-11-28 16:15:09 +02:00
parent 28ebb5c649
commit d8f08be770
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
4 changed files with 51 additions and 7 deletions

View File

@ -60,23 +60,27 @@ $sub-schema-offset: ($bullet-size / 2) + $bullet-margin;
font-weight: bold;
}
.param-type {
.param-type, .param-array-format {
vertical-align: middle;
line-height: $param-name-height;
color: rgba($black, 0.4);
font-size: 0.929em;
}
.param-type {
font-weight: normal;
&.array::before, &.tuple::before {
color: $black;
font-weight: $base-font-weight;
.param-collection-format-multi + & {
content: none;
}
}
&.array::before {
content: $array-text;
color: $black;
font-weight: $base-font-weight;
}
&.tuple::before {
content: $tuple-text;
color: $black;
font-weight: $base-font-weight;
}
&.with-hint {
@ -193,6 +197,19 @@ $sub-schema-offset: ($bullet-size / 2) + $bullet-margin;
}
}
.param-enum {
color: $text-color;
font-size: 0.95em;
&::before {
content: 'Valid values: ';
}
.param-type.array ~ &::before {
content: 'Valid items values: ';
}
}
.param-pattern {
color: $nullable-color;
white-space: nowrap;

View File

@ -12,6 +12,9 @@
</div>
<div class="param-info">
<div>
<span *ngIf='param.type === "array"' class="param-array-format param-collection-format-{{param.collectionFormat}}">
{{param | collectionFormat}}
</span>
<span class="param-type {{param.type}}" [ngClass]="{'with-hint': param._displayTypeHint}"
title="{{param._displayTypeHint}}"> {{param._displayType}} {{param._displayFormat}}</span>
<span class="param-range" *ngIf="param._range"> {{param._range}} </span>

View File

@ -18,6 +18,11 @@ header.paramType {
text-transform: capitalize;
}
.param-array-format {
color: black;
font-weight: 300;
}
// paramters can't be multilevel so table representation works for it without javascript
.params-wrap {
display: table;

View File

@ -116,6 +116,25 @@ export class EncodeURIComponentPipe implements PipeTransform {
}
}
const COLLECTION_FORMATS = {
csv: 'Comma Separated',
ssv: 'Space Separated',
tsv: 'Tab Separated',
pipes: 'Pipe Separated'
};
@Pipe({ name: 'collectionFormat' })
export class CollectionFormatPipe implements PipeTransform {
transform(param:any) {
let format = param.collectionFormat;
if (!format) format = 'csv';
if (format === 'multi') {
return 'Multiple ' + param.in + ' params of';
}
return COLLECTION_FORMATS[format];
}
}
export const REDOC_PIPES = [
JsonPointerEscapePipe, MarkedPipe, SafePipe, PrismPipe, EncodeURIComponentPipe, JsonFormatter, KeysPipe
JsonPointerEscapePipe, MarkedPipe, SafePipe, PrismPipe, EncodeURIComponentPipe, JsonFormatter, KeysPipe, CollectionFormatPipe
];