import * as React from 'react'; import { ShelfIcon } from '../../common-elements'; import { OperationModel } from '../../services'; import { Markdown } from '../Markdown/Markdown'; import { OptionsContext } from '../OptionsProvider'; import { SelectOnClick } from '../SelectOnClick/SelectOnClick'; import { getBasePath } from '../../utils'; import { EndpointInfo, HttpVerb, OperationEndpointWrap, ServerItem, ServerRelativeURL, ServersOverlay, ServerUrl, } from './styled.elements'; export interface EndpointProps { operation: OperationModel; hideHostname?: boolean; inverted?: boolean; } export interface EndpointState { expanded: boolean; } export class Endpoint extends React.Component { constructor(props) { super(props); this.state = { expanded: false, }; } toggle = () => { this.setState({ expanded: !this.state.expanded }); }; render() { const { operation, inverted, hideHostname } = this.props; const { expanded } = this.state; // TODO: highlight server variables, e.g. https://{user}.test.com return ( {options => ( {operation.httpVerb}{' '} {operation.path} {operation.servers.map(server => ( {hideHostname || options.hideHostname ? getBasePath(server.url) : server.url} {operation.path} ))} )} ); } }