[BUG][java-micronaut-server] Illegal codegeneration for security schemes
Bug Report Checklist
- [x] Have you provided a full/minimal spec to reproduce the issue?
- [x] Have you validated the input using an OpenAPI validator (example)?
- [x] Have you tested with the latest master to confirm the issue still exists?
- [x] Have you searched for related issues/PRs?
- [x] What's the actual output vs expected output?
- [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I try to create RBAC authentication based on micronaut controller.
The micronaut controller was generated from openapi spec. The generator ignores the scope of the securitySchemes. I expected the security scopes in @Secured annotation. The generated file contains: @Secured({SecurityRule.IS_AUTHENTICATED}), but expected annotations like: @Secured({"write", "read"})
openapi-generator version
OpenAPI declaration file content or url
Here is a link: https://github.com/rost5000/micronaut-server-openapi/blob/master/src/main/resources/openapi.yaml
Generation Details
- gradle openapi generator plugin
- java-micronaut-server
Steps to reproduce
- clone the project: https://github.com/rost5000/micronaut-server-openapi.git
- assemble the project:
./gradlew clean build - The generated code is in build/generate-resources/main/src/main/java/com/example/api/AbstractDefaultController.java
Related issues/PRs
Suggest a fix
I suggest that openapi generator load scopes information from /security or /components/securitySchemes I expect to see in generated controllers the scopes of the security, like @Secured("write", "admin")
@rost5000 Fixed it here: https://github.com/micronaut-projects/micronaut-openapi/pull/1733
Just use official micronaut generator for java and kotlin by micronaut-opeanpi gradle or maven plugin from this repo: https://github.com/micronaut-projects/micronaut-openapi
Look to this guide: https://guides.micronaut.io/latest/micronaut-openapi-generator-server.html
Also, please describe problems and suggestions here: https://github.com/micronaut-projects/micronaut-openapi/issues