@Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .produces(Sets.newHashSet("application/json")) .consumes(Sets.newHashSet("application/json")) .protocols(Sets.newHashSet("http", "https")) .apiInfo(apiInfo()) .forCodeGeneration(true) .useDefaultResponseMessages(false).select() .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) .paths(PathSelectors.any()).build(); }
/** * Springfox configuration for the management endpoints (actuator) Swagger docs. * * @param appName the application name * @param managementContextPath the path to access management endpoints * @param appVersion the application version * @return the Swagger Springfox configuration */ @Bean public Docket swaggerSpringfoxManagementDocket(@Value("${spring.application.name}") String appName, @Value("${management.context-path}") String managementContextPath, @Value("${info.project.version}") String appVersion) { return createDocket() .apiInfo(new ApiInfo(appName + " " + MANAGEMENT_TITLE_SUFFIX, MANAGEMENT_DESCRIPTION, appVersion, "", ApiInfo.DEFAULT_CONTACT, "", "", new ArrayList<>())) .groupName(MANAGEMENT_GROUP_NAME) .host(properties.getHost()) .protocols(new HashSet<>(Arrays.asList(properties.getProtocols()))) .forCodeGeneration(true) .directModelSubstitute(java.nio.ByteBuffer.class, String.class) .genericModelSubstitutes(ResponseEntity.class) .select() .paths(regex(managementContextPath + ".*")) .build(); }
.groupName(MANAGEMENT_GROUP_NAME) .host(properties.getHost()) .protocols(new HashSet<>(Arrays.asList(properties.getProtocols()))) .forCodeGeneration(true) .directModelSubstitute(ByteBuffer.class, String.class)
.protocols(new HashSet<>(Arrays.asList(properties.getProtocols()))) .apiInfo(apiInfo) .forCodeGeneration(true)
@Override public void customize(Docket docket) { Contact contact = new Contact( properties.getContactName(), properties.getContactUrl(), properties.getContactEmail() ); ApiInfo apiInfo = new ApiInfo( properties.getTitle(), properties.getDescription(), properties.getVersion(), properties.getTermsOfServiceUrl(), contact, properties.getLicense(), properties.getLicenseUrl(), new ArrayList<>() ); docket.host(properties.getHost()) .protocols(new HashSet<>(Arrays.asList(properties.getProtocols()))) .apiInfo(apiInfo) .useDefaultResponseMessages(properties.isUseDefaultResponseMessages()) .forCodeGeneration(true) .directModelSubstitute(ByteBuffer.class, String.class) .genericModelSubstitutes(ResponseEntity.class) .ignoredParameterTypes(Pageable.class) .select() .paths(regex(properties.getDefaultIncludePattern())) .build(); }