Skip to content

[BUG] Typescript/Angular generator does not handle authorization header for OIDC security schemes #21245

@bgiddens

Description

@bgiddens

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Relevant code is here.

When handling auth methods, the Typescript/Angular generator implements a method call to add the authorization token to the request headers or query. It does this for the api_key, http, or oauth2 security scheme types, but does nothing for the openIdConnect type, resulting in a comment in the generated code indicating the need for authorization, but no actual implementation. The resulting generated services fail authorization as a result.

openapi-generator version

7.12.0
(issue confirmed in source for 4cffd32f87224e54a60813e1fc9da73788977e54)

Steps to reproduce

Run typescript/angular generator for any OpenAPI file with an operation implementing a security scheme of type openIdConnect.

Suggest a fix

The issue is visible in source and the fix should be simple, which is why I have not bothered to create a sample spec. To resolve this, the OIDC case should add a bearer token in the authorization header by the same approach as the OAuth2 case. For observability, it may also be worth issuing a warning in the event that the auth method is present but none of these type-specific cases are triggered (helpful in the event that the spec is extended for other security scheme types, resulting in a similar issue to this one).

As a workaround in the interim, OpenAPI docs can be modified to document the security scheme as OAuth2 rather than OIDC, at least for purposes of code generation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions