mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-07 21:40:32 +03:00
Add support for collectionFormat
This commit is contained in:
parent
28ebb5c649
commit
d8f08be770
|
@ -60,23 +60,27 @@ $sub-schema-offset: ($bullet-size / 2) + $bullet-margin;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.param-type {
|
.param-type, .param-array-format {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
line-height: $param-name-height;
|
line-height: $param-name-height;
|
||||||
color: rgba($black, 0.4);
|
color: rgba($black, 0.4);
|
||||||
font-size: 0.929em;
|
font-size: 0.929em;
|
||||||
|
}
|
||||||
|
.param-type {
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
|
&.array::before, &.tuple::before {
|
||||||
|
color: $black;
|
||||||
|
font-weight: $base-font-weight;
|
||||||
|
.param-collection-format-multi + & {
|
||||||
|
content: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.array::before {
|
&.array::before {
|
||||||
content: $array-text;
|
content: $array-text;
|
||||||
color: $black;
|
|
||||||
font-weight: $base-font-weight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.tuple::before {
|
&.tuple::before {
|
||||||
content: $tuple-text;
|
content: $tuple-text;
|
||||||
color: $black;
|
|
||||||
font-weight: $base-font-weight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&.with-hint {
|
&.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 {
|
.param-pattern {
|
||||||
color: $nullable-color;
|
color: $nullable-color;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="param-info">
|
<div class="param-info">
|
||||||
<div>
|
<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}"
|
<span class="param-type {{param.type}}" [ngClass]="{'with-hint': param._displayTypeHint}"
|
||||||
title="{{param._displayTypeHint}}"> {{param._displayType}} {{param._displayFormat}}</span>
|
title="{{param._displayTypeHint}}"> {{param._displayType}} {{param._displayFormat}}</span>
|
||||||
<span class="param-range" *ngIf="param._range"> {{param._range}} </span>
|
<span class="param-range" *ngIf="param._range"> {{param._range}} </span>
|
||||||
|
|
|
@ -18,6 +18,11 @@ header.paramType {
|
||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.param-array-format {
|
||||||
|
color: black;
|
||||||
|
font-weight: 300;
|
||||||
|
}
|
||||||
|
|
||||||
// paramters can't be multilevel so table representation works for it without javascript
|
// paramters can't be multilevel so table representation works for it without javascript
|
||||||
.params-wrap {
|
.params-wrap {
|
||||||
display: table;
|
display: table;
|
||||||
|
|
|
@ -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 = [
|
export const REDOC_PIPES = [
|
||||||
JsonPointerEscapePipe, MarkedPipe, SafePipe, PrismPipe, EncodeURIComponentPipe, JsonFormatter, KeysPipe
|
JsonPointerEscapePipe, MarkedPipe, SafePipe, PrismPipe, EncodeURIComponentPipe, JsonFormatter, KeysPipe, CollectionFormatPipe
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user