Install the following dependencies required by Redoc CE if you do not already have them installed:
reactreact-dommobxstyled-componentscore-js
If you have npm installed, you can install these dependencies using the following command:
npm i react react-dom mobx styled-components core-js- Import the
RedocStandalonecomponent.
import { RedocStandalone } from 'redoc';Use the component, either:
- link to your OpenAPI definition with a URL, using the following format:
<RedocStandalone specUrl="url/to/your/spec"/>- pass your OpenAPI definition as an object, using the following format:
<RedocStandalone spec={/* spec as an object */}/>(Optional) You can pass options to the
RedocStandalonecomponent to alter how it renders.For example:
<RedocStandalone specUrl="http://petstore.swagger.io/v2/swagger.json" options={{ nativeScrollbars: true, theme: { colors: { primary: { main: '#dd5522' } } }, }} />
For more information on configuration options, refer to the Configuration options for Reference docs section of the documentation.
You can also specify the onLoaded callback, which is called each time Redoc CE is fully rendered or when an error occurs (with an error as the first argument).
<RedocStandalone
specUrl="http://petstore.swagger.io/v2/swagger.json"
onLoaded={(error) => {
if (!error) {
console.log('Yay!');
}
}}
/>- Redoc CE deployment guide - Follow step-by-step instructions for setting up your Redoc CE project