diff --git a/src/components/RedocStandalone.tsx b/src/components/RedocStandalone.tsx index c28cdee2..41805c8d 100644 --- a/src/components/RedocStandalone.tsx +++ b/src/components/RedocStandalone.tsx @@ -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 { 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 ( diff --git a/src/standalone.tsx b/src/standalone.tsx index 258311c7..ecf063cb 100644 --- a/src/standalone.tsx +++ b/src/standalone.tsx @@ -33,11 +33,19 @@ export function init( throw new Error('"element" argument is not provided and 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...'],