mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-18 10:50:32 +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';
|
import { Redoc } from './Redoc/Redoc';
|
||||||
|
|
||||||
export interface RedocStandaloneProps {
|
export interface RedocStandaloneProps {
|
||||||
specOrSpecUrl: string | object;
|
spec?: object;
|
||||||
|
specUrl?: string;
|
||||||
options?: {
|
options?: {
|
||||||
theme?: ThemeInterface;
|
theme?: ThemeInterface;
|
||||||
};
|
};
|
||||||
|
@ -16,15 +17,7 @@ export interface RedocStandaloneProps {
|
||||||
|
|
||||||
export class RedocStandalone extends React.Component<RedocStandaloneProps> {
|
export class RedocStandalone extends React.Component<RedocStandaloneProps> {
|
||||||
render() {
|
render() {
|
||||||
const { specOrSpecUrl, options } = this.props;
|
const { spec, specUrl, options } = this.props;
|
||||||
let specUrl;
|
|
||||||
let spec;
|
|
||||||
|
|
||||||
if (typeof specOrSpecUrl === 'string') {
|
|
||||||
specUrl = specOrSpecUrl;
|
|
||||||
} else if (typeof specOrSpecUrl === 'object') {
|
|
||||||
spec = specOrSpecUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary>
|
<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');
|
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(
|
render(
|
||||||
React.createElement(
|
React.createElement(
|
||||||
RedocStandalone,
|
RedocStandalone,
|
||||||
{
|
{
|
||||||
specOrSpecUrl,
|
spec,
|
||||||
|
specUrl,
|
||||||
options: { ...options, ...parseOptionsFromElement(element) },
|
options: { ...options, ...parseOptionsFromElement(element) },
|
||||||
},
|
},
|
||||||
['Loading...'],
|
['Loading...'],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user