diff --git a/spring-data-rest-springfox/build.gradle b/spring-data-rest-springfox/build.gradle index b7e4310..f6099e5 100644 --- a/spring-data-rest-springfox/build.gradle +++ b/spring-data-rest-springfox/build.gradle @@ -20,15 +20,16 @@ sourceCompatibility = 1.8 repositories { mavenLocal() mavenCentral() + maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/' } } dependencies { compile('org.springframework.boot:spring-boot-starter-data-jpa') compile('org.springframework.boot:spring-boot-starter-data-rest') - compile('io.springfox:springfox-data-rest:2.7.0') - compile('io.springfox:springfox-swagger2:2.7.0') - compile('io.springfox:springfox-swagger-ui:2.7.0') + compile('io.springfox:springfox-data-rest:2.7.1-SNAPSHOT') + compile('io.springfox:springfox-swagger2:2.7.1-SNAPSHOT') + compile('io.springfox:springfox-swagger-ui:2.7.1-SNAPSHOT') compile('com.h2database:h2:1.4.196') testCompile('org.springframework.boot:spring-boot-starter-test') } diff --git a/spring-data-rest-springfox/src/main/java/com/example/demo/AddressRepository.java b/spring-data-rest-springfox/src/main/java/com/example/demo/AddressRepository.java index a38a9fc..6cf1d20 100644 --- a/spring-data-rest-springfox/src/main/java/com/example/demo/AddressRepository.java +++ b/spring-data-rest-springfox/src/main/java/com/example/demo/AddressRepository.java @@ -1,28 +1,23 @@ package com.example.demo; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import org.springframework.data.domain.Page; +import io.swagger.annotations.*; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.query.Param; import org.springframework.data.rest.core.annotation.RepositoryRestResource; -import org.springframework.web.bind.annotation.RequestParam; -import java.awt.print.Pageable; import java.util.List; @Api(tags = "Address Entity") @RepositoryRestResource(path = "addresses") public interface AddressRepository extends PagingAndSortingRepository
{ - @ApiOperation("find all Addresses that are associated with a given Customer") - List findByCustomerId(@Param("customerId") @RequestParam @ApiParam(name="customerId", value="ID of the customer") Long customerId); + @ApiOperation("find all Addresses that are associated with a given Customer") + List findByCustomerId(@Param("customerId") @ApiParam(name = "customerId", value = "ID of the customer", type = "body") Long customerId); - @Override - @SuppressWarnings("unchecked") - @ApiOperation("saves a new Address") - Address save(Address address); + @Override + @SuppressWarnings("unchecked") + @ApiOperation("saves a new Address") + @ApiResponses({@ApiResponse(code = 201, message = "Created", response = Address.class)}) + Address save(Address address); } diff --git a/spring-data-rest-springfox/src/main/java/com/example/demo/SpringfoxConfiguration.java b/spring-data-rest-springfox/src/main/java/com/example/demo/SpringfoxConfiguration.java index 5d1f786..00576de 100644 --- a/spring-data-rest-springfox/src/main/java/com/example/demo/SpringfoxConfiguration.java +++ b/spring-data-rest-springfox/src/main/java/com/example/demo/SpringfoxConfiguration.java @@ -8,16 +8,14 @@ import springfox.documentation.service.Tag; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; -import javax.servlet.ServletContext; - @Configuration public class SpringfoxConfiguration { - @Bean - public Docket restApi(ServletContext servletContext) { - return new Docket(DocumentationType.SWAGGER_2) - .tags(new Tag("Address Entity", "Repository for Address entities")) - .apiInfo(new ApiInfo("Customer Service API", "REST API of the Customer Service", "v42", null, null, null, null, Lists.newArrayList())); - } + @Bean + public Docket docket() { + return new Docket(DocumentationType.SWAGGER_2) + .tags(new Tag("Address Entity", "Repository for Address entities")) + .apiInfo(new ApiInfo("Customer Service API", "REST API of the Customer Service", "v42", null, null, null, null, Lists.newArrayList())); + } }