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

Add support for alternate keys in code indexers #4241

Open
baywet opened this issue Feb 26, 2024 · 2 comments
Open

Add support for alternate keys in code indexers #4241

baywet opened this issue Feb 26, 2024 · 2 comments
Labels
enhancement New feature or request generator Issues or improvements relater to generation capabilities. help wanted Issue caused by core project dependency modules or library
Milestone

Comments

@baywet
Copy link
Member

baywet commented Feb 26, 2024

Notes from a conversation between myself and @baywet

The current OpenAPI specification says that the following is invalid

  /pets/{petId}/fur
  /pets/{name}/hair

However, I expect future iterations of the specification will relax this constraint and we know that these already exist in the wild. The notion of a collection of things having multiple candidate keys is a common concept and we should be able to model this.

We currently model these parameter segments as a CodeIndexer DOM model. Currently the CodeIndexer doesn't support the notion of alternate keys. We think it is worth exploring adding support for alternate keys to the CodeIndexer. We can continue to use the first parameter alphabetically as the default primary key, and all other parameters as alternate keys. This allows us to introduce support for a x-primary-key hint in the OpenAPI description that enables a particular path to be stable in its use of syntax like the C# indexer.

It may be possible that different candidate keys return different types. From a logical perspective the different types should be closely related, but from code perspective the types could be different. This does warp the concept of CodeIndexer slightly, but may be tolerable.

Adding this notion of candidate/alternate keys to the code indexer would remove the need for merging of nodes and the language refiners can emit specific named indexer methods for alternate keys and some default indexer method for the primary key, or they can emit specific named indexer methods for all the candidate keys.

Originally posted by @darrelmiller in #4174 (comment)

@github-project-automation github-project-automation bot moved this to Todo in Kiota Feb 26, 2024
@baywet baywet added enhancement New feature or request generator Issues or improvements relater to generation capabilities. help wanted Issue caused by core project dependency modules or library labels Feb 26, 2024
@baywet baywet added this to the Backlog milestone Feb 26, 2024
@baywet
Copy link
Member Author

baywet commented Feb 26, 2024

Cleanup instructions;

@andrueastman
Copy link
Member

Cleanup instructions;

To add we should also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request generator Issues or improvements relater to generation capabilities. help wanted Issue caused by core project dependency modules or library
Projects
Status: New📃
Development

No branches or pull requests

2 participants