swagger-api / swagger-api/swagger-codegen-generators

JavaJAXRSSpecServerCodegen never add security scopes to @Operation annotations

Open
#776 1 comment 1 reaction 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.