Skip to content

Instantly share code, notes, and snippets.

@indrabasak
Created July 24, 2017 16:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indrabasak/6c20d618324a6e14950b98354ee6d169 to your computer and use it in GitHub Desktop.
Save indrabasak/6c20d618324a6e14950b98354ee6d169 to your computer and use it in GitHub Desktop.
@Configuration
@EnableSwagger2
public class MySwaggerConfiguration {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("myApis")
.select()
.apis(exactPackage("com.basaki.example.controller"))
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo("My Example API", "API Example"));
}
private ApiInfo apiInfo(String title, String description) {
Contact contact = new Contact("Indra Basak", "",
"developer@gmail.com");
return new ApiInfo(title, description, "1.0", "terms of service url",
contact, "license", "license url");
}
private static Predicate exactPackage(final String pkg) {
return input -> declaringClass(input).getPackage().getName().equals(
pkg);
}
private static Class declaringClass(RequestHandler input) {
return input.declaringClass();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment