mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-26 23:54:07 +03:00
carry out statusCodeType detection
This commit is contained in:
parent
4a53a35770
commit
16570984e0
|
@ -4,6 +4,7 @@ import {RedocComponent, BaseComponent} from '../base';
|
|||
import JsonPointer from '../../utils/JsonPointer';
|
||||
import {Tabs, Tab} from '../../common/components/Tabs/tabs';
|
||||
import SchemaSample from '../SchemaSample/schema-sample';
|
||||
import {statusCodeType} from '../../utils/helpers';
|
||||
|
||||
|
||||
function isNumeric(n) {
|
||||
|
@ -42,14 +43,7 @@ export default class ResponsesSamples extends BaseComponent {
|
|||
}
|
||||
|
||||
resp.code = respCode;
|
||||
resp.type = 'success';
|
||||
if (respCode >= 300 && respCode < 400) {
|
||||
resp.type = 'redirect';
|
||||
} else if (respCode > 400) {
|
||||
resp.type = 'error';
|
||||
} else if (respCode < 100) {
|
||||
resp.type = 'info';
|
||||
}
|
||||
resp.type = statusCodeType(resp.code);
|
||||
return resp;
|
||||
})
|
||||
.filter(response => hasExample(response));
|
||||
|
|
13
lib/utils/helpers.js
Normal file
13
lib/utils/helpers.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
export function statusCodeType(statusCode) {
|
||||
let res = 'success';
|
||||
if (statusCode >= 300 && statusCode < 400) {
|
||||
res = 'redirect';
|
||||
} else if (statusCode > 400) {
|
||||
res = 'error';
|
||||
} else if (statusCode < 100) {
|
||||
res = 'info';
|
||||
}
|
||||
return res;
|
||||
}
|
Loading…
Reference in New Issue
Block a user