mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-29 12:03:44 +03:00
Update Redoc Standalone API
This commit is contained in:
parent
1dabeebb3d
commit
6fbd47b340
|
@ -8,7 +8,8 @@ import { ErrorBoundary } from './ErrorBoundary';
|
|||
import { Redoc } from './Redoc/Redoc';
|
||||
|
||||
export interface RedocStandaloneProps {
|
||||
specOrSpecUrl: string | object;
|
||||
spec?: object;
|
||||
specUrl?: string;
|
||||
options?: {
|
||||
theme?: ThemeInterface;
|
||||
};
|
||||
|
@ -16,15 +17,7 @@ export interface RedocStandaloneProps {
|
|||
|
||||
export class RedocStandalone extends React.Component<RedocStandaloneProps> {
|
||||
render() {
|
||||
const { specOrSpecUrl, options } = this.props;
|
||||
let specUrl;
|
||||
let spec;
|
||||
|
||||
if (typeof specOrSpecUrl === 'string') {
|
||||
specUrl = specOrSpecUrl;
|
||||
} else if (typeof specOrSpecUrl === 'object') {
|
||||
spec = specOrSpecUrl;
|
||||
}
|
||||
const { spec, specUrl, options } = this.props;
|
||||
|
||||
return (
|
||||
<ErrorBoundary>
|
||||
|
|
|
@ -33,11 +33,19 @@ export function init(
|
|||
throw new Error('"element" argument is not provided and <redoc> tag is not found on the page');
|
||||
}
|
||||
|
||||
let specUrl, spec;
|
||||
if (typeof specOrSpecUrl === 'string') {
|
||||
specUrl = specOrSpecUrl;
|
||||
} else if (typeof specOrSpecUrl === 'object') {
|
||||
spec = specOrSpecUrl;
|
||||
}
|
||||
|
||||
render(
|
||||
React.createElement(
|
||||
RedocStandalone,
|
||||
{
|
||||
specOrSpecUrl,
|
||||
spec,
|
||||
specUrl,
|
||||
options: { ...options, ...parseOptionsFromElement(element) },
|
||||
},
|
||||
['Loading...'],
|
||||
|
|
Loading…
Reference in New Issue
Block a user