diff --git a/src/components/Operation/Operation.tsx b/src/components/Operation/Operation.tsx index c395fef348..85a6d4e92b 100644 --- a/src/components/Operation/Operation.tsx +++ b/src/components/Operation/Operation.tsx @@ -139,6 +139,7 @@ export class Operation extends React.Component { type: mapStatusCodeToType(statusCode), code: statusCode || 0, content: formatResponseContent(data, contentType), + format: contentType, }, }); }); diff --git a/src/components/ResponseSamples/DownloadResponse.tsx b/src/components/ResponseSamples/DownloadResponse.tsx index d3bb7d7a1f..2b41f7612a 100644 --- a/src/components/ResponseSamples/DownloadResponse.tsx +++ b/src/components/ResponseSamples/DownloadResponse.tsx @@ -4,14 +4,22 @@ import { OperationModel } from '../../services'; interface DownloadResponseProps { operation?: OperationModel; content: any; + format?: string; } -export const DownloadResponse = ({ operation, content }: DownloadResponseProps) => { +const getHrefTextFormat = (format?: string) => { + if (format === 'text/csv') { + return format; + } + return 'text/plain'; +}; + +export const DownloadResponse = ({ operation, content, format }: DownloadResponseProps) => { content = typeof content === 'object' && content !== null ? JSON.stringify(content) : content; const downloadItAnchor = ( download it diff --git a/src/components/ResponseSamples/ResponseSamples.tsx b/src/components/ResponseSamples/ResponseSamples.tsx index 926d73b116..dbf2390eb1 100644 --- a/src/components/ResponseSamples/ResponseSamples.tsx +++ b/src/components/ResponseSamples/ResponseSamples.tsx @@ -25,7 +25,7 @@ export class ResponseSamples extends React.Component { return response.content && response.content.hasSample; }); const hasResponseSamples = responses && responses.length > 0; - const content = customResponse?.content; + const { content, format } = customResponse || {}; const contentLength = content?.length || JSON.stringify(content)?.length || 0; const reachedMaxPayloadLength = contentLength > MAX_CONTENT_LENGTH; @@ -36,7 +36,7 @@ export class ResponseSamples extends React.Component { {l('response')}
{reachedMaxPayloadLength ? ( - + ) : ( )}