swagger-api / swagger-api/swagger-codegen-generators
[SPRING] OAuth2 scopes missing
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
- when setting security scopes in api definition they should be in the generated code too
@ApiOperation(value = "Get Data", nickname = "getData", notes = "", response = Data.class, authorizations = {
@Authorization(value = "oAuth", scopes = {
<the scopes list should be inserted here>
})
}, tags={ "data", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "data", response = Data.class),
@ApiResponse(code = 200, message = "unexpected error", response = Error.class) })
@RequestMapping(value = "/data",
produces = { "application/json" },
method = RequestMethod.GET)
ResponseEntity<Data> getData();
my api definition looks like:
/data:
get:
summary: Get Data
operationId: getData
tags:
- data
responses:
'200':
description: data
content:
application/json:
schema:
$ref: "#/components/schemas/Data"
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
security:
- oAuth: ["data:read"]
components:
securitySchemes:
oAuth:
type: oauth2
flows:
authorizationCode:
authorizationUrl: https://example.com/oauth/authorize
tokenUrl: https://example.com/oauth/token
scopes:
- data:read
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
Use the provided OpenAPI security block and generated Spring @ApiOperation example as the reproduction, then locate the Spring generator template responsible for rendering authorization scopes. Done means the generated Java annotation includes the data:read scope for the shown endpoint and preserves the existing OAuth2 authorization structure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100