diff --git a/onebusaway-api-webapp/pom.xml b/onebusaway-api-webapp/pom.xml index 4d25fd114a..bdee67b041 100644 --- a/onebusaway-api-webapp/pom.xml +++ b/onebusaway-api-webapp/pom.xml @@ -16,6 +16,24 @@ + + + io.springfox + springfox-swagger-ui + ${springfox-version} + + + + io.springfox + springfox-swagger2 + ${springfox-version} + + + + org.springframework + spring-webmvc + + org.onebusaway onebusaway-agency-metadata @@ -31,6 +49,11 @@ onebusaway-transit-data-federation ${project.version} + + org.onebusaway + onebusaway-transit-data-federation-webapp + 2.1.2-SNAPSHOT + org.onebusaway onebusaway-presentation diff --git a/onebusaway-api-webapp/src/main/java/org/onebusaway/api/configs/SpringFoxConfig.java b/onebusaway-api-webapp/src/main/java/org/onebusaway/api/configs/SpringFoxConfig.java new file mode 100644 index 0000000000..81504d64b4 --- /dev/null +++ b/onebusaway-api-webapp/src/main/java/org/onebusaway/api/configs/SpringFoxConfig.java @@ -0,0 +1,58 @@ +package org.onebusaway.api.configs; + + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.util.StringUtils; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@Configuration +@EnableSwagger2 +@EnableWebMvc +public class SpringFoxConfig implements WebMvcConfigurer { + private final String baseUrl = "http://localhost:9090/oba-api"; + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + String baseUrl = StringUtils.trimTrailingCharacter(this.baseUrl, '/'); + registry. + addResourceHandler(baseUrl + "/swagger-ui/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/") + .resourceChain(false); + } + + @Override + public void addViewControllers(ViewControllerRegistry registry) { + registry.addViewController(baseUrl + "/swagger-ui/") + .setViewName("forward:" + baseUrl + "/swagger-ui/index.html"); + } + + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build() + .apiInfo(apiInfo()); + + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("OBA") + .description("Api Services") + .version("2.1.2") + .build(); + } +} diff --git a/onebusaway-api-webapp/src/main/resources/org/onebusaway/api/swagger-servlet.xml b/onebusaway-api-webapp/src/main/resources/org/onebusaway/api/swagger-servlet.xml new file mode 100644 index 0000000000..365b28ee4f --- /dev/null +++ b/onebusaway-api-webapp/src/main/resources/org/onebusaway/api/swagger-servlet.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/onebusaway-api-webapp/src/main/webapp/WEB-INF/web.xml b/onebusaway-api-webapp/src/main/webapp/WEB-INF/web.xml index 24576c8631..25f729db25 100644 --- a/onebusaway-api-webapp/src/main/webapp/WEB-INF/web.xml +++ b/onebusaway-api-webapp/src/main/webapp/WEB-INF/web.xml @@ -86,4 +86,75 @@ index.html + + swagger + org.springframework.web.servlet.DispatcherServlet + + contextConfigLocation + + classpath:org/onebusaway/api/swagger-servlet.xml + + 1 + + + + swagger + /swagger-ui.html + + + + swagger + /swagger-ui.index.html + + + + swagger + /swagger-ui/springfox.css + + + + swagger + /swagger-ui/springfox.js + + + + swagger + /swagger-ui/swagger-ui.css + + + + swagger + /swagger-ui/swagger-ui.js + + + + swagger + /swagger-ui/swagger-ui-bundle.js + + + + swagger + /swagger-ui/swagger-ui-standalone-preset.js + + + + swagger + /v2/api-docs + + + + swagger + /swagger-resources + + + + swagger + /swagger-resources/configuration/ui + + + + swagger + /swagger-resources/configuration/security + + \ No newline at end of file diff --git a/onebusaway-gtfs-realtime-model/pom.xml b/onebusaway-gtfs-realtime-model/pom.xml index aa8d3aa377..c3d59a61f3 100644 --- a/onebusaway-gtfs-realtime-model/pom.xml +++ b/onebusaway-gtfs-realtime-model/pom.xml @@ -24,7 +24,7 @@ org.onebusaway onebusaway-container - 2.1.1-SNAPSHOT + 2.1.2-SNAPSHOT diff --git a/onebusaway-transit-data-federation-webapp/pom.xml b/onebusaway-transit-data-federation-webapp/pom.xml index dfdadb569d..26894e9009 100644 --- a/onebusaway-transit-data-federation-webapp/pom.xml +++ b/onebusaway-transit-data-federation-webapp/pom.xml @@ -78,6 +78,19 @@ mysql mysql-connector-java + + + + io.springfox + springfox-swagger-ui + ${springfox-version} + + + + io.springfox + springfox-swagger2 + ${springfox-version} + diff --git a/onebusaway-transit-data-federation-webapp/src/main/webapp/WEB-INF/remoting-servlet.xml b/onebusaway-transit-data-federation-webapp/src/main/webapp/WEB-INF/remoting-servlet.xml index b96aa7f0e3..728b478ea3 100644 --- a/onebusaway-transit-data-federation-webapp/src/main/webapp/WEB-INF/remoting-servlet.xml +++ b/onebusaway-transit-data-federation-webapp/src/main/webapp/WEB-INF/remoting-servlet.xml @@ -17,10 +17,11 @@ -->