mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-04 20:10:34 +03:00
Add 200 response schema sample
This commit is contained in:
parent
25412953df
commit
d8e4063677
|
@ -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;
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -11,7 +11,7 @@ method {
|
|||
|
||||
.methods:before {
|
||||
content: "";
|
||||
background: rgb(59, 59, 105);
|
||||
background: rgb(64, 33, 37);
|
||||
height: 100%;
|
||||
width: 40%;
|
||||
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