API Documentation with ReDoc and Spring boot
Asked Answered
Q

1

6

Could someone share some examples on how to implement API Documentation using ReDoc along with SpringBoot framework. It would be great help if someone knows some good examples with ReDoc + Springboot.

Quaternity answered 28/4, 2021 at 16:53 Comment(1)
Refer this tutorial baeldung.com/spring-rest-docsAnamorphosis
H
7

You can create a spring boot application enabling springdoc-openapi-ui [1] and then add a static html [2] as shown in here! by changing spec-url as http://localhost:8080/v3/api-docs [3]

[1] : https://www.baeldung.com/spring-rest-openapi-documentation

[2] : https://mcmap.net/q/264724/-how-can-i-serve-static-html-from-spring-boot

[3] :

<!DOCTYPE html>
<html>
  <head>
    <title>Redoc</title>
    <!-- needed for adaptive design -->
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">

    <!--
    Redoc doesn't change outer page styles
    -->
    <style>
      body {
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <redoc spec-url='http://localhost:8080/v3/api-docs'></redoc>
    <script src="https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js"> </script>
  </body>
</html>
Hairless answered 18/10, 2021 at 16:2 Comment(2)
How to set the base URL in the spec-URL as it changes based on the environmentRotorua
Set it relatively: "v3/api-docs".Solvent

© 2022 - 2024 — McMap. All rights reserved.