micronaut 有没有办法像我们在 spring-boot 中通过 spec.yaml 文件那样生成端点?
我们的代码代表一个端点
@Override
public ResponseEntity<UserDetailsDto> createUser(UserDto userDto) {
User user = repository.save(new User(userDto.getName(), userDto.getEmail()));
return ResponseEntity.ok().body(new UserDetailsDto(user.getId(), userDto.getName(), userDto.getEmail()));
}
通过 Spring Boot OpenAPI 生成器生成的端点
/**
* POST /users : Create a new user
* Create a new user
*
* @param userDto (required)
* @return successful operation (status code 200)
*/
@ApiOperation(value = "Create a new user", nickname = "createUser", notes = "Create a new user", response = UserDetailsDto.class, tags={ "users", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = UserDetailsDto.class) })
@RequestMapping(value = "/users",
produces = { "application/json" },
consumes = { "application/json" },
method = RequestMethod.POST)
ResponseEntity<UserDetailsDto> createUser(@ApiParam(value = "" ,required=true ) @Valid @RequestBody UserDto userDto);