Skip to content

Commit

Permalink
Merge pull request #36 from urashin/base-api-impl
Browse files Browse the repository at this point in the history
SpringFoxを使ってRest APIドキュメントを自動生成する仕組みを追加
  • Loading branch information
urashin authored Feb 26, 2022
2 parents 32349e8 + 75d908f commit c0d2bb1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
14 changes: 9 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ repositories {

dependencies {
//implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'mysql:mysql-connector-java'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf:2.6.0'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc:2.6.0'
implementation 'org.springframework.boot:spring-boot-starter-jdbc:2.6.0'
implementation 'org.springframework.boot:spring-boot-starter-web:2.6.0'
implementation 'io.springfox:springfox-swagger2:2.8.0'
implementation 'io.springfox:springfox-swagger-ui:2.8.0'
implementation 'io.springfox:springfox-core:2.8.0'
implementation 'javax.xml.bind:jaxb-api'
implementation 'mysql:mysql-connector-java:8.0.27'
implementation 'com.auth0:java-jwt:3.8.2'
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.0'
//implementation 'com.google.code.gson:gson:2.7'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.microvolunteer.platform.config;

import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
@Bean
public Docket swaggerSpringMvcPlugin() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("micro-volunteer-api") // APIドキュメントをグルーピングするための識別名
.select()
.paths(paths())
.build()
.apiInfo(apiInfo());
}

private Predicate<String> paths() {
return Predicates.or(Predicates.containsPattern("/v1/api*"));
}

private ApiInfo apiInfo() {
ApiInfo apiInfo = new ApiInfo("micro-volunteer API", "micro-volunteer platformを利用するためのAPIです。",
"v1", "", "http://micro-volunteer-supporter.com", "", "");
return apiInfo;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


@RestController
@RequestMapping("/v1")
@RequestMapping("/v1/api")
@Slf4j
public class Controller {
private Logger logger = LoggerFactory.getLogger(Controller.class);
Expand Down

0 comments on commit c0d2bb1

Please sign in to comment.