OpenAPITools / OpenAPITools/openapi-generator
[BUG] [typescript-axios] Duplicate identifier 'options' when URL parameter 'options' exists
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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:
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
- Save the spec to
./foo-api.json - Run
openapi-generator-cli generate - 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache at the hardcoded override parameter referenced in the issue, then reproduce generation with the supplied OpenAPI specification and typescript-axios settings. Done means the generated client no longer declares duplicate options parameters while retaining the HTTP options override behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100