Skip to content

[BUG][typescript-angular] apiKeys cause service compilation errors #22774

Description

@saxicek

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

Use of apiKey in the query causes uncompilable service code. It generates:

        // authentication (SessionIdAuth) required
        localVarQueryParameters = this.configuration.addCredentialToQuery('SessionIdAuth', 'sid', localVarQueryParameters);

This is failing to compile with the error:

Type 'HttpParams' is missing the following properties from type 'OpenApiHttpParams': params, defaults, resolveOptions, toRecord, toHttpParamsts(2739)

openapi-generator version

Used version 7.19.0 and also latest master.

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: Test API key in query
  version: v1
paths:
    /pet-store:
      get:
        operationId: get
        parameters:
          - name: id
            in: query
            required: true
            schema:
              type: string
        responses:
          '200':
            description: Successful operation
components:
  securitySchemes:
    SessionIdAuth:
      type: apiKey
      in: query
      name: sid
security:
  - SessionIdAuth: []

Also available at https://gist.github.com/saxicek/43daa70a6d95dece378f5729517cb0c1/raw/798d83b853e589451ef39b0d81fe13b232f06d87/api_key_query.yaml

Generation Details
Steps to reproduce
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
   -i api_key_query.yaml \
   -g typescript-angular \
   -o ./typescript-angular
Related issues/PRs
Suggest a fix

I think we can simply change addCredentialToQuery method signature to work with OpenApiHttpParams instead of HttpParams. I will submit a PR for that.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions