kiota icon indicating copy to clipboard operation
kiota copied to clipboard

Typescript RequestBuilderNavigationMetadata name collision unhandled

Open npbenjohnson opened this issue 9 months ago • 0 comments

What are you generating using Kiota, clients or plugins?

API Client/SDK

In what context or format are you using Kiota?

Nuget tool

Client library/SDK language

TypeScript

Describe the bug

When a route has a repeated segment, there is a name conflict which breaks the generated RequestBuilderNavigationMetadata.

It looks like the generator uses an alias via "as" for the RequestBuilder type import to prevent name collisions, but doesn't do the same with RequestBuilderNavigationMetadata.

ex:

import { type VehicleSpecificationsRequestBuilder as I6ebd2f6d4c8e512f73e9fc20673aeabb12454cf3128d799d7f72acd8d168492a, VehicleSpecificationsRequestBuilderNavigationMetadata } from './vehicleSpecifications/index.js';

// ...

export const VehicleSpecificationsRequestBuilderNavigationMetadata: Record<Exclude<keyof VehicleSpecificationsRequestBuilder, KeysToExcludeForNavigationMetadata>, NavigationMetadata> = {
    vehicleSpecifications: {
// TS error here because VehicleSpecificationsRequestBuilderNavigationMetadata is self-referencing
        navigationMetadata: VehicleSpecificationsRequestBuilderNavigationMetadata,
    }
};

Expected behavior

Generated index.js for a url segment should import the child RequestBuilderNavigationMetadata's under an alias when necessary to avoid breaking due to a self-reference.

How to reproduce

Generate clients against an api that has routes like "api/foo/foo/bar". Example command which has the issue:

dotnet tool run kiota generate -l typescript -d https://localhost:44345/swagger.json -c VehicleSpecificationsClient -o ./vehicle-specifications --exclude-backward-compatible --clean-output

Open API description file

No response

Kiota Version

microsoft.openapi.kiota 1.28.0 (dotnet tool)

Latest Kiota version known to work for scenario above?(Not required)

No response

Known Workarounds

No response

Configuration

No response

Debug output

Click to expand log ```
</details>


### Other information

_No response_

npbenjohnson avatar Jul 15 '25 20:07 npbenjohnson