Typescript RequestBuilderNavigationMetadata name collision unhandled
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 3.8k
- Forks
- 333
- Avg merge
- 16h 29m
- Merged PRs (30d)
- 116
Description
### 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:
``` ts
import { type VehicleSpecificationsRequestBuilder as I6ebd2f6d4c8e512f73e9fc20673aeabb12454cf3128d799d7f72acd8d168492a, VehicleSpecificationsRequestBuilderNavigationMetadata } from './vehicleSpecifications/index.js';
// ...
export const VehicleSpecificationsRequestBuilderNavigationMetadata: Record, 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:
``` cmd
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
```
```
### Other information
_No response_
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 by reproducing the issue with the provided dotnet tool run kiota generate command against routes such as api/foo/foo/bar, then inspect the generated index.js for the repeated-segment import. Done means the child RequestBuilderNavigationMetadata is imported under an alias when needed and the generated TypeScript no longer self-references or fails to compile.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, typescript
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100