diff --git a/src/components/RedocStandalone.tsx b/src/components/RedocStandalone.tsx index 41805c8d..fb241e39 100644 --- a/src/components/RedocStandalone.tsx +++ b/src/components/RedocStandalone.tsx @@ -16,6 +16,26 @@ export interface RedocStandaloneProps { } export class RedocStandalone extends React.Component { + static propTypes = { + spec: (props, _, componentName) => { + if (!props.spec && !props.specUrl) { + return new Error( + `One of props 'spec' or 'specUrlurl' was not specified in '${componentName}'.`, + ); + } + return null; + }, + + specUrl: (props, _, componentName) => { + if (!props.spec && !props.specUrl) { + return new Error( + `One of props 'spec' or 'specUrl' was not specified in '${componentName}'.`, + ); + } + return null; + }, + }; + render() { const { spec, specUrl, options } = this.props; diff --git a/src/standalone.tsx b/src/standalone.tsx index ecf063cb..16500b34 100644 --- a/src/standalone.tsx +++ b/src/standalone.tsx @@ -33,7 +33,9 @@ export function init( throw new Error('"element" argument is not provided and tag is not found on the page'); } - let specUrl, spec; + let specUrl: string | undefined; + let spec: object | undefined; + if (typeof specOrSpecUrl === 'string') { specUrl = specOrSpecUrl; } else if (typeof specOrSpecUrl === 'object') {