Skip to content

Commit cac5f0a

Browse files
implement redoc
1 parent 71e7a96 commit cac5f0a

3 files changed

Lines changed: 62 additions & 0 deletions

File tree

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@
146146
<version>2.8.13</version> <!-- OpenAPI support for automatic API documentation -->
147147
</dependency>
148148

149+
<dependency>
150+
<groupId>org.springframework.boot</groupId>
151+
<artifactId>spring-boot-starter-thymeleaf</artifactId>
152+
</dependency>
153+
149154
<dependency>
150155
<groupId>org.springdoc</groupId>
151156
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package smartpot.com.api.Documentation;
2+
3+
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.stereotype.Controller;
5+
import org.springframework.ui.Model;
6+
import org.springframework.web.bind.annotation.GetMapping;
7+
8+
@Controller
9+
public class RedocController {
10+
@Value("${application.title}")
11+
private String title;
12+
13+
@Value("${application.description}")
14+
private String description;
15+
16+
@Value("${application.author}")
17+
private String author;
18+
19+
@Value("${application.version}")
20+
private String version;
21+
22+
@Value("${springdoc.api-docs.path:/v3/api-docs}")
23+
private String specUrl;
24+
25+
@GetMapping("${springdoc.redoc.path:/redoc}")
26+
public String redoc(Model model) {
27+
model.addAttribute("specUrl", specUrl);
28+
model.addAttribute("title", title);
29+
model.addAttribute("description", description);
30+
model.addAttribute("author", author);
31+
model.addAttribute("version", version);
32+
return "redoc";
33+
}
34+
}
35+
36+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!DOCTYPE html>
2+
<html xmlns:th="http://www.thymeleaf.org">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title th:text="${title}">API Documentation</title>
6+
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"></script>
7+
<style>
8+
body {
9+
margin: 0;
10+
padding: 0;
11+
background-color: #121212;
12+
}
13+
redoc {
14+
height: 100vh;
15+
}
16+
</style>
17+
</head>
18+
<body>
19+
<redoc th:attr="spec-url=${specUrl}"></redoc>
20+
</body>
21+
</html>

0 commit comments

Comments
 (0)