https://github.com/ellizio/kiota.autogen
A set of libraries for auto-generating API clients using Kiota
https://github.com/ellizio/kiota.autogen
kiota openapi-client openapi-codegen openapi3 swagger
Last synced: 5 months ago
JSON representation
A set of libraries for auto-generating API clients using Kiota
- Host: GitHub
- URL: https://github.com/ellizio/kiota.autogen
- Owner: ellizio
- License: mit
- Created: 2024-06-13T18:06:04.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2025-06-24T15:32:09.000Z (12 months ago)
- Last Synced: 2025-11-15T05:26:36.164Z (7 months ago)
- Topics: kiota, openapi-client, openapi-codegen, openapi3, swagger
- Language: C#
- Homepage:
- Size: 57.6 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
#
Kiota.Autogen
A set of libraries for auto-generating API clients using Kiota
---
## Libraries list
- [](https://www.nuget.org/packages/Kiota.Autogen.Swagger/) [Kiota.Autogen.Swagger](src/Kiota.Autogen.Swagger) for generating API client based on [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore)
## Basic Usage
1. Add a `Class Library` project to the solution that contains WebApi project
2. Add WebApi project reference with `ExcludeAssets="All"`
```xml
```
3. Install `Kiota.Autogen.Swagger` with `PrivateAssets="All"`
```xml
```
4. Install following `Kiota` packages
```xml
```
5. Create a `gensettings.json` file with the following structure
```jsonc
[
{
"name": "WeatherClient", // API client name to be generated
"namespace": "Weather.Client", // API client namespace
"version": "v1" // WebApi Swagger document version
},
{
"name": "WeatherClientNew",
"namespace": "Weather.Client.New",
"version": "v2"
}
]
```
6. Set up `Class library` project to build as a nuget package
```xml
... other properties
true
ExampleService.Client
```
7. Pack `Class library` project
8. Enjoy using API client
```csharp
using Microsoft.Kiota.Abstractions.Authentication;
using Microsoft.Kiota.Http.HttpClientLibrary;
using Weather.Client;
using var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("http://your_service_url");
var provider = new AnonymousAuthenticationProvider();
using var adapter = new HttpClientRequestAdapter(provider, httpClient: httpClient);
var client = new WeatherClient(adapter);
var forecasts = await client.Weatherforecast.GetAsync();
```
See [full example](https://github.com/ellizio/Kiota.Autogen-Examples/tree/master/1.%20Swagger)
## Advanced Usage
You can provide your own implementations of `Microsoft.Kiota.Abstractions` from the `Class library` project if you need\
Usage:
```csharp
using Microsoft.Kiota.Abstractions.Authentication;
using Microsoft.Kiota.Http.HttpClientLibrary;
using Weather.Client;
using var httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("http://your_service_url");
var provider = new AnonymousAuthenticationProvider();
using var adapter = new HttpClientRequestAdapter(provider, new WeatherParseNodeFactory(), new WeatherSerializationWriterFactory(), httpClient: httpClient);
var client = new WeatherClient(adapter);
var forecasts = await client.Weatherforecast.GetAsync();
```
See [full example](https://github.com/ellizio/Kiota.Autogen-Examples/tree/master/2.%20Advanced)
## More Examples
See more examples [here](https://github.com/ellizio/Kiota.Autogen-Examples)
## Additional References
- [Changelog](CHANGELOG.md)
- [Kiota](https://github.com/microsoft/kiota)
- [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore)