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.32k stars 6.45k forks source link

[REQ] [typescript-angular]: Support securityScheme type 'openIdConnect' like type 'oauth2' is already supported #4406

Open aanno2 opened 4 years ago

aanno2 commented 4 years ago

Is your feature request related to a problem? Please describe.

Support securityScheme type 'openIdConnect' like type 'oauth2' is already supported.

If your securitrySchemes includes something like:

    "securitySchemes": {
      "oAuth2Flows": {
        "type": "oauth2",
        "flows": {
          "implicit": {
            "authorizationUrl": "${KEYCLOAK_BASE_URL}/auth/realms/zap/protocol/openid-connect/auth",
            "scopes": {
              "openid": "description"
            }
          }
        }
      }

openapi-generator emits the following inside API calls:

        // authentication (oAuth2Flows) required
        if (this.configuration.accessToken) {
            const accessToken = typeof this.configuration.accessToken === 'function'
                ? this.configuration.accessToken()
                : this.configuration.accessToken;
            headers = headers.set('Authorization', 'Bearer ' + accessToken);
        }

This is all right, as the client needs to send the (OAuth2) bearer token to the server.

However, for the type 'openIdConnect', the code is not generated.

    "securitySchemes": {
      "kcqs": {
        "type": "openIdConnect",
        "openIdConnectUrl": "\${KEYCLOAK_BASE_URL}/auth/realms/zap/.well-known/openid-configuration"
      }
    }

Result:

        // authentication (kcqs) required
        // nothing follows

Describe the solution you'd like

The very same code must be generated for type 'openIdConnect' and type 'oauth2'.

auto-labeler[bot] commented 4 years ago

👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.