Skip to content

[BUG][typescript-fetch] @deprecated JSDoc missing on operation parameters (parameter isDeprecated always false) #24511

Description

@babariviere

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 and looked for the fix?

Description

typescript-fetch does not emit @deprecated for operation parameters marked deprecated: true in the spec. #11522 / #11523 added @deprecated for operations and model properties, but individual parameters are still undocumented, and when useSingleRequestParameter is enabled the generated XxxRequest parameter interfaces have no JSDoc at all.

Root cause: DefaultCodegen.fromParameter correctly sets CodegenParameter.isDeprecated from the spec, but TypeScriptFetchClientCodegen.ExtendedCodegenParameter's copy constructor copies ~70 fields and omits isDeprecated, resetting it to false. As a result {{#isDeprecated}} is always false for parameters. The operation and model wrappers copy their own isDeprecated, which is why those cases work.

openapi-generator version

master (7.25.0-SNAPSHOT). Present since the Extended* wrappers were introduced in typescript-fetch.

OpenAPI declaration file content to reproduce

openapi: 3.0.3
info: { title: Example API, version: '1.0' }
paths:
  /items:
    get:
      operationId: listItems
      parameters:
        - name: q
          in: query
          description: Free-text search query.
          schema: { type: string }
        - name: legacyId
          in: query
          deprecated: true
          description: Deprecated. Use id instead.
          schema: { type: string }
      responses:
        '200': { description: OK }

Steps to reproduce

java -jar openapi-generator-cli.jar generate -i spec.yaml -g typescript-fetch -o out \
  --additional-properties=useSingleRequestParameter=true

Current output

export interface ListItemsRequest {
    q?: string;
    legacyId?: string;
}

Expected output

export interface ListItemsRequest {
    /**
     * Free-text search query.
     * @type {string}
     * @memberof ListItemsRequest
     */
    q?: string;
    /**
     * Deprecated. Use id instead.
     * @type {string}
     * @memberof ListItemsRequest
     * @deprecated
     */
    legacyId?: string;
}

Related

Suggested fix

Copy isDeprecated in the ExtendedCodegenParameter(CodegenParameter) constructor (as the operation and model wrappers already do), and document the request-parameter interfaces in apis.mustache. PR: #24510

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions