mirror of
https://github.com/Redocly/redoc.git
synced 2025-01-31 10:04:08 +03:00
fix: Only display API version if present (#773)
* Only display API version if present * Warn if `info.version` is omitted, error if `info` is missing.
This commit is contained in:
parent
c343db694e
commit
fb3cb3627b
|
@ -70,12 +70,18 @@ export class ApiInfo extends React.Component<ApiInfoProps> {
|
|||
)) ||
|
||||
null;
|
||||
|
||||
const version =
|
||||
(info.version && (
|
||||
<span>({info.version})</span>
|
||||
)) ||
|
||||
null;
|
||||
|
||||
return (
|
||||
<Section>
|
||||
<Row>
|
||||
<MiddlePanel className="api-info">
|
||||
<ApiHeader>
|
||||
{info.title} <span>({info.version})</span>
|
||||
{info.title} {version}
|
||||
</ApiHeader>
|
||||
{!hideDownloadButton && (
|
||||
<p>
|
||||
|
|
|
@ -63,6 +63,12 @@ export class OpenAPIParser {
|
|||
if (spec.openapi === undefined) {
|
||||
throw new Error('Document must be valid OpenAPI 3.0.0 definition');
|
||||
}
|
||||
if (spec.info === undefined) {
|
||||
throw new Error('OpenAPI 3.0.0 requires an `info` section');
|
||||
}
|
||||
if (spec.info.version === undefined) {
|
||||
console.warn('OpenAPI 3.0.0 requires setting a `info.version` field, ignoring.')
|
||||
}
|
||||
}
|
||||
|
||||
preprocess(spec: OpenAPISpec) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user