Skip to content

[BUG] [typescript-axios] Duplicate identifier 'options' when URL parameter 'options' exists #23456

@petetnt

Description

@petetnt

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

In the spec we are using there's a parameter called options:

          {
            "name": "options",
            "in": "query",
            "description": "FOO",
            "schema": {
              "type": "string",
              "default": "bar"
            }
          },

When generating the client from this spec, duplicate identified options appears:

    (
      options?: string,
      options?: any,
    ):

This is due to Override http request option parameter being hardcoded as "options" here:

https://github.com/OpenAPITools/openapi-generator/blame/e6ef8ee728c8c2b4d22bc869fc81d3cf819575a7/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache#L46

There's no way to rename this parameter, or disable it as far as I know. Options like "useSingleRequestParameter": true or "ensureUniqueParams": true do not help with this case: the query parameter cannot be renamed and useSingleRequestParameter still uses options in the inner calls even if the public API uses an single object.

openapi-generator version

openapi-generator-cli@2.31.0 / openapi-generator@7.21.0

OpenAPI declaration file content or url
{
  "openapi": "3.0.1",
  "info": {
    "title": "FOO API",
    "description": "FOO API",
    "contact": {
      "name": "FOO",
      "url": "https://foo.com",
      "email": "foo@foo.com"
    },
    "license": {
      "name": "foo",
      "url": "https://foo.com"
    },
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://foo.com"
    }
  ],
  "paths": {
    "/search": {
      "get": {
        "summary": "foo",
        "externalDocs": {
          "description": "Search",
          "url": "https://foo.com/search.md"
        },
        "operationId": "search",
        "parameters": [
          {
            "name": "options",
            "in": "query",
            "description": "FOO",
            "schema": {
              "type": "string",
              "default": "FOO"
            }
          }
        ],
        "responses": {
          "default": {
            "description": "Response",
            "content": {
              "application/json;charset=UTF-8": {
                "schema": {
                 
                }
              }
            }
          },
          "503": {
            "description": "Request Rejected"
          },
          "504": {
            "description": "Backend Timeout "
          }
        }
      }
    }
  }
}
Generation Details

Open API generator spec:

{
  "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "5.1.1",
    "storageDir": "../../.openapi-generator/",
    "generators": {
      "foo": {
        "generatorName": "typescript-axios",
        "output": "#{cwd}/foo-api-client/",
        "glob": "./foo-api.json",
        "additionalProperties": {
          "withSeparateModelsAndApi": "true",
          "apiPackage": "api",
          "modelPackage": "model",
          "useSingleRequestParameter": true,
          "ensureUniqueParams": true
        }
      }
    }
  }
}
Steps to reproduce
  1. Save the spec to ./foo-api.json
  2. Run openapi-generator-cli generate
  3. Check the generated client, confirm that there's duplicate identifier options
Related issues/PRs
Suggest a fix

Rename the override parameter to something that's unlikely to be used as a query parameter like __AxiosHTTPOptionsOverride

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