redoc/src/components/Responses/ResponseHeaders.tsx
2018-07-31 16:55:06 +03:00

31 lines
901 B
TypeScript

import * as React from 'react';
import { PropertiesTable } from '../../common-elements/fields-layout';
import { FieldModel } from '../../services/models';
import { mapWithLast } from '../../utils';
import { Field } from '../Fields/Field';
import { HeadersCaption } from './styled.elements';
export interface ResponseHeadersProps {
headers?: FieldModel[];
}
export class ResponseHeaders extends React.PureComponent<ResponseHeadersProps> {
render() {
const { headers } = this.props;
if (headers === undefined || headers.length === 0) {
return null;
}
return (
<PropertiesTable>
<HeadersCaption> Response Headers </HeadersCaption>
<tbody>
{mapWithLast(headers, (header, isLast) => (
<Field isLast={isLast} key={header.name} field={header} showExamples={true} />
))}
</tbody>
</PropertiesTable>
);
}
}