Created
          March 3, 2023 20:45 
        
      - 
      
- 
        Save hendrixroa/7ccd7cccb1737bd42af494727a37e2e5 to your computer and use it in GitHub Desktop. 
    Code snippet to configure a swagger instance in react.
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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