Added Swagger
This commit is contained in:
parent
7e07448770
commit
cbe7aa6cc5
|
@ -7,6 +7,7 @@
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.http.version>1.19.0</project.http.version>
|
<project.http.version>1.19.0</project.http.version>
|
||||||
<project.oauth.version>1.19.0</project.oauth.version>
|
<project.oauth.version>1.19.0</project.oauth.version>
|
||||||
|
@ -35,7 +36,6 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
|
|
||||||
<!-- <dependency> -->
|
<!-- <dependency> -->
|
||||||
<!-- <groupId>dmp-backend</groupId> -->
|
<!-- <groupId>dmp-backend</groupId> -->
|
||||||
<!-- <artifactId>dmp-backend-commons</artifactId> -->
|
<!-- <artifactId>dmp-backend-commons</artifactId> -->
|
||||||
|
@ -250,11 +250,17 @@
|
||||||
<!-- <version>0.7.0</version> -->
|
<!-- <version>0.7.0</version> -->
|
||||||
<!-- </dependency> -->
|
<!-- </dependency> -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.apis</groupId>
|
<groupId>com.google.apis</groupId>
|
||||||
<artifactId>google-api-services-oauth2</artifactId>
|
<artifactId>google-api-services-oauth2</artifactId>
|
||||||
<version>v2-rev75-1.19.0</version>
|
<version>v2-rev75-1.19.0</version>
|
||||||
</dependency>
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava-jdk5</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.http-client</groupId>
|
<groupId>com.google.http-client</groupId>
|
||||||
<artifactId>google-http-client-jackson2</artifactId>
|
<artifactId>google-http-client-jackson2</artifactId>
|
||||||
|
@ -294,6 +300,26 @@
|
||||||
<version>23.0</version>
|
<version>23.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Swagger for providing a minimal (descriptive) UI for the rest API -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger2</artifactId>
|
||||||
|
<version>2.7.0</version>
|
||||||
|
<!-- <exclusions> -->
|
||||||
|
<!-- <exclusion> -->
|
||||||
|
<!-- <groupId>com.google.guava</groupId> -->
|
||||||
|
<!-- <artifactId>guava</artifactId> -->
|
||||||
|
<!-- </exclusion> -->
|
||||||
|
<!-- </exclusions> -->
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>2.7.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- Various libs -->
|
<!-- Various libs -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -335,7 +361,7 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
||||||
<finalName>${project.artifactId}</finalName>
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package swagger;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
|
||||||
|
import springfox.documentation.builders.PathSelectors;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@EnableSwagger2
|
||||||
|
@EnableWebMvc
|
||||||
|
public class SwaggerConfig extends WebMvcConfigurerAdapter {
|
||||||
|
@Bean
|
||||||
|
public Docket api() {
|
||||||
|
System.out.println("Initializing Swagger 2...");
|
||||||
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.any())
|
||||||
|
.paths(PathSelectors.any())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
System.out.println("Overriding resource handlers");
|
||||||
|
registry.addResourceHandler("swagger-ui.html")
|
||||||
|
.addResourceLocations("classpath*:/META-INF/resources/");
|
||||||
|
registry.addResourceHandler("/webjars/**")
|
||||||
|
.addResourceLocations("classpath*:/META-INF/resources/webjars/");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||||
|
xmlns:cache="http://www.springframework.org/schema/cache"
|
||||||
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/mvc
|
||||||
|
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
|
||||||
|
http://www.springframework.org/schema/context
|
||||||
|
http://www.springframework.org/schema/context/spring-context-4.1.xsd
|
||||||
|
http://www.springframework.org/schema/beans
|
||||||
|
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
|
||||||
|
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
|
||||||
|
|
||||||
|
<context:property-placeholder location="classpath*:**/dmp.properties" />
|
||||||
|
|
||||||
|
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/"/>
|
||||||
|
|
||||||
|
<context:component-scan base-package="swagger" />
|
||||||
|
|
||||||
|
<context:component-scan base-package="rest" />
|
||||||
|
|
||||||
|
<context:component-scan base-package="proxy" />
|
||||||
|
|
||||||
|
|
||||||
|
<bean id="proxy" class="proxy.Proxy">
|
||||||
|
<constructor-arg type = "String" value = "${proxy.allowed.host}"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
</beans>
|
|
@ -57,6 +57,33 @@
|
||||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||||
</listener>
|
</listener>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- This mapping is for swagger -->
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>swagger</servlet-name>
|
||||||
|
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||||
|
<!-- <init-param> -->
|
||||||
|
<!-- <param-name>contextConfigLocation</param-name> -->
|
||||||
|
<!-- <param-value></param-value> -->
|
||||||
|
<!-- </init-param> -->
|
||||||
|
<load-on-startup>1</load-on-startup>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>default</servlet-name>
|
||||||
|
<url-pattern>/swagger-ui.html</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>swagger</servlet-name>
|
||||||
|
<url-pattern>/*</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- this listener is for checking required stuff upon deployment of the webapp -->
|
<!-- this listener is for checking required stuff upon deployment of the webapp -->
|
||||||
<listener>
|
<listener>
|
||||||
<listener-class>
|
<listener-class>
|
||||||
|
@ -104,4 +131,5 @@
|
||||||
</filter-mapping>
|
</filter-mapping>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</web-app>
|
</web-app>
|
Loading…
Reference in New Issue