OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.49k stars 6.5k forks source link

[BUG] [SPRING-CLOUD] Security config is not wrong for feign client #16049

Open MelleD opened 1 year ago

MelleD commented 1 year ago

If there are multiple security schemes, the Feign client will simply use all of them instead of the assigned one.

Example

  /foo:
    get:
    ...
      security:
        - foo: [ ]
  /bar:
    get:
    ...
      security:
        - bar: [ ]

  securitySchemes:
    foo:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: 'foo/auth'
          tokenUrl: 'foo/token'
          scopes: { }
        clientCredentials:
          tokenUrl: '/foo/token'
          scopes: { }
    bar:
      type: http
      scheme: basic

However, the Feign client always uses ALL secruity methods instead of a special one. I know how to fix the ClientConfiguration.

However, I have problems at this point. How do I find out which secruity (bar or foo) was assigned to the resource?

Code:

@FeignClient(name="${{openbrace}}{{classVarName}}.name:{{classVarName}}{{closebrace}}", {{#useFeignClientUrl}}url="${{openbrace}}{{classVarName}}.url:{{basePath}}{{closebrace}}", {{/useFeignClientUrl}}configuration = ClientConfiguration.class)
public interface {{classname}}Client extends {{classname}} {
}

Here in the last line I need a if or the information which security method is assignedconfiguration = ClientConfiguration.class

Is there a possibilty to get this information? @wing328 @welshm @borsch any ideas?

borsch commented 1 year ago

@MelleD at "postProcessOperations" write code that would figure out which security schema is applied to that particular operation?