swagger
This commit is contained in:
@@ -81,6 +81,18 @@
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>io.springfox</groupId>-->
|
||||
<!-- <artifactId>springfox-boot-starter</artifactId>-->
|
||||
<!-- <version>3.0.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -2,6 +2,10 @@ package com.example.restfulwebservice.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
@@ -16,19 +20,35 @@ import java.util.Set;
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
public class SwaggerConfig {
|
||||
private static final Contact DEFAULT_CONTACT = new Contact("Kim",
|
||||
"http://www.joneconsulting.co.kr", "email@naver.com");
|
||||
private static final ApiInfo DEFAULT_API_INFO = new ApiInfo("Awesome Api Title",
|
||||
"My User management REST API service", "1.0", "uri:tos",
|
||||
DEFAULT_CONTACT, "Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0", new ArrayList<>());
|
||||
private static final Set<String> DEFAULT_PRODUCES_AND_CONSUMES = new HashSet<>(
|
||||
Arrays.asList("application/json", "application/xml"));
|
||||
// private static final Contact DEFAULT_CONTACT = new Contact("Kim",
|
||||
// "http://www.joneconsulting.co.kr", "email@naver.com");
|
||||
// private static final ApiInfo DEFAULT_API_INFO = new ApiInfo("Awesome Api Title",
|
||||
// "My User management REST API service", "1.0", "uri:tos",
|
||||
// DEFAULT_CONTACT, "Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0", new ArrayList<>());
|
||||
// private static final Set<String> DEFAULT_PRODUCES_AND_CONSUMES = new HashSet<>(
|
||||
// Arrays.asList("application/json", "application/xml"));
|
||||
|
||||
// @Bean
|
||||
// public Docket api() {
|
||||
// return new Docket(DocumentationType.SWAGGER_2)
|
||||
// .apiInfo(DEFAULT_API_INFO)
|
||||
// .produces(DEFAULT_PRODUCES_AND_CONSUMES)
|
||||
// .consumes(DEFAULT_PRODUCES_AND_CONSUMES);
|
||||
// }
|
||||
|
||||
// @Bean
|
||||
// public Docket apiDocket() {
|
||||
// return new Docket(DocumentationType.SWAGGER_2)
|
||||
// .select()
|
||||
// .apis(RequestHandlerSelectors.any())
|
||||
// .paths(PathSelectors.any())
|
||||
// .build();
|
||||
// }
|
||||
@Bean
|
||||
public Docket api() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(DEFAULT_API_INFO)
|
||||
.produces(DEFAULT_PRODUCES_AND_CONSUMES)
|
||||
.consumes(DEFAULT_PRODUCES_AND_CONSUMES);
|
||||
public Docket produceApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2).select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.example.restfulwebservice"))
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class UserJpaController {
|
||||
post.setUser(user.get());
|
||||
Post savedPost = postRepository.save(post);
|
||||
|
||||
URI location = ServletUriComponentsBuilder. ()
|
||||
URI location = ServletUriComponentsBuilder.fromCurrentRequest()
|
||||
.path("/{id}")
|
||||
.buildAndExpand(savedPost.getId())
|
||||
.toUri();
|
||||
|
||||
@@ -3,7 +3,7 @@ server:
|
||||
|
||||
logging:
|
||||
level:
|
||||
org.springframework: DEBUG
|
||||
org.springframework: INFO
|
||||
|
||||
spring:
|
||||
messages:
|
||||
@@ -25,7 +25,6 @@ spring:
|
||||
username: sa
|
||||
password:
|
||||
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
|
||||
Reference in New Issue
Block a user