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
|
||||
`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
|
||||
Extends OpenAPI [Schema Object](http://swagger.io/specification/#schemaObject)
|
||||
|
|
|
@ -8,6 +8,7 @@ import { DropdownOrLabel } from '../DropdownOrLabel/DropdownOrLabel';
|
|||
import { MediaTypesSwitch } from '../MediaTypeSwitch/MediaTypesSwitch';
|
||||
import { Schema } from '../Schema';
|
||||
|
||||
import { Markdown } from '../Markdown/Markdown';
|
||||
import { ResponseHeaders } from './ResponseHeaders';
|
||||
import { ResponseDetailsWrap, StyledResponseTitle } from './styled.elements';
|
||||
|
||||
|
@ -18,11 +19,11 @@ export class ResponseView extends React.Component<{ response: ResponseModel }> {
|
|||
};
|
||||
|
||||
render() {
|
||||
const { headers, type, description, code, expanded, content } = this.props.response;
|
||||
const { headers, type, summary, description, code, expanded, content } = this.props.response;
|
||||
const mimes =
|
||||
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 (
|
||||
<div>
|
||||
|
@ -30,13 +31,14 @@ export class ResponseView extends React.Component<{ response: ResponseModel }> {
|
|||
onClick={this.toggle}
|
||||
type={type}
|
||||
empty={empty}
|
||||
title={description || ''}
|
||||
title={summary || ''}
|
||||
code={code}
|
||||
opened={expanded}
|
||||
/>
|
||||
{expanded &&
|
||||
!empty && (
|
||||
<ResponseDetailsWrap>
|
||||
{description && <Markdown source={description} />}
|
||||
<ResponseHeaders headers={headers} />
|
||||
<MediaTypesSwitch content={content} renderDropdown={this.renderDropdown}>
|
||||
{({ schema }) => {
|
||||
|
|
|
@ -13,6 +13,7 @@ export class ResponseModel {
|
|||
|
||||
content?: MediaContentModel;
|
||||
code: string;
|
||||
summary: string;
|
||||
description: string;
|
||||
type: string;
|
||||
headers: FieldModel[] = [];
|
||||
|
@ -32,7 +33,15 @@ export class ResponseModel {
|
|||
if (info.content !== undefined) {
|
||||
this.content = new MediaContentModel(parser, info.content, false, options);
|
||||
}
|
||||
this.description = info.description || '';
|
||||
|
||||
if (info['x-summary'] !== undefined) {
|
||||
this.summary = info['x-summary'];
|
||||
this.description = info.description || '';
|
||||
} else {
|
||||
this.summary = info.description || '';
|
||||
this.description = '';
|
||||
}
|
||||
|
||||
this.type = getStatusCodeType(code, defaultAsError);
|
||||
|
||||
const headers = info.headers;
|
||||
|
|
Loading…
Reference in New Issue
Block a user