mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 10:04:08 +03:00
parent
a8a7593da2
commit
63ae2e8e94
|
@ -200,6 +200,16 @@ Extends OpenAPI [Parameter Object](http://swagger.io/specification/#parameterObj
|
||||||
###### Usage in ReDoc
|
###### Usage in ReDoc
|
||||||
`x-examples` are rendered in the JSON tab on the right panel of ReDoc.
|
`x-examples` are rendered in the JSON tab on the right panel of ReDoc.
|
||||||
|
|
||||||
|
### Response Object vendor extensions
|
||||||
|
Extneds OpeanAPI [Response Object](https://swagger.io/specification/#responseObject)
|
||||||
|
|
||||||
|
#### x-summary
|
||||||
|
| Field Name | Type | Description |
|
||||||
|
| :------------- | :------: | :---------- |
|
||||||
|
| x-summary | string | a short summary of the response |
|
||||||
|
|
||||||
|
###### Usage in ReDoc
|
||||||
|
If specified, `x-summary` is used as the response button text. Description is rendered under the button.
|
||||||
|
|
||||||
### Schema Object vendor extensions
|
### Schema Object vendor extensions
|
||||||
Extends OpenAPI [Schema Object](http://swagger.io/specification/#schemaObject)
|
Extends OpenAPI [Schema Object](http://swagger.io/specification/#schemaObject)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { DropdownOrLabel } from '../DropdownOrLabel/DropdownOrLabel';
|
||||||
import { MediaTypesSwitch } from '../MediaTypeSwitch/MediaTypesSwitch';
|
import { MediaTypesSwitch } from '../MediaTypeSwitch/MediaTypesSwitch';
|
||||||
import { Schema } from '../Schema';
|
import { Schema } from '../Schema';
|
||||||
|
|
||||||
|
import { Markdown } from '../Markdown/Markdown';
|
||||||
import { ResponseHeaders } from './ResponseHeaders';
|
import { ResponseHeaders } from './ResponseHeaders';
|
||||||
import { ResponseDetailsWrap, StyledResponseTitle } from './styled.elements';
|
import { ResponseDetailsWrap, StyledResponseTitle } from './styled.elements';
|
||||||
|
|
||||||
|
@ -18,11 +19,11 @@ export class ResponseView extends React.Component<{ response: ResponseModel }> {
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { headers, type, description, code, expanded, content } = this.props.response;
|
const { 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;
|
const empty = headers.length === 0 && mimes.length === 0 && !description;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
@ -30,13 +31,14 @@ export class ResponseView extends React.Component<{ response: ResponseModel }> {
|
||||||
onClick={this.toggle}
|
onClick={this.toggle}
|
||||||
type={type}
|
type={type}
|
||||||
empty={empty}
|
empty={empty}
|
||||||
title={description || ''}
|
title={summary || ''}
|
||||||
code={code}
|
code={code}
|
||||||
opened={expanded}
|
opened={expanded}
|
||||||
/>
|
/>
|
||||||
{expanded &&
|
{expanded &&
|
||||||
!empty && (
|
!empty && (
|
||||||
<ResponseDetailsWrap>
|
<ResponseDetailsWrap>
|
||||||
|
{description && <Markdown source={description} />}
|
||||||
<ResponseHeaders headers={headers} />
|
<ResponseHeaders headers={headers} />
|
||||||
<MediaTypesSwitch content={content} renderDropdown={this.renderDropdown}>
|
<MediaTypesSwitch content={content} renderDropdown={this.renderDropdown}>
|
||||||
{({ schema }) => {
|
{({ schema }) => {
|
||||||
|
|
|
@ -13,6 +13,7 @@ export class ResponseModel {
|
||||||
|
|
||||||
content?: MediaContentModel;
|
content?: MediaContentModel;
|
||||||
code: string;
|
code: string;
|
||||||
|
summary: string;
|
||||||
description: string;
|
description: string;
|
||||||
type: string;
|
type: string;
|
||||||
headers: FieldModel[] = [];
|
headers: FieldModel[] = [];
|
||||||
|
@ -32,7 +33,15 @@ export class ResponseModel {
|
||||||
if (info.content !== undefined) {
|
if (info.content !== undefined) {
|
||||||
this.content = new MediaContentModel(parser, info.content, false, options);
|
this.content = new MediaContentModel(parser, info.content, false, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (info['x-summary'] !== undefined) {
|
||||||
|
this.summary = info['x-summary'];
|
||||||
this.description = info.description || '';
|
this.description = info.description || '';
|
||||||
|
} else {
|
||||||
|
this.summary = info.description || '';
|
||||||
|
this.description = '';
|
||||||
|
}
|
||||||
|
|
||||||
this.type = getStatusCodeType(code, defaultAsError);
|
this.type = getStatusCodeType(code, defaultAsError);
|
||||||
|
|
||||||
const headers = info.headers;
|
const headers = info.headers;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user