mirror of
https://github.com/Redocly/redoc.git
synced 2025-05-30 10:43:04 +03:00
Added responses list
This commit is contained in:
parent
8c54d83ee8
commit
93d7d98ad7
|
@ -1,3 +1,7 @@
|
||||||
|
responses-list, params-list {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
font-size: 32px;
|
font-size: 32px;
|
||||||
font-weight: 200;
|
font-weight: 200;
|
||||||
|
|
|
@ -7,3 +7,5 @@
|
||||||
{{data.methodInfo.description}}
|
{{data.methodInfo.description}}
|
||||||
</p>
|
</p>
|
||||||
<params-list pointer="{{pointer}}/parameters"> </params-list>
|
<params-list pointer="{{pointer}}/parameters"> </params-list>
|
||||||
|
<br>
|
||||||
|
<responses-list pointer="{{pointer}}/responses"> </responses-list>
|
||||||
|
|
|
@ -3,12 +3,13 @@
|
||||||
import {JsonPointer} from '../../utils/JsonPointer';
|
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';
|
||||||
|
|
||||||
@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]
|
directives: [ParamsList, ResponsesList]
|
||||||
})
|
})
|
||||||
export class Method extends BaseComponent {
|
export class Method extends BaseComponent {
|
||||||
constructor(schemaMgr) {
|
constructor(schemaMgr) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ h4 {
|
||||||
}
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
|
width: 100%;
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
border: 2px solid #1976D3;
|
border: 2px solid #1976D3;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
<small class="no-params" *ng-if="data.noParams"> No parameters </small>
|
<small class="no-params" *ng-if="data.noParams"> No parameters </small>
|
||||||
<!-- General parameters -->
|
<!-- General parameters -->
|
||||||
<table *ng-if="!data.noParams">
|
<table *ng-if="!data.noParams" class="inline">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="3"> Parameters </th>
|
<th colspan="3"> Parameters </th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th> Name </th>
|
<th> Name </th>
|
||||||
<th> Type </th>
|
|
||||||
<th> Description </th>
|
<th> Description </th>
|
||||||
|
<th> Type </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ng-for="#param of data.params">
|
<tr *ng-for="#param of data.params">
|
||||||
<!--<div class="param">-->
|
<!--<div class="param">-->
|
||||||
<td class="param-name">{{param.name}}</td>
|
<td class="param-name">{{param.name}}</td>
|
||||||
<td>
|
|
||||||
<span class="param-type" [ng-class]="param.type">{{param.type}}</span>
|
|
||||||
</td>
|
|
||||||
<td class="param-description">{{param.description}}</td>
|
<td class="param-description">{{param.description}}</td>
|
||||||
|
<td>
|
||||||
|
<span class="type" [ng-class]="param.type">{{param.type}}</span>
|
||||||
|
</td>
|
||||||
<!--</div>-->
|
<!--</div>-->
|
||||||
</tr>
|
</tr>
|
||||||
<!-- in-body parameter -->
|
<!-- in-body parameter -->
|
||||||
|
|
32
lib/components/ResponsesList/responses-list.css
Normal file
32
lib/components/ResponsesList/responses-list.css
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-spacing: 0;
|
||||||
|
border: 2px solid green;
|
||||||
|
}
|
||||||
|
|
||||||
|
thead tr:first-child {
|
||||||
|
background: green;
|
||||||
|
color: #fff;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
thead tr:last-child th {
|
||||||
|
border-bottom: 3px solid #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbody tr:last-child td {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
tbody td {
|
||||||
|
border-bottom: 1px solid #ddd;
|
||||||
|
}
|
||||||
|
|
||||||
|
td, th {
|
||||||
|
vertical-align: top;
|
||||||
|
padding: 10px 15px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
text-align: left;
|
||||||
|
}
|
22
lib/components/ResponsesList/responses-list.html
Normal file
22
lib/components/ResponsesList/responses-list.html
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<table class="inline">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="3"> Responses </th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th> Response code </th>
|
||||||
|
<th> Description </th>
|
||||||
|
<th> Response schema </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ng-for="#response of data.responses">
|
||||||
|
<td>{{response.code}}</td>
|
||||||
|
<td>{{response.description}}</td>
|
||||||
|
<td>
|
||||||
|
<schema *ng-if="response.schema" class="schema type" pointer="{{response.pointer}}/schema">
|
||||||
|
</schema>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
42
lib/components/ResponsesList/responses-list.js
Normal file
42
lib/components/ResponsesList/responses-list.js
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
import {RedocComponent, BaseComponent} from '../base';
|
||||||
|
import {JsonPointer} from '../../utils/JsonPointer';
|
||||||
|
import {JsonSchemaView} from '../JsonSchemaView/json-schema-view';
|
||||||
|
|
||||||
|
function isNumeric(n) {
|
||||||
|
return (!isNaN(parseFloat(n)) && isFinite(n));
|
||||||
|
}
|
||||||
|
|
||||||
|
@RedocComponent({
|
||||||
|
selector: 'responses-list',
|
||||||
|
templateUrl: './lib/components/ResponsesList/responses-list.html',
|
||||||
|
styleUrls: ['./lib/components/ResponsesList/responses-list.css'],
|
||||||
|
directives: [JsonSchemaView]
|
||||||
|
})
|
||||||
|
export class ResponsesList extends BaseComponent {
|
||||||
|
constructor(schemaMgr) {
|
||||||
|
super(schemaMgr);
|
||||||
|
}
|
||||||
|
|
||||||
|
prepareModel() {
|
||||||
|
this.data = {};
|
||||||
|
let responses = this.componentSchema;
|
||||||
|
responses = Object.keys(responses).filter(respCode => {
|
||||||
|
// only response-codes and "default"
|
||||||
|
return ( isNumeric(respCode) || (respCode === 'default'));
|
||||||
|
}).map(respCode => {
|
||||||
|
let resp = responses[respCode];
|
||||||
|
resp.pointer = JsonPointer.join(this.pointer, respCode);
|
||||||
|
if (resp.$ref) {
|
||||||
|
let ref = resp.$ref;
|
||||||
|
resp = this.schemaMgr.byPointer(resp.$ref);
|
||||||
|
resp.pointer = ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.code = respCode;
|
||||||
|
return resp;
|
||||||
|
});
|
||||||
|
this.data.responses = responses;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user