2017-11-14 18:46:50 +03:00
|
|
|
import * as React from 'react';
|
|
|
|
|
|
|
|
import { ThemeInterface } from '../theme';
|
|
|
|
|
|
|
|
import { LoadingWrap } from './LoadingWrap/LoadingWrap';
|
|
|
|
import { StoreProvider } from './StoreProvider';
|
|
|
|
import { ErrorBoundary } from './ErrorBoundary';
|
|
|
|
import { Redoc } from './Redoc/Redoc';
|
|
|
|
|
2017-11-19 22:27:44 +03:00
|
|
|
export interface RedocStandaloneProps {
|
2017-11-14 18:46:50 +03:00
|
|
|
specOrSpecUrl: string | object;
|
|
|
|
options?: {
|
|
|
|
theme?: ThemeInterface;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-11-19 22:27:44 +03:00
|
|
|
export class RedocStandalone extends React.Component<RedocStandaloneProps> {
|
2017-11-14 18:46:50 +03:00
|
|
|
render() {
|
|
|
|
const { specOrSpecUrl, options } = this.props;
|
|
|
|
let specUrl;
|
|
|
|
let spec;
|
|
|
|
|
|
|
|
if (typeof specOrSpecUrl === 'string') {
|
|
|
|
specUrl = specOrSpecUrl;
|
|
|
|
} else if (typeof specOrSpecUrl === 'object') {
|
|
|
|
spec = specOrSpecUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ErrorBoundary>
|
|
|
|
<StoreProvider spec={spec} specUrl={specUrl}>
|
|
|
|
{({ loading, store }) => (
|
|
|
|
<LoadingWrap loading={loading}>
|
|
|
|
<Redoc store={store} options={options} />
|
|
|
|
</LoadingWrap>
|
|
|
|
)}
|
|
|
|
</StoreProvider>
|
|
|
|
</ErrorBoundary>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|