-
Notifications
You must be signed in to change notification settings - Fork 221
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
Kiota.Config for managing multiple API dependencies in a project. #3356
Comments
Thanks for starting to write this down. |
@andreaTP that's the last thing we were referring to in the call earlier |
@baywet I will try and take another swing at proposing commands that don't require two commands to add an API. |
I have skimmed through this proposal and I like it very much! A few quick notes:
|
Not wild about The "thing" I'm adding to the config is...:
I do like the idea of separate configuration/lock files. |
I think |
Really exciting feature, was about to propose something similar! I notice this issue has been marked as closed and it's in the 1.12 release notes, however, there doesn't appear to be any documentation on it and it looks like it's behind a feature flag. Is this feature ready or is there more work to be done? I'm happy to help volunteer my time, for example, by having a go at adding the docs (once I have a quick play with it) and I assume I just add them over here? |
Hey @samcragg
If you want to help on the docs, you can get started by submitting a PR to document the new commands and clean up the old ones. It'd be much appreciated! |
Context
Kiota generates client code for an API and stores parameters in a kiota.lock file. A project can contain multiple API clients, but they are independently managed. Kiota has no awareness that an app has a dependency on multiple APIs, even though that is a core use case.
Current Challenges
We have previously described Kiota's approach to managing API dependencies as consistent with the way people manage packages in a project. However, currently our tooling doesn't behave that way. We treat each dependency independently.
Proposal
We should introduce a new Kiota.config file that holds the input parameters required to generate the API Client code. Currently kiota.lock is used to capture what the parameters were at the time of generation and can be used to regenerate based on the parameters in the file. This creates a mixture of purposes for the file.
We did consider creating one kiota.config file as as a peer of the language project file, however, For someone who wants to generate multiple clients for an API in different languages, this would be a bit annoying. An alternative would be to allow the kiota.config file to move further up the folder structure and support generation in multiple languages from a single file. This is more consistent with what TypeSpec are doing and would be helpful for generating CLI and docs as well as a library.
Here is an example of what the kiota.config file could look like.
Note that in this example we added suggestions for new parameters related to authentication. If we are to improve the generation experience so that we read the security schemes information from the OpenAPI, then we will need to have some place to configure what providers we will use for those schemes.
The API Manifest file can be used as a replacement for the kiota.lock file as a place to capture a snapshot of what information was used to perform code generation and what APIs that gives the application access to.
Principles
Tooling commands to manage Kiota.config
In the past we have had both a
generate
and anupdate
comment. This is because if it was the first time running, generate would set defaults for all the properties that were not set on the command line. However, now that we haveadd output
, it can be used to set the defaults andgenerate
can just read from thekiota.config
file. Question 1: Do we keep the parameters in generate to allow you to update kiota.config and maintain some backward compat with previous commands?Scenarios using the command line tool
Get started to generate an API
kiota init --name Myapp kiota add api --name MyApi --openapi https://example.org/api/openapi.json // Can we add using -k ? kiota add output --name MyApi --lang csharp --outputPath ./csharpClient kiota generate
Add a second language to generate an API
kiota add output --name MyApi --lang python --outputPath ./pythonClient kiota generate --name MyApi --lang python // Generate just the Python client for MyApi
Remove a language
Question 2: Does removing the output remove the generated code? The entire folder?
Question 3: How do we uniquely identify an Output? Should we be able to generate two Python clients for MyApi?
Remove an API
Question 5: Does removing the output remove the generated code? The entire folder?
JSON Schema for Kiota.Config
The text was updated successfully, but these errors were encountered: