forked from loafle/openapi-generator-original
[online] Apidocs ui (#3229)
* [online] Use rapidoc UI for api documentation
This commit is contained in:
@@ -33,6 +33,14 @@
|
||||
<build>
|
||||
<finalName>openapi-generator-online</finalName>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -69,11 +77,6 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${springfox-version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
|
||||
@@ -27,6 +27,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
public class HomeController {
|
||||
@RequestMapping(value = "/")
|
||||
public String index() {
|
||||
return "redirect:swagger-ui.html";
|
||||
return "redirect:index.html";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,9 @@ import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
@Configuration
|
||||
@@ -37,13 +39,25 @@ import java.io.InputStream;
|
||||
public class OpenAPIDocumentationConfig {
|
||||
|
||||
ApiInfo apiInfo() {
|
||||
final Properties properties = new Properties();
|
||||
try (InputStream stream = this.getClass().getResourceAsStream("/version.properties")) {
|
||||
if (stream != null) {
|
||||
properties.load(stream);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
// ignore
|
||||
}
|
||||
|
||||
String version = properties.getProperty("version", "unknown");
|
||||
|
||||
|
||||
return new ApiInfoBuilder()
|
||||
.title("OpenAPI Generator Online")
|
||||
.description("This is an online openapi generator server. You can find out more at https://github.com/OpenAPITools/openapi-generator.")
|
||||
.license("Apache 2.0")
|
||||
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
|
||||
.termsOfServiceUrl("")
|
||||
.version("3.0.0")
|
||||
.version(version)
|
||||
.contact(new Contact("","", ""))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -2,3 +2,4 @@ springfox.documentation.swagger.v2.path=/api-docs
|
||||
server.port=8080
|
||||
spring.jackson.date-format=org.openapitools.codegen.online.RFC3339DateFormat
|
||||
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
|
||||
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/
|
||||
|
||||
17
modules/openapi-generator-online/src/main/resources/static/index.html
Executable file
17
modules/openapi-generator-online/src/main/resources/static/index.html
Executable file
@@ -0,0 +1,17 @@
|
||||
<!doctype html> <!-- Important: must specify -->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"> <!-- Important: rapi-doc uses utf8 charecters -->
|
||||
<script src="rapidoc-min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<rapi-doc spec-url="api-docs"
|
||||
theme="dark">
|
||||
<img
|
||||
slot="logo"
|
||||
src="logo.png"
|
||||
style="margin:0 -0.3em 0 0.8em;"
|
||||
/>
|
||||
</rapi-doc>
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
182
modules/openapi-generator-online/src/main/resources/static/rapidoc-min.js
vendored
Normal file
182
modules/openapi-generator-online/src/main/resources/static/rapidoc-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
version = ${project.version}
|
||||
Reference in New Issue
Block a user