带有ReDoc和Spring引导的API文档



有人能分享一些关于如何使用ReDoc和SpringBoot框架实现API文档的例子吗。如果有人知道ReDoc+Springboot的一些好例子,那将是非常有帮助的。

您可以创建一个启用springdoc openapi ui[1]的spring-boot应用程序,然后添加一个静态html[2],如图所示!通过将规范url更改为http://localhost:8080/v3/api-docs[3]

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

[2] :https://stackoverflow.com/a/42393332/878710

[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>

最新更新