|
@@ -0,0 +1,49 @@
|
|
1
|
+package com.yaozhitech.spring5.config;
|
|
2
|
+
|
|
3
|
+import java.util.Optional;
|
|
4
|
+
|
|
5
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
6
|
+import org.springframework.http.HttpStatus;
|
|
7
|
+import org.springframework.http.ResponseEntity;
|
|
8
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
9
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
10
|
+import org.springframework.web.bind.annotation.RestController;
|
|
11
|
+
|
|
12
|
+import reactor.core.publisher.Mono;
|
|
13
|
+import springfox.documentation.swagger.web.*;
|
|
14
|
+
|
|
15
|
+@RestController
|
|
16
|
+@RequestMapping("/swagger-resources")
|
|
17
|
+public class SwaggerHandler {
|
|
18
|
+
|
|
19
|
+ @Autowired(required = false)
|
|
20
|
+ private SecurityConfiguration securityConfiguration;
|
|
21
|
+
|
|
22
|
+ @Autowired(required = false)
|
|
23
|
+ private UiConfiguration uiConfiguration;
|
|
24
|
+
|
|
25
|
+ private final SwaggerResourcesProvider swaggerResources;
|
|
26
|
+
|
|
27
|
+ @Autowired
|
|
28
|
+ public SwaggerHandler(SwaggerResourcesProvider swaggerResources) {
|
|
29
|
+ this.swaggerResources = swaggerResources;
|
|
30
|
+ }
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+ @GetMapping("/configuration/security")
|
|
34
|
+ public Mono<ResponseEntity<SecurityConfiguration>> securityConfiguration() {
|
|
35
|
+ return Mono.just(new ResponseEntity<>(
|
|
36
|
+ Optional.ofNullable(securityConfiguration).orElse(SecurityConfigurationBuilder.builder().build()), HttpStatus.OK));
|
|
37
|
+ }
|
|
38
|
+
|
|
39
|
+ @GetMapping("/configuration/ui")
|
|
40
|
+ public Mono<ResponseEntity<UiConfiguration>> uiConfiguration() {
|
|
41
|
+ return Mono.just(new ResponseEntity<>(
|
|
42
|
+ Optional.ofNullable(uiConfiguration).orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK));
|
|
43
|
+ }
|
|
44
|
+
|
|
45
|
+ @GetMapping("")
|
|
46
|
+ public Mono<ResponseEntity> swaggerResources() {
|
|
47
|
+ return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK)));
|
|
48
|
+ }
|
|
49
|
+}
|