swagger-api / swagger-api/swagger-codegen-generators
JavaJAXRSSpecServerCodegen never add security scopes to @Operation annotations
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
the generator JavaJAXRSSpecServerCodegen uses a template apiInterface.mustache when interfaceOnly is set to true. Unluckily, if I set oauth2 security scheme and security tag I obtain a beautiful Java interface annotated with @Operation but no scope refered because processed as a list whereas it is a Map.
@Operation(summary = "blabla.....", description = "", security = {
@SecurityRequirement(name = "my_auth", scopes = {
"",
}) }, tags={ "atag" })
I can fix this by override apiInterface.mustache and replace
scopes = {
{{#scopes}}"{{scope}}"{{#hasMore}},
{{/hasMore}}{{/scopes}} ....
by
scopes = {
{{#each scopes}}"{{@key}}"{{^@last}},{{/@last}}{{/each}}
How can I provide A Pull Request ?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with apiInterface.mustache, used by JavaJAXRSSpecServerCodegen when interfaceOnly is true, and inspect how scopes are rendered in the @Operation annotation. Ensure the generated annotation emits OAuth2 scope map keys rather than treating scopes as a list. Regenerate an interface with an OAuth2 security scheme and security tag to confirm the scopes appear correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100