mirror of
https://github.com/Redocly/redoc.git
synced 2025-07-13 17:52:26 +03:00
Add showExtentions for Responses
This commit is contained in:
parent
918e2414f6
commit
dbaab9e306
|
@ -12,11 +12,11 @@ export class ResponseView extends React.Component<{ response: ResponseModel }> {
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { headers, type, summary, description, code, expanded, content } = this.props.response;
|
const { extensions, headers, type, summary, description, code, expanded, content } = this.props.response;
|
||||||
const mimes =
|
const mimes =
|
||||||
content === undefined ? [] : content.mediaTypes.filter(mime => mime.schema !== undefined);
|
content === undefined ? [] : content.mediaTypes.filter(mime => mime.schema !== undefined);
|
||||||
|
|
||||||
const empty = headers.length === 0 && mimes.length === 0 && !description;
|
const empty = Object.keys(extensions).length === 0 && headers.length === 0 && mimes.length === 0 && !description;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -7,15 +7,17 @@ import { DropdownOrLabel } from '../DropdownOrLabel/DropdownOrLabel';
|
||||||
import { MediaTypesSwitch } from '../MediaTypeSwitch/MediaTypesSwitch';
|
import { MediaTypesSwitch } from '../MediaTypeSwitch/MediaTypesSwitch';
|
||||||
import { Schema } from '../Schema';
|
import { Schema } from '../Schema';
|
||||||
|
|
||||||
|
import { Extensions } from '../Fields/Extensions';
|
||||||
import { Markdown } from '../Markdown/Markdown';
|
import { Markdown } from '../Markdown/Markdown';
|
||||||
import { ResponseHeaders } from './ResponseHeaders';
|
import { ResponseHeaders } from './ResponseHeaders';
|
||||||
|
|
||||||
export class ResponseDetails extends React.PureComponent<{ response: ResponseModel }> {
|
export class ResponseDetails extends React.PureComponent<{ response: ResponseModel }> {
|
||||||
render() {
|
render() {
|
||||||
const { description, headers, content } = this.props.response;
|
const { description, extensions, headers, content } = this.props.response;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{description && <Markdown source={description} />}
|
{description && <Markdown source={description} />}
|
||||||
|
<Extensions extensions={extensions} />
|
||||||
<ResponseHeaders headers={headers} />
|
<ResponseHeaders headers={headers} />
|
||||||
<MediaTypesSwitch content={content} renderDropdown={this.renderDropdown}>
|
<MediaTypesSwitch content={content} renderDropdown={this.renderDropdown}>
|
||||||
{({ schema }) => {
|
{({ schema }) => {
|
||||||
|
|
|
@ -2,7 +2,10 @@ import { action, observable } from 'mobx';
|
||||||
|
|
||||||
import { OpenAPIResponse, Referenced } from '../../types';
|
import { OpenAPIResponse, Referenced } from '../../types';
|
||||||
|
|
||||||
import { getStatusCodeType } from '../../utils';
|
import {
|
||||||
|
getStatusCodeType,
|
||||||
|
extractExtensions
|
||||||
|
} from '../../utils';
|
||||||
import { OpenAPIParser } from '../OpenAPIParser';
|
import { OpenAPIParser } from '../OpenAPIParser';
|
||||||
import { RedocNormalizedOptions } from '../RedocNormalizedOptions';
|
import { RedocNormalizedOptions } from '../RedocNormalizedOptions';
|
||||||
import { FieldModel } from './Field';
|
import { FieldModel } from './Field';
|
||||||
|
@ -19,6 +22,8 @@ export class ResponseModel {
|
||||||
type: string;
|
type: string;
|
||||||
headers: FieldModel[] = [];
|
headers: FieldModel[] = [];
|
||||||
|
|
||||||
|
extensions: Record<string, any>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
parser: OpenAPIParser,
|
parser: OpenAPIParser,
|
||||||
code: string,
|
code: string,
|
||||||
|
@ -52,6 +57,10 @@ export class ResponseModel {
|
||||||
return new FieldModel(parser, { ...header, name }, '', options);
|
return new FieldModel(parser, { ...header, name }, '', options);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.showExtensions) {
|
||||||
|
this.extensions = extractExtensions(info, options.showExtensions);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
|
Loading…
Reference in New Issue
Block a user