Java 21460 Move code from spring-boot-swagger & spring-boot-swagger-2 to spring-boot-swagger-springfox module (#14310)
* JAVA-21460 Upgrade spring-boot-swagger-jwt modules to use SpringDoc in place of SpringFox * JAVA-21460 Upgrade spring-boot-swagger-2 module to use SpringDoc in place of SpringFox * JAVA-21460 Upgrade spring-boot-swagger module to use SpringDoc in place of SpringFox * JAVA-21460 Move code from spring-boot-swagger & spring-boot-swagger-2 to spring-boot-swagger-springfox module * JAVA-21457 Upgrade spring-security-web-rest to use SpringDoc in place of SpringFox
This commit is contained in:
-44
@@ -1,44 +0,0 @@
|
||||
package com.baeldung.swagger2;
|
||||
|
||||
import static com.google.common.collect.Lists.newArrayList;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.builders.ResponseBuilder;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Bean
|
||||
public Docket api() {
|
||||
return new Docket(DocumentationType.SWAGGER_2).select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.baeldung.web.controller"))
|
||||
.paths(PathSelectors.ant("/foos/*"))
|
||||
.build()
|
||||
.apiInfo(apiInfo())
|
||||
.useDefaultResponseMessages(false)
|
||||
.globalResponses(HttpMethod.GET, newArrayList(
|
||||
new ResponseBuilder().code("500")
|
||||
.description("500 message").build(),
|
||||
new ResponseBuilder().code("403")
|
||||
.description("Forbidden!!!!!").build()
|
||||
));
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
ApiInfo apiInfo = new ApiInfo("My REST API", "Some custom description of API.", "API TOS", "Terms of service", new Contact("John Doe", "www.example.com", "myeaddress@company.com"), "License of API", "API license URL", Collections.emptyList());
|
||||
return apiInfo;
|
||||
}
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
package com.baeldung.web.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
@Controller
|
||||
public class CustomController {
|
||||
|
||||
@RequestMapping(value = "/custom", method = RequestMethod.POST)
|
||||
public String custom() {
|
||||
return "custom";
|
||||
}
|
||||
}
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
package com.baeldung.web;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.jayway.restassured.RestAssured;
|
||||
import com.jayway.restassured.response.Response;
|
||||
|
||||
public class SwaggerLiveTest {
|
||||
private static final String URL_PREFIX = "http://localhost:8080/spring-security-rest/api";
|
||||
|
||||
@Test
|
||||
public void whenVerifySpringFoxIsWorking_thenOK() {
|
||||
final Response response = RestAssured.get(URL_PREFIX + "/v2/api-docs");
|
||||
assertEquals(200, response.statusCode());
|
||||
System.out.println(response.asString());
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user