Add 200 response schema sample

This commit is contained in:
Roman Gotsiy 2015-10-21 17:24:04 +03:00
parent 25412953df
commit d8e4063677
6 changed files with 48 additions and 4 deletions

View File

@ -21,17 +21,28 @@ h3 > span {
display: block;
box-sizing: border-box;
float: left;
padding: 0 20px;
}
.content {
width: 60%;
padding: 0 20px;
}
.samples {
color: white;
width: 40%;
}
.samples header {
padding: 10px 20px;
font-size: 20px;
background-color: #231416;
}
.samples .snippet {
padding: 10px 20px;
}
.method:after {
content: "";
display: table;

View File

@ -14,6 +14,9 @@
<responses-list pointer="{{pointer}}/responses"> </responses-list>
</div>
<div class="samples">
<header> Response sample </header>
<div class="snippet">
<schema-sample pointer="{{pointer}}/responses/200/schema"> <schema-sample>
</div>
</div>
<div>

View File

@ -4,12 +4,13 @@ import {JsonPointer} from '../../utils/JsonPointer';
import {RedocComponent, BaseComponent} from '../base';
import {ParamsList} from '../ParamsList/params-list';
import {ResponsesList} from '../ResponsesList/responses-list';
import {SchemaSample} from '../SchemaSample/schema-sample';
@RedocComponent({
selector: 'method',
templateUrl: './lib/components/Method/method.html',
styleUrls: ['./lib/components/Method/method.css'],
directives: [ParamsList, ResponsesList]
directives: [ParamsList, ResponsesList, SchemaSample]
})
export class Method extends BaseComponent {
constructor(schemaMgr) {

View File

@ -11,7 +11,7 @@ method {
.methods:before {
content: "";
background: rgb(59, 59, 105);
background: rgb(64, 33, 37);
height: 100%;
width: 40%;
top: 0;

View File

@ -0,0 +1,3 @@
<div class="snippet">
<pre>{{data.sample | json}}</pre>
</div>

View File

@ -0,0 +1,26 @@
'use strict';
import {RedocComponent, BaseComponent} from '../base';
import SchemaSampler from 'json-schema-instantiator';
@RedocComponent({
selector: 'schema-sample',
templateUrl: './lib/components/SchemaSample/schema-sample.html'
})
export class SchemaSample extends BaseComponent {
constructor(schemaMgr) {
super(schemaMgr);
}
init() {
this.data = {};
if (!this.componentSchema || !this.pointer) {
console.log(this.pointer);
return;
}
this.dereference();
let sample = SchemaSampler.instantiate(this.componentSchema);
this.data.sample = sample;
}
}