Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Adds swagger-ui #329

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 108 additions & 2 deletions docs-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@
<packaging>war</packaging>
<name>Docs Web</name>

<properties>
<!-- Build plugins -->

<java.version>1.8</java.version>
<mvn-compiler-plugin.version>3.7.0</mvn-compiler-plugin.version>
<maven-dependency-plugin.version>3.1.1</maven-dependency-plugin.version>
<maven-war-plugin.version>3.2.2</maven-war-plugin.version>
<replacer.version>1.5.3</replacer.version>
<!-- end Build plugins -->
<!-- Code -->
<javax.servlet-api.version>4.0.1</javax.servlet-api.version>
<javax.ws.rs-api.version>2.1</javax.ws.rs-api.version>
<jersey.version>2.27</jersey.version>
<swagger.version>2.0.2</swagger.version>
<swagger-ui.version>3.17.0</swagger-ui.version>
<!-- end Code -->
</properties>

<dependencies>
<!-- Dependencies to Docs -->
<dependency>
Expand Down Expand Up @@ -78,7 +96,11 @@
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${javax.ws.rs-api.version}</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
Expand Down Expand Up @@ -139,6 +161,18 @@
<scope>test</scope>
</dependency>

<!-- Swagger -->
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-jaxrs2</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-jaxrs2-servlet-initializer</artifactId>
<version>${swagger.version}</version>
</dependency>
<!-- End Swagger -->
</dependencies>

<build>
Expand Down Expand Up @@ -180,6 +214,78 @@
</resources>

<plugins>
<plugin>
<!-- Build with specified Java version. -->
<artifactId>maven-compiler-plugin</artifactId>
<version>${mvn-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<!-- Download Swagger UI webjar. -->
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven-dependency-plugin.version}</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.webjars</groupId>
<artifactId>swagger-ui</artifactId>
<version>${swagger-ui.version}</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/swagger-ui</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!-- Add Swagger UI resources to the war file. -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<webResources combine.children="append">
<resource>
<directory>${project.build.directory}/swagger-ui/META-INF/resources/webjars/swagger-ui/${swagger-ui.version}</directory>
<includes>
<include>**/*.*</include>
</includes>
<targetPath>swagger-ui</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<!-- Replace the OpenAPI specification example URL with the local one. -->
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>${replacer.version}</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${project.build.directory}/swagger-ui/META-INF/resources/webjars/swagger-ui/${swagger-ui.version}/index.html</file>
<replacements>
<replacement>
<token>http://petstore.swagger.io/v2/swagger.json</token>
<value>/api/openapi.json</value>
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
Expand Down Expand Up @@ -282,4 +388,4 @@
</build>
</profile>
</profiles>
</project>
</project>
8 changes: 8 additions & 0 deletions docs-web/src/main/webapp/WEB-INF/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
prettyPrint: true
cacheTTL: 0
openAPI:
info:
version: "1.0.0"
title: "Teedy"
servers:
- url: "/api"
2 changes: 1 addition & 1 deletion docs-web/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.sismics.docs.rest.resource</param-value>
<param-value>io.swagger.v3.jaxrs2.integration.resources,com.sismics.docs.rest.resource</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
Expand Down