webflux springdoc-openapi

1
2
3
4
5
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webflux-ui</artifactId>
<version>1.6.7</version>
</dependency>

code

1
2
3
4
5
6
7
8
9
@SpringBootApplication
@OpenAPIDefinition(info = @Info(title = "APIs", version = "1.0", description = "Documentation APIs v1.0"))
public class ApisApplication {

public static void main(String[] args) {
SpringApplication.run(ApisApplication.class, args);
}

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
@RestController
@Tag(name = "Test APIs", description = "Test APIs for demo purpose")
public class TestController {

@GetMapping("test")
@Operation(description = "Get a test model demo", parameters = {
@Parameter(name = "name", in = ParameterIn.QUERY, required = true, description = "name parameter")
})
public Mono<TestDto> getTestDto(final @RequestParam String name,
final ServerWebExchange exchange) {
TestDto testDto = new TestDto();
testDto.setName(name);
testDto.setAge(0);
testDto.setName("Welcome "+name);
return Mono.just(testDto);
}

@PostMapping("test")
@Operation(description = "Create a test model demo", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody())
public Mono<TestDto> postTestDto(@Valid @RequestBody final TestDto testDto,
final ServerWebExchange exchange) {
return Mono.just(testDto);
}

}

my demo

参考文章

评论