├── .java-version ├── boot-swagger ├── src │ ├── test │ │ ├── resources │ │ │ └── .gitkeep │ │ └── java │ │ │ └── springfoxdemo │ │ │ └── .gitkeep │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── springfoxdemo │ │ └── boot │ │ └── swagger │ │ ├── web │ │ ├── Category.java │ │ ├── HomeController.java │ │ ├── FileUploadController.java │ │ └── CategoryController.java │ │ ├── SwaggerUiWebMvcConfigurer.java │ │ └── Application.java ├── build.gradle └── README.md ├── boot-static-docs ├── src │ ├── main │ │ ├── resources │ │ │ └── .gitkeep │ │ └── java │ │ │ └── springfoxdemo │ │ │ └── staticdocs │ │ │ ├── SwaggerConfig.java │ │ │ └── Application.java │ └── test │ │ ├── resources │ │ └── .gitkeep │ │ ├── java │ │ └── springfoxdemo │ │ │ └── .gitkeep │ │ └── groovy │ │ └── springfoxdemo │ │ └── staticdocs │ │ └── StaticDocsTest.groovy ├── README.md └── build.gradle ├── spring-java-swagger ├── src │ ├── test │ │ ├── resources │ │ │ └── .gitkeep │ │ └── java │ │ │ └── springfoxdemo │ │ │ └── .gitkeep │ └── main │ │ ├── resources │ │ └── application.properties │ │ └── java │ │ └── springfoxdemo │ │ └── java │ │ └── swagger │ │ ├── HelloWorldController.java │ │ ├── AppConfiguration.java │ │ ├── ServletInitializer.java │ │ └── SpringConfig.java ├── build.gradle └── README.md ├── spring-xml-swagger ├── src │ ├── main │ │ ├── resources │ │ │ └── .gitkeep │ │ ├── java │ │ │ └── springfoxdemo │ │ │ │ └── xml │ │ │ │ └── swagger │ │ │ │ ├── ApplicationSwaggerConfig.java │ │ │ │ └── ApplicationInitializer.java │ │ └── webapp │ │ │ └── WEB-INF │ │ │ └── dispatcher-servlet.xml │ └── test │ │ ├── resources │ │ └── .gitkeep │ │ └── java │ │ └── springfoxdemo │ │ └── .gitkeep ├── build.gradle └── README.md ├── boot-webflux ├── settings.gradle ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── io │ │ │ └── springfox │ │ │ └── demo │ │ │ └── bootwebflux │ │ │ └── BootWebfluxApplication.java │ └── test │ │ └── java │ │ └── io │ │ └── springfox │ │ └── demo │ │ └── bootwebflux │ │ └── BootWebfluxApplicationTests.java ├── README.md ├── .gitignore ├── build.gradle ├── gradlew.bat └── gradlew ├── boot-webmvc ├── settings.gradle ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ ├── maven-wrapper.properties │ │ └── MavenWrapperDownloader.java ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── io │ │ │ └── springfox │ │ │ └── demo │ │ │ └── bootwebmvc │ │ │ ├── Security.java │ │ │ └── BootWebmvcApplication.java │ └── test │ │ └── java │ │ └── io │ │ └── springfox │ │ └── demo │ │ └── bootwebmvc │ │ └── BootWebmvcApplicationTests.java ├── .gitignore ├── README.md ├── build.gradle ├── gradlew.bat └── gradlew ├── springfox-integration-webflux ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── escalon │ │ │ └── springfox │ │ │ └── springintegration │ │ │ └── SpringIntegrationWebFluxApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── escalon │ │ └── springfox │ │ └── springintegration │ │ └── SpringIntegrationApplicationTests.java ├── settings.gradle ├── .gitignore ├── build.gradle └── pom.xml ├── springfox-integration-webmvc ├── src │ ├── main │ │ ├── resources │ │ │ └── application.properties │ │ └── java │ │ │ └── com │ │ │ └── escalon │ │ │ └── springfox │ │ │ └── springintegration │ │ │ └── SpringIntegrationWebMvcApplication.java │ └── test │ │ └── java │ │ └── com │ │ └── escalon │ │ └── springfox │ │ └── springintegration │ │ ├── SpringIntegrationWebMvcApplicationTests.java │ │ └── SpringIntegrationWebMvcApplicationTest.java ├── settings.gradle ├── .gitignore ├── build.gradle └── pom.xml ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties └── dependencies.gradle ├── .gitignore ├── settings.gradle ├── README.md ├── gradlew.bat ├── gradlew └── LICENSE /.java-version: -------------------------------------------------------------------------------- 1 | 1.8.0.252 -------------------------------------------------------------------------------- /boot-swagger/src/test/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /boot-static-docs/src/main/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /boot-static-docs/src/test/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-java-swagger/src/test/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-xml-swagger/src/main/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-xml-swagger/src/test/resources/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /boot-static-docs/src/test/java/springfoxdemo/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /boot-swagger/src/test/java/springfoxdemo/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-java-swagger/src/test/java/springfoxdemo/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spring-xml-swagger/src/test/java/springfoxdemo/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /boot-webflux/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'boot-webflux' 2 | -------------------------------------------------------------------------------- /boot-webmvc/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'boot-webflux' 2 | -------------------------------------------------------------------------------- /springfox-integration-webflux/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springfox-integration-webmvc/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /springfox-integration-webmvc/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'spring-integration-springfox' 2 | -------------------------------------------------------------------------------- /springfox-integration-webflux/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'springfox-integration-webflux' 2 | -------------------------------------------------------------------------------- /spring-java-swagger/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.springfox.documentation=DEBUG -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/springfox/springfox-demos/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /boot-webflux/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/springfox/springfox-demos/HEAD/boot-webflux/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /boot-webmvc/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/springfox/springfox-demos/HEAD/boot-webmvc/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /boot-webflux/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/springfox/springfox-demos/HEAD/boot-webflux/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /boot-swagger/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | #Comment the below property for the Swagger page to work again 2 | server.servlet.contextPath=/springfox -------------------------------------------------------------------------------- /boot-swagger/src/main/java/springfoxdemo/boot/swagger/web/Category.java: -------------------------------------------------------------------------------- 1 | package springfoxdemo.boot.swagger.web; 2 | 3 | public enum Category { 4 | ONE, 5 | TWO, 6 | THREE 7 | } 8 | -------------------------------------------------------------------------------- /boot-webflux/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.springfox.documentation=DEBUG 2 | springfox.documentation.swagger-ui.base-url=/documentation 3 | #server.servlet.context-path=/mvc 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | build/ 3 | classes/ 4 | # Ignore Gradle GUI config 5 | gradle-app.setting 6 | 7 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 8 | !gradle-wrapper.jar 9 | .java-version 10 | .idea 11 | -------------------------------------------------------------------------------- /boot-webmvc/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | logging.level.springfox.documentation=DEBUG 2 | springfox.documentation.swagger-ui.base-url=/documentation 3 | server.servlet.context-path=/mvc 4 | springfox.documentation.swagger.v2.use-model-v3=false 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /boot-webflux/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /boot-webflux/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /boot-webmvc/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'springfox-demos' 2 | include 'boot-swagger' 3 | include 'boot-static-docs' 4 | include 'spring-xml-swagger' 5 | include 'spring-java-swagger' 6 | include 'springfox-integration-webflux' 7 | include 'springfox-integration-webmvc' 8 | include 'boot-webmvc' 9 | include 'boot-webflux' 10 | -------------------------------------------------------------------------------- /spring-java-swagger/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "org.gretty" version "3.0.3" 3 | } 4 | 5 | apply plugin: 'war' 6 | 7 | dependencies { 8 | compile libs.spring 9 | compile libs.jackson 10 | compile libs.springfoxOpenApi 11 | compile libs.springfoxSwaggerUi 12 | compile 'org.slf4j:slf4j-simple:1.7.30' 13 | testCompile libs.test 14 | } -------------------------------------------------------------------------------- /boot-static-docs/src/main/java/springfoxdemo/staticdocs/SwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package springfoxdemo.staticdocs; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; 5 | 6 | @Configuration 7 | @EnableSwagger2WebMvc 8 | public class SwaggerConfig { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /boot-webmvc/src/test/java/io/springfox/demo/bootwebmvc/BootWebmvcApplicationTests.java: -------------------------------------------------------------------------------- 1 | package io.springfox.demo.bootwebmvc; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class BootWebmvcApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /boot-webflux/src/test/java/io/springfox/demo/bootwebflux/BootWebfluxApplicationTests.java: -------------------------------------------------------------------------------- 1 | package io.springfox.demo.bootwebflux; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class BootWebfluxApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /spring-xml-swagger/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "org.gretty" version "3.0.3" 3 | } 4 | 5 | apply plugin: 'war' 6 | 7 | dependencies { 8 | compile libs.spring 9 | compile libs.jackson 10 | compile libs.springfoxPetstore 11 | compile libs.springfoxSwagger2 12 | compile libs.springfoxSwaggerUi 13 | compile 'org.slf4j:slf4j-simple:1.7.30' 14 | testCompile libs.test 15 | } -------------------------------------------------------------------------------- /boot-swagger/src/main/java/springfoxdemo/boot/swagger/web/HomeController.java: -------------------------------------------------------------------------------- 1 | package springfoxdemo.boot.swagger.web; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | 6 | @Controller 7 | public class HomeController { 8 | public String home() { 9 | return "redirect:/swagger-ui/index.html"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /springfox-integration-webmvc/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /springfox-integration-webflux/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ -------------------------------------------------------------------------------- /spring-java-swagger/src/main/java/springfoxdemo/java/swagger/HelloWorldController.java: -------------------------------------------------------------------------------- 1 | package springfoxdemo.java.swagger; 2 | 3 | import org.springframework.web.bind.annotation.RequestMapping; 4 | import org.springframework.web.bind.annotation.RestController; 5 | 6 | @RestController 7 | public class HelloWorldController { 8 | @RequestMapping("/hello") 9 | public String sayHello() { 10 | return "Hello World"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /boot-swagger/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.3.1.RELEASE' 3 | } 4 | 5 | apply plugin: 'idea' 6 | 7 | dependencies { 8 | compile libs.springBoot 9 | compile libs.springfoxPetstore 10 | compile libs.springfoxSwagger2 11 | compile "io.springfox:springfox-swagger1:${springfoxVersion}" 12 | compile "io.springfox:springfox-oas:${springfoxVersion}" 13 | compile libs.springfoxSwaggerUi 14 | testCompile libs.test 15 | } -------------------------------------------------------------------------------- /boot-webflux/README.md: -------------------------------------------------------------------------------- 1 | # boot-swagger 2 | A spring boot application with OpenAPI 3.0 api documentation enabled 3 | - Demonstrates using the default swagger group 4 | 5 | ``` 6 | ./gradlew boot-webflux:bootRun 7 | ``` 8 | 9 | ## Paths 10 | - All Swagger Resources(groups) `http://localhost:8080/documentation/swagger-resources` 11 | - Swagger UI endpoint: `http://localhost:8080/documentation/swagger-ui/` 12 | - Swagger docs endpoint: `http://localhost:8080/v3/api-docs` 13 | 14 | 15 | -------------------------------------------------------------------------------- /spring-java-swagger/README.md: -------------------------------------------------------------------------------- 1 | ## spring-java-swagger 2 | An java configured spring web mvc app with Swagger2 and Swagger UI 3 | 4 | ### Running 5 | ``` 6 | ./gradlew spring-java-swagger:appRun 7 | ``` 8 | 9 | ### Working Api Endpoint 10 | http://localhost:8080/spring-java-swagger/hello 11 | 12 | 13 | ### Swagger 2 Default Documentation 14 | http://localhost:8080/spring-java-swagger/v3/api-docs 15 | 16 | ### Swagger UI 17 | http://localhost:8080/spring-java-swagger/swagger-ui/ 18 | -------------------------------------------------------------------------------- /boot-webflux/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /boot-webmvc/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | 30 | ### VS Code ### 31 | .vscode/ 32 | -------------------------------------------------------------------------------- /spring-xml-swagger/README.md: -------------------------------------------------------------------------------- 1 | ## spring-xml-swagger 2 | An xml configured spring web mvc app with Swagger2 and Swagger UI 3 | 4 | ### Running 5 | ``` 6 | ./gradlew spring-xml-swagger:appRun 7 | ``` 8 | 9 | ### Working Api Endpoint 10 | http://localhost:8080/spring-xml-swagger/api/user/login?username=a&password=b 11 | 12 | 13 | ### Swagger 2 Default Documentation 14 | http://localhost:8080/spring-xml-swagger/v2/api-docs 15 | 16 | ### Swagger UI 17 | http://localhost:8080/spring-xml-swagger/swagger-ui.html 18 | -------------------------------------------------------------------------------- /boot-swagger/README.md: -------------------------------------------------------------------------------- 1 | # boot-swagger 2 | A spring boot application with both swagger 1.2, 2.0 and 3.0 api documentation enabled 3 | - Demonstrates using swagger groups 4 | - Demonstrates manual configuration (without using auto configuration/springfox boot-starter) 5 | 6 | ``` 7 | ./gradlew boot-swagger:bootRun 8 | ``` 9 | 10 | ## Paths 11 | - All Swagger Resources(groups) `http://localhost:8080/springfox/swagger-resources` 12 | - Swagger UI endpoint: `http://localhost:8080/springfox/swagger-ui/index.html` 13 | 14 | 15 | -------------------------------------------------------------------------------- /spring-java-swagger/src/main/java/springfoxdemo/java/swagger/AppConfiguration.java: -------------------------------------------------------------------------------- 1 | package springfoxdemo.java.swagger; 2 | 3 | import org.springframework.context.annotation.ComponentScan; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 6 | import springfox.documentation.oas.annotations.EnableOpenApi; 7 | 8 | @Configuration 9 | @EnableWebMvc 10 | @ComponentScan("springfoxdemo.java.swagger") 11 | @EnableOpenApi 12 | public class AppConfiguration { 13 | } 14 | -------------------------------------------------------------------------------- /springfox-integration-webflux/src/test/java/com/escalon/springfox/springintegration/SpringIntegrationApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.escalon.springfox.springintegration; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class SpringIntegrationApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-xml-swagger/src/main/java/springfoxdemo/xml/swagger/ApplicationSwaggerConfig.java: -------------------------------------------------------------------------------- 1 | package springfoxdemo.xml.swagger; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import springfox.documentation.spi.DocumentationType; 5 | import springfox.documentation.spring.web.plugins.Docket; 6 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 7 | 8 | @EnableSwagger2 9 | public class ApplicationSwaggerConfig { 10 | @Bean 11 | public Docket petStore() { 12 | return new Docket(DocumentationType.SWAGGER_2); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /boot-webmvc/README.md: -------------------------------------------------------------------------------- 1 | # boot-swagger 2 | A spring boot application with OpenAPI 3.0 api documentation enabled 3 | - Demonstrates using the default swagger group 4 | - Demonstrates using context path of `/mvc` 5 | - Demonstrates use of path for swagger-ui @ `/documentation` 6 | ``` 7 | ./gradlew boot-webflux:bootRun 8 | ``` 9 | 10 | ## Paths 11 | - All Swagger Resources(groups) `http://localhost:8080/mvc/documentation/swagger-resources` 12 | - Swagger UI endpoint: `http://localhost:8080/mvc/documentation/swagger-ui/` 13 | - Swagger docs endpoint: `http://localhost:8080/mvc/v3/api-docs` 14 | 15 | 16 | -------------------------------------------------------------------------------- /springfox-integration-webmvc/src/test/java/com/escalon/springfox/springintegration/SpringIntegrationWebMvcApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.escalon.springfox.springintegration; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest(classes=SpringIntegrationWebMvcApplication.class) 10 | public class SpringIntegrationWebMvcApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /spring-java-swagger/src/main/java/springfoxdemo/java/swagger/ServletInitializer.java: -------------------------------------------------------------------------------- 1 | package springfoxdemo.java.swagger; 2 | 3 | import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; 4 | 5 | public class ServletInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { 6 | 7 | @Override 8 | protected Class[] getServletConfigClasses() { 9 | return new Class[] { AppConfiguration.class }; 10 | } 11 | 12 | @Override 13 | protected String[] getServletMappings() { 14 | return new String[] { "/" }; 15 | } 16 | 17 | @Override 18 | protected Class[] getRootConfigClasses() { 19 | return null; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /spring-xml-swagger/src/main/java/springfoxdemo/xml/swagger/ApplicationInitializer.java: -------------------------------------------------------------------------------- 1 | package springfoxdemo.xml.swagger; 2 | 3 | import org.springframework.web.WebApplicationInitializer; 4 | import org.springframework.web.servlet.DispatcherServlet; 5 | 6 | import javax.servlet.ServletContext; 7 | import javax.servlet.ServletRegistration; 8 | 9 | public class ApplicationInitializer implements WebApplicationInitializer { 10 | @Override 11 | public void onStartup(ServletContext container) { 12 | ServletRegistration.Dynamic registration = container.addServlet("dispatcher", new DispatcherServlet()); 13 | registration.setLoadOnStartup(1); 14 | registration.addMapping("/*"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /boot-webflux/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.3.1.RELEASE' 3 | id 'io.spring.dependency-management' version '1.0.9.RELEASE' 4 | } 5 | 6 | group = 'io.springfox.demo' 7 | version = '0.0.1-SNAPSHOT' 8 | sourceCompatibility = '1.8' 9 | 10 | dependencies { 11 | implementation 'org.springframework.boot:spring-boot-starter-webflux' 12 | implementation "io.springfox:springfox-boot-starter:$springfoxVersion" 13 | testImplementation('org.springframework.boot:spring-boot-starter-test') { 14 | exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' 15 | } 16 | testImplementation 'io.projectreactor:reactor-test' 17 | } 18 | 19 | test { 20 | useJUnitPlatform() 21 | } 22 | -------------------------------------------------------------------------------- /boot-static-docs/src/main/java/springfoxdemo/staticdocs/Application.java: -------------------------------------------------------------------------------- 1 | package springfoxdemo.staticdocs; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.ApplicationContext; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import springfox.petstore.controller.PetController; 8 | 9 | @SpringBootApplication 10 | @ComponentScan(basePackageClasses = { 11 | SwaggerConfig.class, PetController.class 12 | }) 13 | public class Application { 14 | public static void main(String[] args) { 15 | ApplicationContext ctx = SpringApplication.run(Application.class, args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /boot-static-docs/README.md: -------------------------------------------------------------------------------- 1 | ## boot-static-docs 2 | 3 | __Experimental__ 4 | - A spring boot app with a default swagger2 configuration 5 | - A test which uses `springfox-staticdocs` and [swagger2markup](https://github.com/RobWin/swagger2markup) to generate 6 | Asciidoc source from the applications JSO API. 7 | - The [asciidoctor-gradle-plugin](https://github.com/asciidoctor/asciidoctor-gradle-plugin) to generate pdf and html asciidoctor docs. 8 | 9 | 10 | To generate the asciidoctor documentation run: 11 | 12 | ```bash 13 | ./gradlew boot-static-docs:asciidoctor 14 | ``` 15 | 16 | ### Runnng the app 17 | ```bash 18 | ./gradlew boot-static-docs:bootRun 19 | ``` 20 | 21 | http://localhost:8080/v2/api-docs 22 | http://localhost:8080/swagger-ui.html 23 | -------------------------------------------------------------------------------- /boot-webmvc/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.springframework.boot' version '2.3.1.RELEASE' 3 | id 'io.spring.dependency-management' version '1.0.9.RELEASE' 4 | } 5 | 6 | group = 'io.springfox.demo' 7 | version = '0.0.1-SNAPSHOT' 8 | sourceCompatibility = '1.8' 9 | 10 | dependencies { 11 | implementation 'org.springframework.boot:spring-boot-starter-web' 12 | implementation "io.springfox:springfox-boot-starter:$springfoxVersion" 13 | implementation 'org.springframework.security:spring-security-web' 14 | implementation 'org.springframework.security:spring-security-config' 15 | testImplementation('org.springframework.boot:spring-boot-starter-test') { 16 | exclude group: 'org.junit.vintage', module: 'junit-vintage-engine' 17 | } 18 | testImplementation 'io.projectreactor:reactor-test' 19 | } 20 | 21 | test { 22 | useJUnitPlatform() 23 | } 24 | -------------------------------------------------------------------------------- /boot-webmvc/src/main/java/io/springfox/demo/bootwebmvc/Security.java: -------------------------------------------------------------------------------- 1 | package io.springfox.demo.bootwebmvc; 2 | 3 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 4 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 5 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 6 | import org.springframework.security.web.csrf.CookieCsrfTokenRepository; 7 | 8 | @EnableWebSecurity 9 | public class Security extends WebSecurityConfigurerAdapter { 10 | @Override 11 | protected void configure(HttpSecurity http) throws Exception { 12 | http 13 | .authorizeRequests() 14 | .anyRequest() 15 | .anonymous() 16 | .and() 17 | .csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /boot-swagger/src/main/java/springfoxdemo/boot/swagger/web/FileUploadController.java: -------------------------------------------------------------------------------- 1 | package springfoxdemo.boot.swagger.web; 2 | 3 | import org.springframework.http.MediaType; 4 | import org.springframework.http.ResponseEntity; 5 | import org.springframework.stereotype.Controller; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.RequestPart; 9 | import org.springframework.web.multipart.MultipartFile; 10 | 11 | @Controller 12 | public class FileUploadController { 13 | @RequestMapping(value = "/upload", consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }, method = RequestMethod.POST) 14 | public ResponseEntity uploadFile(@RequestPart String description, @RequestPart MultipartFile file) { 15 | //yaay! 16 | return ResponseEntity.ok(null); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # springfox-demos 2 | Springfox demo applications 3 | 4 | 5 | # IDE 6 | First build 7 | ``` 8 | ./gradlew idea 9 | ``` 10 | 11 | ## Examples 12 | |Example | Description | 13 | |---|---| 14 | | boot-static-docs | demonstrates generating static docs @ build time | 15 | | boot-swagger | demonstrates application with manual configuration using `@Enable...` annotations and beans | 16 | | boot-webflux | demonstrates webflux support and open api 3.0.3 support with auto configuration | 17 | | boot-webmvc | demonstrates webmvc support and open api 3.0.3 support with auto configuration | 18 | | spring-java-swagger | demonstrates manual java configuration api 3.0.3 support on an non-boot app | 19 | | spring-xml-swagger | demonstrates manual xml configuration api 3.0.3 support on an non-boot app | 20 | | spring-integration-webflux | demonstrates spring integration support on webflux project | 21 | | spring-integration-webmvc | demonstrates spring integration support on webmvc project| 22 | 23 | -------------------------------------------------------------------------------- /spring-java-swagger/src/main/java/springfoxdemo/java/swagger/SpringConfig.java: -------------------------------------------------------------------------------- 1 | package springfoxdemo.java.swagger; 2 | 3 | import org.springframework.stereotype.Component; 4 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 5 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | @Component 9 | public class SpringConfig implements WebMvcConfigurer { 10 | @Override 11 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 12 | registry. 13 | addResourceHandler("/swagger-ui/**") 14 | .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/") 15 | .resourceChain(false); 16 | } 17 | 18 | @Override 19 | public void addViewControllers(ViewControllerRegistry registry) { 20 | registry.addViewController("/swagger-ui/") 21 | .setViewName("forward:" + "/swagger-ui/index.html"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /boot-static-docs/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | } 5 | 6 | dependencies { 7 | classpath "org.asciidoctor:asciidoctor-gradle-plugin:1.5.3" 8 | classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.11' 9 | } 10 | } 11 | 12 | plugins { 13 | id 'org.springframework.boot' version '2.3.1.RELEASE' 14 | } 15 | 16 | apply plugin: 'idea' 17 | apply plugin: 'groovy' 18 | apply plugin: "org.asciidoctor.convert" 19 | 20 | dependencies { 21 | compile libs.springBoot 22 | compile libs.springfoxPetstore 23 | compile libs.springfoxSwagger2 24 | compile libs.springfoxSwaggerUi 25 | testCompile libs.test 26 | testCompile libs.springfoxStaticDocs 27 | testCompile 'io.swagger:swagger-parser:2.0.0-rc1' 28 | } 29 | 30 | def targetDocDir = "${project.buildDir}/asciidoc/generated/swagger_adoc" 31 | test { 32 | systemProperty "asciiDocOutputDir", targetDocDir 33 | } 34 | asciidoctor.dependsOn test 35 | 36 | asciidoctor { 37 | sourceDir = file(targetDocDir) 38 | backends = ['html5', 'pdf'] 39 | } -------------------------------------------------------------------------------- /spring-xml-swagger/src/main/webapp/WEB-INF/dispatcher-servlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /springfox-integration-webflux/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'maven' 3 | 4 | group = 'com.escalon.springfox' 5 | version = '0.0.1-SNAPSHOT' 6 | 7 | description = """spring-integration""" 8 | 9 | sourceCompatibility = 1.8 10 | targetCompatibility = 1.8 11 | tasks.withType(JavaCompile) { 12 | options.encoding = 'UTF-8' 13 | } 14 | 15 | dependencies { 16 | compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.3.1.RELEASE' 17 | compile group: 'org.springframework.boot', name: 'spring-boot-starter-integration', version: '2.3.1.RELEASE' 18 | compile group: 'org.springframework.boot', name: 'spring-boot-starter-webflux', version: '2.3.1.RELEASE' 19 | compile group: 'org.springframework.integration', name: 'spring-integration-webflux', version: '5.3.2.RELEASE' 20 | compile group: 'io.springfox', name: 'springfox-swagger2', version: springfoxVersion 21 | compile group: 'io.springfox', name: 'springfox-spring-webflux', version: springfoxVersion 22 | compile group: 'io.springfox', name: 'springfox-spring-integration-webflux', version: springfoxVersion 23 | compile group: 'io.springfox', name: 'springfox-swagger-ui', version: springfoxVersion 24 | testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.3.1.RELEASE' 25 | } 26 | -------------------------------------------------------------------------------- /boot-static-docs/src/test/groovy/springfoxdemo/staticdocs/StaticDocsTest.groovy: -------------------------------------------------------------------------------- 1 | package springfoxdemo.staticdocs 2 | 3 | import groovy.io.FileType 4 | import org.springframework.beans.factory.annotation.Autowired 5 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc 6 | import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest 7 | import org.springframework.http.MediaType 8 | import org.springframework.test.web.servlet.MockMvc 9 | import spock.lang.Ignore 10 | import spock.lang.Specification 11 | import springfox.documentation.staticdocs.Swagger2MarkupResultHandler 12 | 13 | import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.* 14 | import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.* 15 | 16 | @AutoConfigureMockMvc 17 | @WebMvcTest 18 | class StaticDocsTest extends Specification { 19 | 20 | @Autowired 21 | MockMvc mockMvc; 22 | 23 | @Ignore 24 | def "generates the petstore api asciidoc"() { 25 | setup: 26 | String outDir = System.getProperty('asciiDocOutputDir', 'build/aciidoc') 27 | Swagger2MarkupResultHandler resultHandler = Swagger2MarkupResultHandler 28 | .outputDirectory(outDir) 29 | .build() 30 | 31 | when: 32 | this.mockMvc.perform(get("/v2/api-docs").accept(MediaType.APPLICATION_JSON)) 33 | .andDo(resultHandler) 34 | .andExpect(status().isOk()) 35 | 36 | then: 37 | def list = [] 38 | def dir = new File(resultHandler.outputDir) 39 | dir.eachFileRecurse(FileType.FILES) { file -> 40 | list << file.name 41 | } 42 | list.sort() == ['definitions.adoc', 'overview.adoc', 'paths.adoc'] 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /boot-swagger/src/main/java/springfoxdemo/boot/swagger/SwaggerUiWebMvcConfigurer.java: -------------------------------------------------------------------------------- 1 | package springfoxdemo.boot.swagger; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.util.StringUtils; 6 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 7 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 8 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 9 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 10 | 11 | @Component 12 | public class SwaggerUiWebMvcConfigurer implements WebMvcConfigurer { 13 | private final String baseUrl; 14 | 15 | public SwaggerUiWebMvcConfigurer( 16 | @Value("${springfox.documentation.swagger-ui.base-url:}") String baseUrl) { 17 | this.baseUrl = baseUrl; 18 | } 19 | 20 | @Override 21 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 22 | String baseUrl = StringUtils.trimTrailingCharacter(this.baseUrl, '/'); 23 | registry. 24 | addResourceHandler(baseUrl + "/swagger-ui/**") 25 | .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/") 26 | .resourceChain(false); 27 | } 28 | 29 | @Override 30 | public void addViewControllers(ViewControllerRegistry registry) { 31 | registry.addViewController(baseUrl + "/swagger-ui/") 32 | .setViewName("forward:" + baseUrl + "/swagger-ui/index.html"); 33 | } 34 | 35 | @Override 36 | public void addCorsMappings(CorsRegistry registry) { 37 | registry 38 | .addMapping("/api/pet") 39 | .allowedOrigins("http://editor.swagger.io"); 40 | registry 41 | .addMapping("/v2/api-docs.*") 42 | .allowedOrigins("http://editor.swagger.io"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /springfox-integration-webmvc/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | apply plugin: 'maven' 3 | 4 | group = 'com.escalon.springfox' 5 | version = '0.0.1-SNAPSHOT' 6 | 7 | description = """spring-integration""" 8 | 9 | sourceCompatibility = 1.8 10 | targetCompatibility = 1.8 11 | tasks.withType(JavaCompile) { 12 | options.encoding = 'UTF-8' 13 | } 14 | 15 | jar { 16 | dependsOn 'test' 17 | sourceSets { 18 | main { 19 | java { 20 | srcDirs = ['src/main/java'] 21 | } 22 | resources { 23 | srcDirs = ["target/generated-snippets", "src/main/resources"] 24 | // include "**/*.springfox" 25 | } 26 | } 27 | } 28 | } 29 | 30 | clean { 31 | delete 'out' // interpreted relative to the project directory 32 | } 33 | 34 | dependencies { 35 | compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator', version: '2.3.1.RELEASE' 36 | compile group: 'org.springframework.boot', name: 'spring-boot-starter-integration', version: '2.3.1.RELEASE' 37 | compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.3.1.RELEASE' 38 | compile(group: 'org.springframework.integration', name: 'spring-integration-http', version: '5.3.2.RELEASE') { 39 | exclude(module: 'commons-logging') 40 | exclude(module: 'commons-logging-api') 41 | } 42 | compile group: 'io.springfox', name: 'springfox-swagger2', version: springfoxVersion 43 | compile group: 'io.springfox', name: 'springfox-spring-webmvc', version: springfoxVersion 44 | compile group: 'io.springfox', name: 'springfox-spring-integration-webmvc', version: springfoxVersion 45 | compile group: 'io.springfox', name: 'springfox-swagger-ui', version: springfoxVersion 46 | testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: '2.3.1.RELEASE' 47 | testCompile group: 'org.springframework.restdocs', name: 'spring-restdocs-mockmvc', version: '2.0.2.RELEASE' 48 | } 49 | -------------------------------------------------------------------------------- /boot-webmvc/src/main/java/io/springfox/demo/bootwebmvc/BootWebmvcApplication.java: -------------------------------------------------------------------------------- 1 | package io.springfox.demo.bootwebmvc; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | import org.springframework.web.bind.annotation.RestController; 11 | import springfox.documentation.spi.DocumentationType; 12 | import springfox.documentation.spring.web.plugins.Docket; 13 | import springfox.documentation.swagger.web.SecurityConfiguration; 14 | import springfox.documentation.swagger.web.SecurityConfigurationBuilder; 15 | 16 | @SpringBootApplication 17 | public class BootWebmvcApplication { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(BootWebmvcApplication.class, args); 21 | } 22 | 23 | @RestController 24 | @RequestMapping("/hello") 25 | public static class HelloWorldController { 26 | @GetMapping 27 | public ResponseEntity hello() { 28 | return ResponseEntity.ok("Hello SpringFox!"); 29 | } 30 | 31 | @GetMapping("/double") 32 | public ResponseEntity testDouble(@RequestParam(value = "test", defaultValue = "10") Double count) { 33 | return ResponseEntity.ok("Value " + count); 34 | } 35 | } 36 | @Bean 37 | public SecurityConfiguration securityConfiguration() { 38 | return SecurityConfigurationBuilder.builder() 39 | .enableCsrfSupport(true) 40 | .build(); 41 | } 42 | 43 | // NOTE: Uncomment to personalize. OAS_30 (OpenAPI is the default spec version) 44 | // @Bean 45 | // public Docket docket() { 46 | // return new Docket(DocumentationType.SWAGGER_2); 47 | // }} 48 | } 49 | -------------------------------------------------------------------------------- /boot-swagger/src/main/java/springfoxdemo/boot/swagger/web/CategoryController.java: -------------------------------------------------------------------------------- 1 | package springfoxdemo.boot.swagger.web; 2 | 3 | import org.springframework.http.ResponseEntity; 4 | import org.springframework.web.bind.annotation.PathVariable; 5 | import org.springframework.web.bind.annotation.RequestBody; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import org.springframework.web.bind.annotation.RestController; 10 | import springfox.documentation.annotations.ApiIgnore; 11 | import springfox.petstore.model.Pet; 12 | 13 | import java.util.HashMap; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | @RestController 18 | public class CategoryController { 19 | @RequestMapping(value = "/category/Resource", method = RequestMethod.GET) 20 | public ResponseEntity search(@RequestParam(value = "someEnum") Category someEnum) { 21 | return ResponseEntity.ok(someEnum.name()); 22 | } 23 | 24 | @RequestMapping(value = "/category/map", method = RequestMethod.GET) 25 | public Map> map() { 26 | return new HashMap<>(); 27 | } 28 | 29 | @RequestMapping(value = "/category/{id}", method = RequestMethod.POST) 30 | public ResponseEntity someOperation( 31 | @PathVariable long id, 32 | @RequestBody int userId) { 33 | return ResponseEntity.ok(null); 34 | } 35 | 36 | @RequestMapping(value = "/category/{id}/{userId}", method = RequestMethod.POST) 37 | public ResponseEntity ignoredParam( 38 | @PathVariable long id, 39 | @PathVariable @ApiIgnore int userId) { 40 | return ResponseEntity.ok(null); 41 | } 42 | 43 | @RequestMapping(value = "/category/{id}/map", method = RequestMethod.POST) 44 | public ResponseEntity map( 45 | @PathVariable String id, 46 | @RequestParam Map test) { 47 | return ResponseEntity.ok(null); 48 | } 49 | 50 | @RequestMapping(value = "/categories", method = RequestMethod.POST) 51 | public ResponseEntity> map(String[] categories) { 52 | return ResponseEntity.ok(null); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /gradle/dependencies.gradle: -------------------------------------------------------------------------------- 1 | ext { 2 | springVersion = "5.2.7.RELEASE" 3 | springBootVersion = "2.3.1.RELEASE" 4 | springfoxVersion = '3.0.0' 5 | jacksonVersion = '2.11.0' 6 | groovy = "3.0.4" 7 | spock = "2.0-M3-groovy-3.0" 8 | 9 | libs = [ 10 | 11 | spring : [ 12 | "org.springframework:spring-core:$springVersion", 13 | "org.springframework:spring-web:$springVersion", 14 | "org.springframework:spring-webmvc:$springVersion" 15 | ], 16 | springBoot : [ 17 | "org.springframework.boot:spring-boot-starter-web:${springBootVersion}" 18 | ], 19 | springfoxPetstore : [ 20 | "io.springfox:springfox-petstore:2.10.5" 21 | ], 22 | springfoxSwagger2 : [ 23 | "io.springfox:springfox-spring-web:${springfoxVersion}", 24 | "io.springfox:springfox-spring-webmvc:${springfoxVersion}", 25 | "io.springfox:springfox-swagger2:${springfoxVersion}" 26 | ], 27 | springfoxOpenApi : [ 28 | "io.springfox:springfox-spring-web:${springfoxVersion}", 29 | "io.springfox:springfox-spring-webmvc:${springfoxVersion}", 30 | "io.springfox:springfox-oas:${springfoxVersion}" 31 | ], 32 | springfoxSwaggerUi: [ 33 | "io.springfox:springfox-swagger-ui:${springfoxVersion}" 34 | ], 35 | jackson : [ 36 | "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}", 37 | "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}" 38 | ], 39 | test : [ 40 | "org.codehaus.groovy:groovy-all:${groovy}", 41 | "org.spockframework:spock-spring:${spock}", 42 | "org.spockframework:spock-core:${spock}", 43 | "org.springframework:spring-test:${springVersion}", 44 | "org.springframework.boot:spring-boot-starter-test:${springBootVersion}" 45 | ], 46 | springfoxStaticDocs: [ 47 | "io.springfox:springfox-staticdocs:2.6.1" 48 | ], 49 | ] 50 | } 51 | -------------------------------------------------------------------------------- /springfox-integration-webflux/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.escalon.springfox 7 | springfox-integration-webflux 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | spring-integration 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.3.1.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 3.0.0-SNAPSHOT 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-actuator 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-integration 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-webflux 40 | 41 | 42 | 43 | org.springframework.integration 44 | spring-integration-webflux 45 | 46 | 47 | 48 | io.springfox 49 | springfox-swagger2 50 | ${springfox.version} 51 | 52 | 53 | io.springfox 54 | springfox-spring-webflux 55 | ${springfox.version} 56 | 57 | 58 | io.springfox 59 | springfox-spring-integration-webflux 60 | ${springfox.version} 61 | 62 | 63 | io.springfox 64 | springfox-swagger-ui 65 | ${springfox.version} 66 | 67 | 68 | 69 | 70 | org.springframework.boot 71 | spring-boot-starter-test 72 | test 73 | 74 | 75 | 76 | 77 | 78 | 79 | org.springframework.boot 80 | spring-boot-maven-plugin 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /boot-webflux/src/main/java/io/springfox/demo/bootwebflux/BootWebfluxApplication.java: -------------------------------------------------------------------------------- 1 | package io.springfox.demo.bootwebflux; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.http.MediaType; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.stereotype.Component; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestParam; 12 | import org.springframework.web.bind.annotation.RestController; 13 | import org.springframework.web.reactive.function.BodyInserters; 14 | import org.springframework.web.reactive.function.server.RequestPredicates; 15 | import org.springframework.web.reactive.function.server.RouterFunction; 16 | import org.springframework.web.reactive.function.server.RouterFunctions; 17 | import org.springframework.web.reactive.function.server.ServerRequest; 18 | import org.springframework.web.reactive.function.server.ServerResponse; 19 | import reactor.core.publisher.Flux; 20 | import reactor.core.publisher.Mono; 21 | import springfox.documentation.spi.DocumentationType; 22 | import springfox.documentation.spring.web.plugins.Docket; 23 | 24 | import java.util.List; 25 | import java.util.Optional; 26 | import java.util.stream.IntStream; 27 | 28 | @SpringBootApplication 29 | public class BootWebfluxApplication { 30 | 31 | public static void main(String[] args) { 32 | SpringApplication.run(BootWebfluxApplication.class, args); 33 | } 34 | 35 | @RestController 36 | @RequestMapping("/functional-hello") 37 | public static class FunctionalHelloWorldController { 38 | @GetMapping("/response-mono") 39 | public ResponseEntity> helloMono() { 40 | return ResponseEntity.ok(Mono.fromSupplier(() -> "Hello SpringFox!")); 41 | } 42 | 43 | @GetMapping("/mono") 44 | public Mono helloPerson(String name) { 45 | return Mono.just("Hello " + name + "!"); 46 | } 47 | 48 | @GetMapping("/flux") 49 | public Flux helloPeople(String... names) { 50 | return Flux.fromArray(names).map(name -> "Hello " + name); 51 | } 52 | 53 | @GetMapping("/response-flux") 54 | public ResponseEntity> helloPeople(@RequestParam List names) { 55 | return ResponseEntity.of(Optional.of(Flux.fromStream(names.stream().map(name -> "Hello " + name)))); 56 | } 57 | } 58 | 59 | @Bean 60 | public RouterFunction route(GreetingHandler greetingHandler) { 61 | return RouterFunctions 62 | .route(RequestPredicates.GET("/hello") 63 | .and(RequestPredicates.accept(MediaType.TEXT_PLAIN)), 64 | greetingHandler::hello); 65 | } 66 | 67 | @Component 68 | public static class GreetingHandler { 69 | 70 | public Mono hello(ServerRequest request) { 71 | return ServerResponse.ok() 72 | .contentType(MediaType.TEXT_PLAIN) 73 | .body(BodyInserters.fromValue("Hello, SpringFox!")); 74 | } 75 | } 76 | 77 | // NOTE: Uncomment to personalize. OAS_30 (OpenAPI is the default spec version) 78 | // @Bean 79 | // public Docket docket() { 80 | // return new Docket(DocumentationType.SWAGGER_2); 81 | // } 82 | } 83 | -------------------------------------------------------------------------------- /springfox-integration-webflux/src/main/java/com/escalon/springfox/springintegration/SpringIntegrationWebFluxApplication.java: -------------------------------------------------------------------------------- 1 | package com.escalon.springfox.springintegration; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.http.HttpMethod; 7 | import org.springframework.integration.dsl.IntegrationFlow; 8 | import org.springframework.integration.dsl.IntegrationFlows; 9 | import org.springframework.integration.webflux.dsl.WebFlux; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | import org.springframework.web.bind.annotation.RequestBody; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | import springfox.documentation.swagger2.annotations.EnableSwagger2WebFlux; 14 | 15 | @SpringBootApplication 16 | @EnableSwagger2WebFlux 17 | public class SpringIntegrationWebFluxApplication { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(SpringIntegrationWebFluxApplication.class, args); 21 | } 22 | 23 | @Bean 24 | public IntegrationFlow toUpperFlow() { 25 | return IntegrationFlows.from( 26 | WebFlux.inboundGateway("/conversions/upper") 27 | .requestMapping(r -> r.methods(HttpMethod.POST) 28 | .consumes("text/plain"))) 29 | .handle((p, h) -> p.toUpperCase()) 30 | .get(); 31 | } 32 | 33 | @Bean 34 | public IntegrationFlow toUpperGetFlow() { 35 | return IntegrationFlows.from( 36 | WebFlux.inboundGateway("/conversions/pathvariable/{upperLower}") 37 | .requestMapping(r -> r 38 | .methods(HttpMethod.GET) 39 | .params("toConvert")) 40 | .headerExpression("upperLower", "#pathVariables.upperLower") 41 | .payloadExpression("#requestParams['toConvert'][0]")) 42 | .handle((p, h) -> "upper".equals(h.get("upperLower")) ? p.toUpperCase() : p.toLowerCase()) 43 | .get(); 44 | } 45 | 46 | public static class Foo { 47 | private String bar; 48 | 49 | public String getBar() { 50 | return bar; 51 | } 52 | 53 | public void setBar(String bar) { 54 | this.bar = bar; 55 | } 56 | } 57 | 58 | @Bean 59 | public IntegrationFlow toLowerFlow() { 60 | return IntegrationFlows.from( 61 | WebFlux.inboundGateway("/conversions/lower") 62 | .requestMapping(r -> r.methods(HttpMethod.POST) 63 | .consumes("application/json")) 64 | .requestPayloadType(Foo.class)) 65 | .handle((p, h) -> p.toUpperCase()) 66 | .get(); 67 | } 68 | 69 | public static class Baz { 70 | public String getBarf() { 71 | return barf; 72 | } 73 | 74 | public void setBarf(String barf) { 75 | this.barf = barf; 76 | } 77 | 78 | private String barf; 79 | } 80 | 81 | @PostMapping("/conversion/controller") 82 | public @ResponseBody 83 | Baz convert(@RequestBody Baz baz) { 84 | return baz; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | 88 | @rem Execute Gradle 89 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 90 | 91 | :end 92 | @rem End local scope for the variables with windows NT shell 93 | if "%ERRORLEVEL%"=="0" goto mainEnd 94 | 95 | :fail 96 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 97 | rem the _cmd.exe /c_ return code! 98 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 99 | exit /b 1 100 | 101 | :mainEnd 102 | if "%OS%"=="Windows_NT" endlocal 103 | 104 | :omega 105 | -------------------------------------------------------------------------------- /boot-webmvc/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | 88 | @rem Execute Gradle 89 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 90 | 91 | :end 92 | @rem End local scope for the variables with windows NT shell 93 | if "%ERRORLEVEL%"=="0" goto mainEnd 94 | 95 | :fail 96 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 97 | rem the _cmd.exe /c_ return code! 98 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 99 | exit /b 1 100 | 101 | :mainEnd 102 | if "%OS%"=="Windows_NT" endlocal 103 | 104 | :omega 105 | -------------------------------------------------------------------------------- /boot-webflux/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | 88 | @rem Execute Gradle 89 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 90 | 91 | :end 92 | @rem End local scope for the variables with windows NT shell 93 | if "%ERRORLEVEL%"=="0" goto mainEnd 94 | 95 | :fail 96 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 97 | rem the _cmd.exe /c_ return code! 98 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 99 | exit /b 1 100 | 101 | :mainEnd 102 | if "%OS%"=="Windows_NT" endlocal 103 | 104 | :omega 105 | -------------------------------------------------------------------------------- /springfox-integration-webmvc/src/test/java/com/escalon/springfox/springintegration/SpringIntegrationWebMvcApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.escalon.springfox.springintegration; 2 | 3 | import org.junit.Before; 4 | import org.junit.Rule; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.http.MediaType; 10 | import org.springframework.restdocs.JUnitRestDocumentation; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | import org.springframework.test.web.servlet.MockMvc; 13 | import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; 14 | import org.springframework.test.web.servlet.result.MockMvcResultMatchers; 15 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 16 | import org.springframework.web.context.WebApplicationContext; 17 | import springfox.documentation.spring.web.SpringfoxTemplateFormat; 18 | 19 | import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; 20 | import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; 21 | import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; 22 | import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; 23 | 24 | @RunWith(SpringRunner.class) 25 | @SpringBootTest(classes = SpringIntegrationWebMvcApplication.class) 26 | public class SpringIntegrationWebMvcApplicationTest { 27 | 28 | @Autowired 29 | private WebApplicationContext context; 30 | 31 | private MockMvc mockMvc; 32 | 33 | @Rule 34 | public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); 35 | 36 | 37 | @Before 38 | public void setUp() { 39 | this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) 40 | .apply(documentationConfiguration(this.restDocumentation) 41 | .snippets() 42 | .withTemplateFormat(new SpringfoxTemplateFormat()) 43 | 44 | // .and() 45 | // .snippets() 46 | // .withTemplateFormat(TemplateFormats.asciidoctor()) 47 | ) 48 | .build(); 49 | } 50 | 51 | @Test 52 | public void toLowerFlowAragorn() throws Exception { 53 | mockMvc.perform( 54 | MockMvcRequestBuilders.post("/conversions/lower") 55 | .contentType(MediaType.APPLICATION_JSON) 56 | .content("{\n" + 57 | " \"bar\": \"Aragorn\",\n" + 58 | " \"foo\": true,\n" + 59 | " \"count\": 3\n" + 60 | "}")) 61 | .andExpect(MockMvcResultMatchers.status() 62 | .isOk()) 63 | .andDo(document("toLowerGatewayAragorn", responseFields( 64 | fieldWithPath("bar").description("Name of the bar"), 65 | fieldWithPath("foo").description("Specifies if this is a foo"), 66 | fieldWithPath("count").description("Specifies how many foos there are") 67 | ))); 68 | 69 | } 70 | 71 | @Test 72 | public void toLowerFlowGimli() throws Exception { 73 | mockMvc.perform( 74 | MockMvcRequestBuilders.post("/conversions/lower") 75 | .contentType(MediaType.APPLICATION_JSON) 76 | .content("{\n" + 77 | " \"bar\": \"Gimli\",\n" + 78 | " \"foo\": true,\n" + 79 | " \"count\": 3\n" + 80 | "}")) 81 | .andExpect(MockMvcResultMatchers.status() 82 | .isOk()) 83 | .andDo(document("toLowerGatewayGimli", responseFields( 84 | fieldWithPath("bar").description("Name of the bar"), 85 | fieldWithPath("foo").description("Specifies if this is a foo"), 86 | fieldWithPath("count").description("Specifies how many foos there are") 87 | ))); 88 | 89 | } 90 | 91 | 92 | } -------------------------------------------------------------------------------- /springfox-integration-webmvc/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.escalon.springfox 7 | spring-integration-springfox 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | spring-integration 12 | Demo project for Spring Boot 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 2.3.1.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 3.0.0-SNAPSHOT 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-actuator 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-integration 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-web 40 | 41 | 42 | 43 | org.springframework.integration 44 | spring-integration-http 45 | 46 | 47 | 48 | io.springfox 49 | springfox-swagger2 50 | ${springfox.version} 51 | 52 | 53 | io.springfox 54 | springfox-spring-webmvc 55 | ${springfox.version} 56 | 57 | 58 | io.springfox 59 | springfox-spring-integration-webmvc 60 | ${springfox.version} 61 | 62 | 63 | io.springfox 64 | springfox-swagger-ui 65 | ${springfox.version} 66 | 67 | 68 | 69 | 70 | org.springframework.boot 71 | spring-boot-starter-test 72 | test 73 | 74 | 75 | org.springframework.restdocs 76 | spring-restdocs-mockmvc 77 | test 78 | 79 | 80 | 81 | 82 | 83 | 84 | org.springframework.boot 85 | spring-boot-maven-plugin 86 | 87 | 88 | org.apache.maven.plugins 89 | maven-resources-plugin 90 | 3.1.0 91 | 92 | 93 | add-restdocs 94 | prepare-package 95 | 96 | copy-resources 97 | 98 | 99 | ${project.build.directory}/classes 100 | 101 | 102 | target/generated-snippets 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /springfox-integration-webmvc/src/main/java/com/escalon/springfox/springintegration/SpringIntegrationWebMvcApplication.java: -------------------------------------------------------------------------------- 1 | package com.escalon.springfox.springintegration; 2 | 3 | import io.swagger.annotations.ApiResponse; 4 | import io.swagger.annotations.ApiResponses; 5 | import io.swagger.annotations.Example; 6 | import io.swagger.annotations.ExampleProperty; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.http.HttpMethod; 11 | import org.springframework.integration.dsl.IntegrationFlow; 12 | import org.springframework.integration.dsl.IntegrationFlows; 13 | import org.springframework.integration.http.dsl.Http; 14 | import org.springframework.web.bind.annotation.PostMapping; 15 | import org.springframework.web.bind.annotation.RequestBody; 16 | import org.springframework.web.bind.annotation.ResponseBody; 17 | import org.springframework.web.bind.annotation.RestController; 18 | import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; 19 | 20 | @SpringBootApplication 21 | @EnableSwagger2WebMvc 22 | @RestController 23 | public class SpringIntegrationWebMvcApplication { 24 | 25 | public static void main(String[] args) { 26 | SpringApplication.run(SpringIntegrationWebMvcApplication.class, args); 27 | } 28 | 29 | 30 | @Bean 31 | public IntegrationFlow toUpperGetFlow() { 32 | return IntegrationFlows.from( 33 | Http.inboundGateway("/conversions/pathvariable/{upperLower}") 34 | .requestMapping(r -> r 35 | .methods(HttpMethod.GET) 36 | .params("toConvert")) 37 | .headerExpression("upperLower", 38 | "#pathVariables.upperLower") 39 | .payloadExpression("#requestParams['toConvert'][0]") 40 | .id("toUpperLowerGateway")) 41 | .handle((p, h) -> "upper".equals(h.get("upperLower")) ? p.toUpperCase() : p.toLowerCase()) 42 | .get(); 43 | } 44 | 45 | 46 | @Bean 47 | public IntegrationFlow toUpperFlow() { 48 | return IntegrationFlows.from( 49 | Http.inboundGateway("/conversions/upper") 50 | .requestMapping(r -> r.methods(HttpMethod.POST) 51 | .consumes("text/plain")) 52 | .requestPayloadType(String.class) 53 | .id("toUpperGateway")) 54 | .handle((p, h) -> p.toUpperCase()) 55 | .get(); 56 | } 57 | 58 | @Bean 59 | public IntegrationFlow toLowerFlow() { 60 | return IntegrationFlows.from( 61 | Http.inboundGateway("/conversions/lower") 62 | .requestMapping(r -> r.methods(HttpMethod.POST) 63 | .consumes("application/json")) 64 | .requestPayloadType(Foo.class) 65 | .id("toLowerGateway")) 66 | .handle((p, h) -> new Foo(p.getBar() 67 | .toLowerCase())) 68 | .get(); 69 | } 70 | 71 | @ApiResponses( 72 | @ApiResponse(code = 200, message = "OK", 73 | examples = @Example(@ExampleProperty(mediaType = "application/json", 74 | value = "{\"gnarf\": \"dragons\"}")))) 75 | @PostMapping("/conversion/controller") 76 | public @ResponseBody 77 | Baz convert(@RequestBody Baz baz) { 78 | return baz; 79 | } 80 | 81 | public static class Baz { 82 | public String getGnarf() { 83 | return gnarf; 84 | } 85 | 86 | public void setGnarf(String gnarf) { 87 | this.gnarf = gnarf; 88 | } 89 | 90 | private String gnarf; 91 | } 92 | 93 | public static class Foo { 94 | private String bar; 95 | private boolean foo = false; 96 | private int count = 3; 97 | 98 | public Foo() { 99 | 100 | } 101 | 102 | public Foo(String bar) { 103 | this.bar = bar; 104 | } 105 | 106 | public String getBar() { 107 | return bar; 108 | } 109 | 110 | public void setBar(String bar) { 111 | this.bar = bar; 112 | } 113 | 114 | public boolean isFoo() { 115 | return foo; 116 | } 117 | 118 | public void setFoo(boolean foo) { 119 | this.foo = foo; 120 | } 121 | 122 | public int getCount() { 123 | return count; 124 | } 125 | 126 | public void setCount(int count) { 127 | this.count = count; 128 | } 129 | } 130 | 131 | 132 | } 133 | -------------------------------------------------------------------------------- /boot-webmvc/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /boot-webflux/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /boot-webflux/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /boot-webmvc/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /boot-swagger/src/main/java/springfoxdemo/boot/swagger/Application.java: -------------------------------------------------------------------------------- 1 | package springfoxdemo.boot.swagger; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.ApplicationContext; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import springfox.documentation.annotations.ApiIgnore; 9 | import springfox.documentation.builders.ApiInfoBuilder; 10 | import springfox.documentation.builders.AuthorizationScopeBuilder; 11 | import springfox.documentation.builders.ImplicitGrantBuilder; 12 | import springfox.documentation.builders.OAuthBuilder; 13 | import springfox.documentation.oas.annotations.EnableOpenApi; 14 | import springfox.documentation.service.ApiInfo; 15 | import springfox.documentation.service.ApiKey; 16 | import springfox.documentation.service.AuthorizationScope; 17 | import springfox.documentation.service.BasicAuth; 18 | import springfox.documentation.service.Contact; 19 | import springfox.documentation.service.GrantType; 20 | import springfox.documentation.service.LoginEndpoint; 21 | import springfox.documentation.service.SecurityReference; 22 | import springfox.documentation.service.SecurityScheme; 23 | import springfox.documentation.spi.DocumentationType; 24 | import springfox.documentation.spi.service.contexts.SecurityContext; 25 | import springfox.documentation.spring.web.plugins.Docket; 26 | import springfox.documentation.swagger.web.SecurityConfiguration; 27 | import springfox.documentation.swagger.web.SecurityConfigurationBuilder; 28 | import springfox.documentation.swagger1.annotations.EnableSwagger; 29 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 30 | import springfox.petstore.controller.PetController; 31 | import springfox.petstore.controller.PetStoreResource; 32 | import springfox.petstore.controller.UserController; 33 | import springfoxdemo.boot.swagger.web.HomeController; 34 | 35 | import javax.print.Doc; 36 | import java.util.Arrays; 37 | import java.util.Collections; 38 | import java.util.List; 39 | import java.util.function.Predicate; 40 | 41 | import static springfox.documentation.builders.PathSelectors.*; 42 | 43 | @SpringBootApplication 44 | @EnableSwagger //Enable swagger 1.2 spec 45 | @EnableSwagger2 //Enable swagger 2.0 spec 46 | @EnableOpenApi //Enable open api 3.0.3 spec 47 | public class Application { 48 | public static void main(String[] args) { 49 | ApplicationContext ctx = SpringApplication.run(Application.class, args); 50 | } 51 | 52 | @Bean 53 | public PetController petController() { 54 | return new PetController(); 55 | } 56 | 57 | @Bean 58 | public PetStoreResource petStoreController() { 59 | return new PetStoreResource(); 60 | } 61 | 62 | @Bean 63 | public UserController userController() { 64 | return new UserController(); 65 | } 66 | 67 | @Bean 68 | public Docket petApi() { 69 | return new Docket(DocumentationType.SWAGGER_2) 70 | .groupName("full-petstore-api") 71 | .apiInfo(apiInfo()) 72 | .select() 73 | .paths(petstorePaths()) 74 | .build() 75 | .securitySchemes(Collections.singletonList(oauth())) 76 | .securityContexts(Collections.singletonList(securityContext())); 77 | } 78 | 79 | @Bean 80 | public Docket categoryApi() { 81 | return new Docket(DocumentationType.SWAGGER_2) 82 | .groupName("category-api") 83 | .apiInfo(apiInfo()) 84 | .select() 85 | .paths(categoryPaths()) 86 | .build() 87 | .ignoredParameterTypes(ApiIgnore.class) 88 | .enableUrlTemplating(true); 89 | } 90 | 91 | @Bean 92 | public Docket multipartApi() { 93 | return new Docket(DocumentationType.SWAGGER_2) 94 | .groupName("multipart-api") 95 | .apiInfo(apiInfo()) 96 | .select() 97 | .paths(multipartPaths()) 98 | .build(); 99 | } 100 | 101 | private Predicate categoryPaths() { 102 | return regex(".*/category.*") 103 | .or(regex(".*/category") 104 | .or(regex(".*/categories"))); 105 | } 106 | 107 | private Predicate multipartPaths() { 108 | return regex(".*/upload.*"); 109 | } 110 | 111 | @Bean 112 | public Docket userApi() { 113 | AuthorizationScope[] authScopes = new AuthorizationScope[1]; 114 | authScopes[0] = new AuthorizationScopeBuilder() 115 | .scope("read") 116 | .description("read access") 117 | .build(); 118 | SecurityReference securityReference = SecurityReference.builder() 119 | .reference("test") 120 | .scopes(authScopes) 121 | .build(); 122 | 123 | List securityContexts = 124 | Collections.singletonList( 125 | SecurityContext.builder() 126 | .securityReferences(Collections.singletonList(securityReference)) 127 | .build()); 128 | return new Docket(DocumentationType.SWAGGER_2) 129 | .securitySchemes(Collections.singletonList(new BasicAuth("test"))) 130 | .securityContexts(securityContexts) 131 | .groupName("user-api") 132 | .apiInfo(apiInfo()) 133 | .select() 134 | .paths(input -> input.contains("user")) 135 | .build(); 136 | } 137 | 138 | @Bean 139 | public Docket openApiPetStore() { 140 | return new Docket(DocumentationType.OAS_30) 141 | .groupName("open-api-pet-store") 142 | .select() 143 | .paths(petstorePaths()) 144 | .build(); 145 | } 146 | 147 | private Predicate petstorePaths() { 148 | return regex(".*/api/pet.*") 149 | .or(regex(".*/api/user.*") 150 | .or(regex(".*/api/store.*"))); 151 | } 152 | 153 | private ApiInfo apiInfo() { 154 | return new ApiInfoBuilder() 155 | .title("Springfox petstore API") 156 | .description("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum " + 157 | "has been the industry's standard dummy text ever since the 1500s, when an unknown printer " 158 | + "took a " + 159 | "galley of type and scrambled it to make a type specimen book. It has survived not only five " + 160 | "centuries, but also the leap into electronic typesetting, remaining essentially unchanged. " + 161 | "It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum " + 162 | "passages, and more recently with desktop publishing software like Aldus PageMaker including " + 163 | "versions of Lorem Ipsum.") 164 | .termsOfServiceUrl("http://springfox.io") 165 | .contact(new Contact("springfox", "", "")) 166 | .license("Apache License Version 2.0") 167 | .licenseUrl("https://github.com/springfox/springfox/blob/master/LICENSE") 168 | .version("2.0") 169 | .build(); 170 | } 171 | 172 | @Bean 173 | SecurityContext securityContext() { 174 | AuthorizationScope readScope = new AuthorizationScope("read:pets", "read your pets"); 175 | AuthorizationScope[] scopes = new AuthorizationScope[1]; 176 | scopes[0] = readScope; 177 | SecurityReference securityReference = SecurityReference.builder() 178 | .reference("petstore_auth") 179 | .scopes(scopes) 180 | .build(); 181 | 182 | return SecurityContext.builder() 183 | .securityReferences(Collections.singletonList(securityReference)) 184 | .forPaths(ant(".*/api/pet.*")) 185 | .build(); 186 | } 187 | 188 | @Bean 189 | SecurityScheme oauth() { 190 | return new OAuthBuilder() 191 | .name("petstore_auth") 192 | .grantTypes(grantTypes()) 193 | .scopes(scopes()) 194 | .build(); 195 | } 196 | 197 | @Bean 198 | SecurityScheme apiKey() { 199 | return new ApiKey("api_key", "api_key", "header"); 200 | } 201 | 202 | List scopes() { 203 | return Arrays.asList( 204 | new AuthorizationScope("write:pets", "modify pets in your account"), 205 | new AuthorizationScope("read:pets", "read your pets")); 206 | } 207 | 208 | List grantTypes() { 209 | GrantType grantType = new ImplicitGrantBuilder() 210 | .loginEndpoint(new LoginEndpoint("http://petstore.swagger.io/api/oauth/dialog")) 211 | .build(); 212 | return Collections.singletonList(grantType); 213 | } 214 | 215 | @Bean 216 | public SecurityConfiguration securityInfo() { 217 | return SecurityConfigurationBuilder.builder() 218 | .clientId("abc") 219 | .clientSecret("123") 220 | .realm("pets") 221 | .appName("petstore") 222 | .scopeSeparator(",") 223 | .build(); 224 | } 225 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | --------------------------------------------------------------------------------