Search code examples
springdoc

Can we replace swagger-ui with redoc in Springdoc


I'm trying to replace a manually-maintained swagger file with Springdoc. Currently, we use ReDoc to render the file, because of their support for discriminator.

Is there a straightforward way to replace/supersede the embedded swagger-ui with ReDoc?


Solution

  • In springdoc you can skip using the swagger UI package and use:

        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-webmvc-core</artifactId>
        </dependency>
    

    instead. Then you can point to the location of swagger schema generated with springdoc (default is /v3/api-docs) in your <redoc /> component. The rest is depending on how you host Redoc. In our case we just added a controller to our service/app that serves a basic HTML described on Redoc documentation page (https://github.com/Redocly/redoc#tldr).