'How to generate endpoints for micronaut via OpenApi Generator?

Is there a way in micronaut to generate endpoints in a way like we do it in spring-boot via spec.yaml file?

our code represented an endpoint

@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()));
}

endpoint generated via spring boot openapi generator

/**
 * 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);


Solution 1:[1]

I've found the solution. I used java-micronaut-client and it generates endpoints described in spec.yaml file and DTOs. But micronaut-client generator only has a beta-version.

Solution 2:[2]

If you want a complete command line to generate a client using npx.

You could use this one :

npx @openapitools/openapi-generator-cli generate -i https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.yaml -g java-micronaut-client -o /tmp

This command will generate a micronaut client of the petstore in the /tmp folder.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Oleh Kuzmenko
Solution 2 Michael COLL