support x-example for parameters

closes #297
This commit is contained in:
Roman Hotsiy 2017-08-17 11:25:58 +03:00
parent b84177c157
commit f792273be8
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
5 changed files with 29 additions and 17 deletions

View File

@ -242,6 +242,7 @@ paths:
in: header in: header
required: false required: false
type: string type: string
x-example: Bearer <TOKEN>
- name: petId - name: petId
in: path in: path
description: Pet id to delete description: Pet id to delete

View File

@ -64,7 +64,8 @@ $sub-schema-offset: ($bullet-size / 2) + $bullet-margin;
font-weight: bold; font-weight: bold;
} }
.param-type, .param-array-format { .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);
@ -73,7 +74,8 @@ $sub-schema-offset: ($bullet-size / 2) + $bullet-margin;
.param-type { .param-type {
font-weight: normal; font-weight: normal;
word-break: break-all; word-break: break-all;
&.array::before, &.tuple::before { &.array::before,
&.tuple::before {
color: $black; color: $black;
font-weight: $base-font-weight; font-weight: $base-font-weight;
.param-collection-format-multi + & { .param-collection-format-multi + & {
@ -144,7 +146,6 @@ $sub-schema-offset: ($bullet-size / 2) + $bullet-margin;
} }
.param:first-of-type { .param:first-of-type {
> .param-name::before { > .param-name::before {
content: ''; content: '';
display: block; display: block;
@ -158,7 +159,6 @@ $sub-schema-offset: ($bullet-size / 2) + $bullet-margin;
.param:last-of-type, .param:last-of-type,
.param.last { .param.last {
> .param-name { > .param-name {
position: relative; position: relative;
@ -236,14 +236,24 @@ $sub-schema-offset: ($bullet-size / 2) + $bullet-margin;
} }
} }
.param-example {
font-size: 0.95em;
&::before {
content: 'Example: ';
}
}
.param-enum-value, .param-enum-value,
.param-default-value { .param-default-value,
background-color: $background-color; .param-example-value {
border: 1px solid rgba($secondary-color, 0.2); font-family: Courier, monospace;
background-color: rgba($secondary-color, 0.02);
border: 1px solid rgba($secondary-color, 0.1);
margin: 2px 3px; margin: 2px 3px;
padding: 0 5px; padding: 0.1em 0.2em 0.2em;
border-radius: 2px; border-radius: $border-radius;
color: $secondary-color; color: $text-color;
display: inline-block; display: inline-block;
min-width: 20px; min-width: 20px;
text-align: center; text-align: center;

View File

@ -22,6 +22,9 @@
<div class="param-default" *ngIf="param.default != null"> <div class="param-default" *ngIf="param.default != null">
<span class="param-default-value">{{param.default | json}}</span> <span class="param-default-value">{{param.default | json}}</span>
</div> </div>
<div class="param-example" *ngIf="param.example != null">
<span class="param-example-value">{{param.example | json}}</span>
</div>
<div *ngIf="param.enum || param._enumItem" class="param-enum"> <div *ngIf="param.enum || param._enumItem" class="param-enum">
<span *ngFor="let enumItem of param.enum" class="param-enum-value {{enumItem.type}}"> <span *ngFor="let enumItem of param.enum" class="param-enum-value {{enumItem.type}}">
{{enumItem.val | json}} {{enumItem.val | json}}

View File

@ -275,16 +275,11 @@ footer {
code { code {
font-family: Courier, monospace; font-family: Courier, monospace;
background-color: rgba(38,50,56,0.04); background-color: rgba(38,50,56,0.04);
padding: 0.1em 0 0.2em 0; padding: 0.1em 0.2em 0.2em;
font-size: 1em; font-size: 1em;
border-radius: $border-radius; border-radius: $border-radius;
color: $red; color: $red;
border: 1px solid rgba(38,50,56, 0.1); border: 1px solid rgba(38,50,56, 0.1);
&:before, &:after {
letter-spacing: -0.2em;
//content: "\00a0";
}
} }
p:last-of-type { p:last-of-type {

View File

@ -119,6 +119,9 @@ const injectors = {
injectTo._displayType = propertySchema.title ? injectTo._displayType = propertySchema.title ?
`${propertySchema.title} (${propertySchema.type})` : propertySchema.type; `${propertySchema.title} (${propertySchema.type})` : propertySchema.type;
} }
if (injectTo['x-example'] && !propertySchema.example) {
injectTo.example = propertySchema['x-example'];
}
injectTo._widgetType = 'trivial'; injectTo._widgetType = 'trivial';
} }
}, },