package com.lance.springfox.common;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.google.common.base.Predicate;
import com.google.common.base.Predicates;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
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 adminApi(){
		return new Docket(DocumentationType.SWAGGER_2)
				.groupName("Admin API")
				.forCodeGeneration(true)
				.pathMapping("/")
				.select()
				.paths(paths())
				.build()
				.apiInfo(apiInfo())
				.useDefaultResponseMessages(false);
	}
	
	private Predicate<String> paths(){
		return Predicates.and(PathSelectors.regex("/.*"), Predicates.not(PathSelectors.regex("/error")));
	}
	
	
	private ApiInfo apiInfo(){
		Contact contact = new Contact("lance", "https://github.com/leelance", "81222045@qq.com");
		return new ApiInfoBuilder()
				.title("Document Api")
				.description("Spring-boot-Springfox Example")
				.license("Apache License Version 2.0")
				.contact(contact)
				.version("2.0")
				.build();
	}
}

@@ -188,50 +188,8 @@
 ate;
-%0Aimport com.google.common.base.Predicates;
 %0A%0Aim
@@ -965,23 +965,8 @@
 urn 
-Predicates.and(
 Path
@@ -986,60 +986,23 @@
 ex(%22
-/.*%22), Predicates.not(PathSelectors.regex(%22/error%22))
+%5E/(?!error).*$%22
 );%0A%09

update swagger path error