[online] Apidocs ui (#3229)

* [online] Use rapidoc UI for api documentation
This commit is contained in:
Jim Schubert
2019-06-29 20:30:45 -04:00
committed by GitHub
parent 731b162942
commit 3e5e82460f
8 changed files with 227 additions and 7 deletions

View File

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

View File

@@ -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";
}
}

View File

@@ -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();
}

View File

@@ -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/

View 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

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
version = ${project.version}