diff --git a/docs/redoc-vendor-extensions.md b/docs/redoc-vendor-extensions.md index 4f012fd2..16909bba 100644 --- a/docs/redoc-vendor-extensions.md +++ b/docs/redoc-vendor-extensions.md @@ -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) diff --git a/src/components/Responses/Response.tsx b/src/components/Responses/Response.tsx index 6f521f4b..2404dce5 100644 --- a/src/components/Responses/Response.tsx +++ b/src/components/Responses/Response.tsx @@ -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 (
@@ -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 && ( + {description && } {({ schema }) => { diff --git a/src/services/models/Response.ts b/src/services/models/Response.ts index 3f8937cd..c18f4097 100644 --- a/src/services/models/Response.ts +++ b/src/services/models/Response.ts @@ -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;