Skip to content

Instantly share code, notes, and snippets.

@hendrixroa
Created March 3, 2023 20:45
Show Gist options
  • Save hendrixroa/7ccd7cccb1737bd42af494727a37e2e5 to your computer and use it in GitHub Desktop.
Save hendrixroa/7ccd7cccb1737bd42af494727a37e2e5 to your computer and use it in GitHub Desktop.
Code snippet to configure a swagger instance in react.
const Swagger = ({...props}) => {
useEffect(() => {
const ui = SwaggerUI({
dom_id: '#swagger-custom-ui',
spec: swaggerData,
displayRequestDuration: true,
syntaxHighlight: {
activate: true,
theme: 'monokai'
},
persistAuthorization: true,
deepLinking: true,
filter: '',
docExpansion: 'none',
showCommonExtensions: true,
});
ui.preauthorizeApiKey('api_key', config.api_key);
}, []);
return <div id='swagger-custom-ui' {...props} />;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment