mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-09 22:40:33 +03:00
Add 200 response schema sample
This commit is contained in:
parent
25412953df
commit
d8e4063677
|
@ -21,17 +21,28 @@ h3 > span {
|
||||||
display: block;
|
display: block;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
float: left;
|
float: left;
|
||||||
padding: 0 20px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
width: 60%;
|
width: 60%;
|
||||||
|
padding: 0 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.samples {
|
.samples {
|
||||||
|
color: white;
|
||||||
width: 40%;
|
width: 40%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.samples header {
|
||||||
|
padding: 10px 20px;
|
||||||
|
font-size: 20px;
|
||||||
|
background-color: #231416;
|
||||||
|
}
|
||||||
|
|
||||||
|
.samples .snippet {
|
||||||
|
padding: 10px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.method:after {
|
.method:after {
|
||||||
content: "";
|
content: "";
|
||||||
display: table;
|
display: table;
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
<responses-list pointer="{{pointer}}/responses"> </responses-list>
|
<responses-list pointer="{{pointer}}/responses"> </responses-list>
|
||||||
</div>
|
</div>
|
||||||
<div class="samples">
|
<div class="samples">
|
||||||
|
<header> Response sample </header>
|
||||||
|
<div class="snippet">
|
||||||
|
<schema-sample pointer="{{pointer}}/responses/200/schema"> <schema-sample>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -4,12 +4,13 @@ import {JsonPointer} from '../../utils/JsonPointer';
|
||||||
import {RedocComponent, BaseComponent} from '../base';
|
import {RedocComponent, BaseComponent} from '../base';
|
||||||
import {ParamsList} from '../ParamsList/params-list';
|
import {ParamsList} from '../ParamsList/params-list';
|
||||||
import {ResponsesList} from '../ResponsesList/responses-list';
|
import {ResponsesList} from '../ResponsesList/responses-list';
|
||||||
|
import {SchemaSample} from '../SchemaSample/schema-sample';
|
||||||
|
|
||||||
@RedocComponent({
|
@RedocComponent({
|
||||||
selector: 'method',
|
selector: 'method',
|
||||||
templateUrl: './lib/components/Method/method.html',
|
templateUrl: './lib/components/Method/method.html',
|
||||||
styleUrls: ['./lib/components/Method/method.css'],
|
styleUrls: ['./lib/components/Method/method.css'],
|
||||||
directives: [ParamsList, ResponsesList]
|
directives: [ParamsList, ResponsesList, SchemaSample]
|
||||||
})
|
})
|
||||||
export class Method extends BaseComponent {
|
export class Method extends BaseComponent {
|
||||||
constructor(schemaMgr) {
|
constructor(schemaMgr) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ method {
|
||||||
|
|
||||||
.methods:before {
|
.methods:before {
|
||||||
content: "";
|
content: "";
|
||||||
background: rgb(59, 59, 105);
|
background: rgb(64, 33, 37);
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 40%;
|
width: 40%;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|
3
lib/components/SchemaSample/schema-sample.html
Normal file
3
lib/components/SchemaSample/schema-sample.html
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<div class="snippet">
|
||||||
|
<pre>{{data.sample | json}}</pre>
|
||||||
|
</div>
|
26
lib/components/SchemaSample/schema-sample.js
Normal file
26
lib/components/SchemaSample/schema-sample.js
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user