swagger-codegen-generators icon indicating copy to clipboard operation
swagger-codegen-generators copied to clipboard

[SPRING] OAuth2 scopes missing

Open MBcom opened this issue 6 years ago • 1 comments

  • 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

MBcom avatar Jan 10 '19 19:01 MBcom

Hi,

Is there any progress on this?

Thank you!

cazacugmihai avatar Aug 04 '21 13:08 cazacugmihai