forked from rongchao/epmet-cloud-rizhao
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.9 KiB
58 lines
1.9 KiB
/**
|
|
* Copyright (c) 2018 人人开源 All rights reserved.
|
|
*
|
|
* https://www.renren.io
|
|
*
|
|
* 版权所有,侵权必究!
|
|
*/
|
|
|
|
package com.epmet.swagger;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import reactor.core.publisher.Mono;
|
|
import springfox.documentation.swagger.web.*;
|
|
|
|
import java.util.Optional;
|
|
|
|
/**
|
|
* Swagger
|
|
*
|
|
* @author Mark sunlightcs@gmail.com
|
|
* @since 1.0.0
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/swagger-resources")
|
|
public class SwaggerHandler {
|
|
@Autowired(required = false)
|
|
private SecurityConfiguration securityConfiguration;
|
|
@Autowired(required = false)
|
|
private UiConfiguration uiConfiguration;
|
|
private final SwaggerResourcesProvider swaggerResources;
|
|
|
|
@Autowired
|
|
public SwaggerHandler(SwaggerResourcesProvider swaggerResources) {
|
|
this.swaggerResources = swaggerResources;
|
|
}
|
|
|
|
@GetMapping("/configuration/security")
|
|
public Mono<ResponseEntity<SecurityConfiguration>> securityConfiguration() {
|
|
return Mono.just(new ResponseEntity<>(
|
|
Optional.ofNullable(securityConfiguration).orElse(SecurityConfigurationBuilder.builder().build()), HttpStatus.OK));
|
|
}
|
|
|
|
@GetMapping("/configuration/ui")
|
|
public Mono<ResponseEntity<UiConfiguration>> uiConfiguration() {
|
|
return Mono.just(new ResponseEntity<>(
|
|
Optional.ofNullable(uiConfiguration).orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK));
|
|
}
|
|
|
|
@GetMapping
|
|
public Mono<ResponseEntity> swaggerResources() {
|
|
return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK)));
|
|
}
|
|
}
|
|
|