import React from "react" import PropTypes from "prop-types" import ImPropTypes from "react-immutable-proptypes" import { sanitizeUrl } from "core/utils" import { safeBuildUrl } from "core/utils/url" import { OAS3ComponentWrapFactory } from "../helpers" const Info = (props) => { const { info, url, host, basePath, getComponent, specSelectors, externalDocs, selectedServer, url: specUrl } = props const isOpenAPI31 = specSelectors.selectIsOpenAPI31() const version = info.get("version") const description = info.get("description") const title = info.get("title") const termsOfServiceUrl = safeBuildUrl(info.get("termsOfService"), specUrl, { selectedServer }) const contact = info.get("contact") const license = info.get("license") // note that ux may want to move summary to a sub-heading, as summary is a string that does not need to be Markdown const summary = info.get("summary") // OAS3.1 field const rawExternalDocsUrl = externalDocs && externalDocs.get("url") const externalDocsUrl = safeBuildUrl(rawExternalDocsUrl, specUrl, { selectedServer }) const externalDocsDescription = externalDocs && externalDocs.get("description") const Markdown = getComponent("Markdown", true) const Link = getComponent("Link") const VersionStamp = getComponent("VersionStamp") const InfoUrl = getComponent("InfoUrl") const InfoBasePath = getComponent("InfoBasePath") const License = getComponent("License") const Contact = getComponent("Contact") return (

{title} {version && }

{host || basePath ? : null} {url && }
{ isOpenAPI31 && summary &&
}
{ termsOfServiceUrl &&
Terms of service
} {contact && contact.size ? : null} {license && license.size ? : null} {externalDocsUrl ? {externalDocsDescription || externalDocsUrl} : null}
) } Info.propTypes = { info: PropTypes.object, url: PropTypes.string, host: PropTypes.string, basePath: PropTypes.string, externalDocs: ImPropTypes.map, getComponent: PropTypes.func.isRequired, specSelectors: PropTypes.object.isRequired, oas3selectors: PropTypes.func, selectedServer: PropTypes.string, } export default OAS3ComponentWrapFactory(Info)