@Bean public Docket practiceApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.sdcuike.practice")) .paths(PathSelectors.any()) .build() .pathMapping("/") .genericModelSubstitutes(ResponseEntity.class) .alternateTypeRules( newRule(typeResolver.resolve(DeferredResult.class, typeResolver.resolve(ResponseEntity.class, WildcardType.class)), typeResolver.resolve(WildcardType.class))) .useDefaultResponseMessages(false) .globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder() .code(500) .message("500 message") .responseModel(new ModelRef("Error")) .build())) .enableUrlTemplating(true) .tags(new Tag("Pet Service", "All apis relating to pets")); }
private List<ResponseMessage> errorList() { List<ResponseMessage> lista = new ArrayList<ResponseMessage>(); lista.add(new ResponseMessageBuilder().code(500).message("500 message").responseModel(new ModelRef("ErrorRestService")).build()); lista.add(new ResponseMessageBuilder().code(400).message("Bad Request").responseModel(new ModelRef("ErrorRestService")).build()); lista.add(new ResponseMessageBuilder().code(401).message("Non Autorizzato").responseModel(new ModelRef("ErrorRestService")).build()); lista.add(new ResponseMessageBuilder().code(412).message("Errore Validazione").responseModel(new ModelRef("ErrorRestService")).build()); return lista; }
@Bean public Docket petApi() { return new Docket(DocumentationType.SWAGGER_2) .select() // .apis(RequestHandlerSelectors.any()) .apis(RequestHandlerSelectors.basePackage("com.tvajjala.resource")) .paths(PathSelectors.any()) // .paths(PathSelectors.ant("/api/*")) .build() .apiInfo(apiInfo()) .pathMapping("/api") // .directModelSubstitute(LocalDate.class, String.class) .genericModelSubstitutes(ResponseEntity.class) .alternateTypeRules( newRule(typeResolver.resolve(DeferredResult.class, typeResolver.resolve(ResponseEntity.class, WildcardType.class)), typeResolver.resolve(WildcardType.class))) .useDefaultResponseMessages(false) .globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder().code(500).message("500 message").responseModel(new ModelRef("Error")).build())) .securitySchemes(newArrayList(apiKey())).securityContexts(newArrayList(securityContext())); }
@Bean public Docket petApi() { return new Docket(DocumentationType.SWAGGER_2) .select() // .apis(RequestHandlerSelectors.any()) .apis(RequestHandlerSelectors.basePackage("com.tvajjala.web.resource")) .paths(PathSelectors.any()) // .paths(PathSelectors.ant("/api/*")) .build() .apiInfo(apiInfo()) .pathMapping("/api") // .directModelSubstitute(LocalDate.class, String.class) .genericModelSubstitutes(ResponseEntity.class) .alternateTypeRules( newRule(typeResolver.resolve(DeferredResult.class, typeResolver.resolve(ResponseEntity.class, WildcardType.class)), typeResolver.resolve(WildcardType.class))) .useDefaultResponseMessages(false) .globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder().code(500).message("500 message").responseModel(new ModelRef("Error")).build())) .securitySchemes(newArrayList(apiKey())).securityContexts(newArrayList(securityContext())); }
@Bean public Docket medicamentApi() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.regex("/api/.*")) .build() .pathMapping("/") .apiInfo(apiInfo()) .directModelSubstitute(LocalDate.class, String.class) .genericModelSubstitutes(ResponseEntity.class) .alternateTypeRules( newRule(typeResolver.resolve(DeferredResult.class, typeResolver.resolve(ResponseEntity.class, WildcardType.class)), typeResolver.resolve(WildcardType.class))) .useDefaultResponseMessages(false) .globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder() .code(500) .message("500 message") .responseModel(new ModelRef("Error")) .build())) .enableUrlTemplating(false); }
@Bean public Docket petApi() { return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any()).paths(PathSelectors.any()).build().pathMapping("/") .apiInfo(new ApiInfo( "Peregrine Event Service", "Peregrine Event Service is a canonical implementation of the Event store pattern", "0.0.1", "", "Alliance Foundry, a Fidelity Investments Open Source Project", "Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0.html")) .consumes(new HashSet<String>(Arrays.asList("application/json"))) .produces(new HashSet<String>(Arrays.asList("application/json"))) .protocols(new HashSet<String>(Arrays.asList("http"))) .directModelSubstitute(LocalDate.class, String.class) .directModelSubstitute(DateTime.class, String.class) .genericModelSubstitutes(ResponseEntity.class) .alternateTypeRules(newRule(typeResolver.resolve(DeferredResult.class, typeResolver.resolve(ResponseEntity.class, WildcardType.class)), typeResolver.resolve(WildcardType.class))) .useDefaultResponseMessages(false) .globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder().code(500).message("500 message").responseModel(new ModelRef("Error")).build())); //.securitySchemes(newArrayList(apiKey())).securityContexts(newArrayList(securityContext())); }
@Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.withClassAnnotation(RestController.class)) // .paths(paths()) .build().pathMapping("/").directModelSubstitute(LocalDate.class, String.class) .genericModelSubstitutes(ResponseEntity.class).useDefaultResponseMessages(false) .globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder().code(500).message("500 message") .responseModel(new ModelRef("Error")).build())); }
@Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build() .host("www.tc.com") .pathMapping("/") .genericModelSubstitutes(ResponseEntity.class) .useDefaultResponseMessages(false) .globalResponseMessage( RequestMethod.GET, Lists.newArrayList( new ResponseMessageBuilder() .code(HttpStatus.OK.value()) .message("请求成功") .responseModel(new ModelRef("TcR")) .build() ) ) .globalResponseMessage( RequestMethod.POST, Lists.newArrayList( new ResponseMessageBuilder() .code(HttpStatus.OK.value()) .message("请求成功") .responseModel(new ModelRef("TcR")) .build() ) ) .protocols(Sets.newHashSet("http", "https")); }
@Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build() .pathMapping("/") .directModelSubstitute(LocalDate.class, String.class) .genericModelSubstitutes(ResponseEntity.class) .alternateTypeRules( newRule(typeResolver.resolve(DeferredResult.class, typeResolver.resolve(ResponseEntity.class, WildcardType.class)), typeResolver.resolve(WildcardType.class))) .useDefaultResponseMessages(false) .globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder() .code(500) .message("500 message") .responseModel(new ModelRef("Error")) .build())) .securitySchemes(newArrayList(apiKey())) .securityContexts(newArrayList(securityContext())) .enableUrlTemplating(true) ; }
@Bean public Docket petApi() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build() .pathMapping("/") .directModelSubstitute(LocalDate.class, String.class) .genericModelSubstitutes(ResponseEntity.class) .alternateTypeRules( newRule(typeResolver.resolve(DeferredResult.class, typeResolver.resolve(ResponseEntity.class, WildcardType.class)), typeResolver.resolve(WildcardType.class))) .useDefaultResponseMessages(false) .globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder() .code(500) .message("500 message") .responseModel(new ModelRef("Error")) .build())) .securitySchemes(newArrayList(apiKey())) .securityContexts(newArrayList(securityContext())) .enableUrlTemplating(false) ; }
@Bean public Docket petApi() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build() .pathMapping("/") .directModelSubstitute(LocalDate.class, String.class) .genericModelSubstitutes(ResponseEntity.class) .alternateTypeRules( newRule(typeResolver.resolve(DeferredResult.class, typeResolver.resolve(ResponseEntity.class, WildcardType.class)), typeResolver.resolve(WildcardType.class))) .useDefaultResponseMessages(false) .globalResponseMessage(RequestMethod.GET, asList(new ResponseMessageBuilder() .code(500) .message("500 message") .responseModel(new ModelRef("Error")) .build())) .securitySchemes(asList(apiKey())) .securityContexts(asList(securityContext())) .enableUrlTemplating(true) // .globalOperationParameters( // newArrayList(new ParameterBuilder() // .name("someGlobalParameter") // .description("Description of someGlobalParameter") // .modelRef(new ModelRef("string")) // .parameterType("query") // .required(true) // .build())) // .tags(new Tag("Pet Service", "All apis relating to pets")) // .additionalModels(typeResolver.resolve(AdditionalModel.class)) ; }
@Bean public Docket newsApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build() .protocols(Sets.newHashSet("https")) .pathMapping("/") .directModelSubstitute(Date.class, String.class) .directModelSubstitute(Locale.class, String.class) .useDefaultResponseMessages(false) .produces(Sets.newHashSet("application/json")) .additionalModels(typeResolver.resolve(NpResult.class)) .globalResponseMessage(RequestMethod.GET, Lists.newArrayList(new ResponseMessageBuilder() .code(500) .message("500 message") .responseModel(new ModelRef("NpRequest")) .build())) //.securitySchemes(Lists.newArrayList(apiKey())) //.securityContexts(Lists.newArrayList(securityContext())) .enableUrlTemplating(true) /*.globalOperationParameters( Lists.newArrayList(new ParameterBuilder() .name("someGlobalParameter") .description("Description of someGlobalParameter") .modelRef(new ModelRef("string")) .parameterType("query") .required(true) .build()))*/ .tags(new Tag("Pet Service", "All apis relating to pets")) ; }
private List<ResponseMessage> getDefaultResponseMessage(){ List<ResponseMessage> responseMessages =new ArrayList<ResponseMessage>(); responseMessages.add(new ResponseMessageBuilder().code(500).message(error.get("500")).responseModel(new ModelRef("ErrorInfo")).build()); responseMessages.add(new ResponseMessageBuilder().code(404).message(error.get("404")).responseModel(new ModelRef("ErrorInfo")).build()); return responseMessages; }
private List<ResponseMessage> responseMessageList() { return newArrayList(new ResponseMessageBuilder().code(500).message("Server Error").responseModel(new ModelRef("Error")).build(), new ResponseMessageBuilder().code(401).message("Unauthorized").build()); }