polishing

This commit is contained in:
Tom Hombergs
2017-08-02 23:15:20 +02:00
parent 57aa1b3d00
commit 42bd620471
3 changed files with 18 additions and 24 deletions

View File

@@ -20,15 +20,16 @@ sourceCompatibility = 1.8
repositories { repositories {
mavenLocal() mavenLocal()
mavenCentral() mavenCentral()
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local/' }
} }
dependencies { dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa') compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-data-rest') compile('org.springframework.boot:spring-boot-starter-data-rest')
compile('io.springfox:springfox-data-rest:2.7.0') compile('io.springfox:springfox-data-rest:2.7.1-SNAPSHOT')
compile('io.springfox:springfox-swagger2:2.7.0') compile('io.springfox:springfox-swagger2:2.7.1-SNAPSHOT')
compile('io.springfox:springfox-swagger-ui:2.7.0') compile('io.springfox:springfox-swagger-ui:2.7.1-SNAPSHOT')
compile('com.h2database:h2:1.4.196') compile('com.h2database:h2:1.4.196')
testCompile('org.springframework.boot:spring-boot-starter-test') testCompile('org.springframework.boot:spring-boot-starter-test')
} }

View File

@@ -1,28 +1,23 @@
package com.example.demo; package com.example.demo;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.data.domain.Page;
import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource; import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.web.bind.annotation.RequestParam;
import java.awt.print.Pageable;
import java.util.List; import java.util.List;
@Api(tags = "Address Entity") @Api(tags = "Address Entity")
@RepositoryRestResource(path = "addresses") @RepositoryRestResource(path = "addresses")
public interface AddressRepository extends PagingAndSortingRepository<Address, Long> { public interface AddressRepository extends PagingAndSortingRepository<Address, Long> {
@ApiOperation("find all Addresses that are associated with a given Customer") @ApiOperation("find all Addresses that are associated with a given Customer")
List<Address> findByCustomerId(@Param("customerId") @RequestParam @ApiParam(name="customerId", value="ID of the customer") Long customerId); List<Address> findByCustomerId(@Param("customerId") @ApiParam(name = "customerId", value = "ID of the customer", type = "body") Long customerId);
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ApiOperation("saves a new Address") @ApiOperation("saves a new Address")
Address save(Address address); @ApiResponses({@ApiResponse(code = 201, message = "Created", response = Address.class)})
Address save(Address address);
} }

View File

@@ -8,16 +8,14 @@ import springfox.documentation.service.Tag;
import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
import javax.servlet.ServletContext;
@Configuration @Configuration
public class SpringfoxConfiguration { public class SpringfoxConfiguration {
@Bean @Bean
public Docket restApi(ServletContext servletContext) { public Docket docket() {
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2)
.tags(new Tag("Address Entity", "Repository for Address entities")) .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())); .apiInfo(new ApiInfo("Customer Service API", "REST API of the Customer Service", "v42", null, null, null, null, Lists.newArrayList()));
} }
} }