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

[Http][Kiota] Include Kiota API Client code generation as part of the Uno Kiota Extension #2644

Open
kazo0 opened this issue Dec 17, 2024 · 1 comment
Assignees
Labels
area/http kind/enhancement New feature or request.

Comments

@kazo0
Copy link
Contributor

kazo0 commented Dec 17, 2024

Along with work from #2510

Currently, the generation of the kiota classes based on the openapi json/yml spec needs to be done manually before building the project.

See: https://learn.microsoft.com/en-us/openapi/kiota/using#client-generation

We need to find a way to incorporate this into the build process when using the Kiota Uno Extension.

Proposed API

I am imagining something like an IHostBuilder extension method called .UseKiota("PATH_TO_API_SPEC.json") or perhaps on a per client basis like:

hostBuilder.UseHttp((context, services) => services
	.AddKiotaClient("PATH_TO_API_SPEC.json")
	.AddKiotaClient("PATH_TO_A_DIFFERENT_API_SPEC.yml")
);
@kazo0 kazo0 added kind/enhancement New feature or request. triage/untriaged Indicates an issue requires triaging or verification. area/http labels Dec 17, 2024
@kazo0 kazo0 removed the triage/untriaged Indicates an issue requires triaging or verification. label Dec 17, 2024
@dr1rrb
Copy link
Member

dr1rrb commented Jan 16, 2025

IMO We should distinguish 2 cases:

  1. The API is in the same solution of the client, i.e. "local"
  2. The API is a "external"

Local API

In that case the API is evolving with the client, and we will need to re-generate the DTO pretty frequently. In that case we could a similar approach as described here https://nikiforovall.github.io/dotnet/aspnetcore/2024/03/24/kiota-guide-deep-dive.html#generate-openapi-specification-automatically

Basically when we compile the server we request generate the spec json file and we use it right away to run kiota gen and generate the code to be used by the client (directly in client folder).

For this we need to update Uno's new solution wizard to include an option for the server to use kiota or not.

  • When not using kiota we should keep the current structure with a DTO project shared between the server and the client,
  • When using kiota we should remove that project and include all tasks to run generation as described above.

External API

The API will most likely not change very often and kiota generator will have to be run only once. While it would be nice, having a generator for that is probably overkill.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/http kind/enhancement New feature or request.
Projects
None yet
Development

No branches or pull requests

3 participants