Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][java-micronaut-server] Illegal codegeneration for security schemes #15428

Open
5 of 6 tasks
rost5000 opened this issue May 5, 2023 · 1 comment
Open
5 of 6 tasks

Comments

@rost5000
Copy link

rost5000 commented May 5, 2023

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • 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
  1. clone the project: https://github.com/rost5000/micronaut-server-openapi.git
  2. assemble the project: ./gradlew clean build
  3. 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")

@altro3
Copy link
Contributor

altro3 commented Aug 27, 2024

@rost5000 Fixed it here: micronaut-projects/micronaut-openapi#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants