Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] typescript-axios generation produces duplicate identifiers when a path parameter called "index" is used #17068

Closed
4 of 6 tasks
rmisiakexscientia opened this issue Nov 14, 2023 · 1 comment · Fixed by #17550

Comments

@rmisiakexscientia
Copy link

rmisiakexscientia commented Nov 14, 2023

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • 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 7.1.0 when a request uses a path parameter called index the typescript generated with the typescript-axios generator does not compile because it contains duplicate identifiers.

7.0.0 works correctly.

openapi-generator version
"@openapitools/openapi-generator-cli": "^2.7.0",
{
  "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "7.1.0"
  }
}
OpenAPI declaration file content or url

https://gist.github.com/rmisiakexscientia/074283d6ef3e975dbd6250ef550b64c7

Generation Details
Steps to reproduce
npx openapi-generator-cli generate -g typescript-axios -i "./src/openapi.json" -o "./src/client" --additional-properties="apiPackage=clients,modelPackage=models,withoutPrefixEnums=false,withSeparateModelsAndApi=true"

Then in count-api.ts you get this

/**
 * CountApi - functional programming interface
 * @export
 */
export const CountApiFp = function(configuration?: Configuration) {
    const localVarAxiosParamCreator = CountApiAxiosParamCreator(configuration)
    return {
        /**
         * 
         * @param {CountControllerTotalIndexEnum} index 
         * @param {*} [options] Override http request option.
         * @throws {RequiredError}
         */
        async countControllerTotal(index: CountControllerTotalIndexEnum, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
            const localVarAxiosArgs = await localVarAxiosParamCreator.countControllerTotal(index, options);
            const index = configuration?.serverIndex ?? 0;
            const operationBasePath = operationServerMap['CountApi.countControllerTotal']?.[index]?.url;
            return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, operationBasePath || basePath);
        },
    }
};

which is invalid because index is both a parameter and declared inside the body

Related issues/PRs
Suggest a fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant