Kiota.Autogen.Swagger
1.16.1
dotnet add package Kiota.Autogen.Swagger --version 1.16.1
NuGet\Install-Package Kiota.Autogen.Swagger -Version 1.16.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Kiota.Autogen.Swagger" Version="1.16.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Kiota.Autogen.Swagger --version 1.16.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Kiota.Autogen.Swagger, 1.16.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Kiota.Autogen.Swagger as a Cake Addin #addin nuget:?package=Kiota.Autogen.Swagger&version=1.16.1 // Install Kiota.Autogen.Swagger as a Cake Tool #tool nuget:?package=Kiota.Autogen.Swagger&version=1.16.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Kiota.Autogen.Swagger is a package for auto-generating API clients based on Swashbuckle.AspNetCore using Kiota
Basic Usage
- Add a
Class Library
project to the solution that contains WebApi project - Add WebApi project reference with
ExcludeAssets="All"
<ItemGroup>
<ProjectReference Include="..\ExampleService.Api\ExampleService.Api.csproj" ExcludeAssets="All" />
</ItemGroup>
- Install
Kiota.Autogen.Swagger
withPrivateAssets="All"
<ItemGroup>
<PackageReference Include="Kiota.Autogen.Swagger" Version="1.15.0" PrivateAssets="All" />
</ItemGroup>
- Install following
Kiota
packages
<ItemGroup>
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.9.10" />
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.9.10" />
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.9.10" />
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.9.10" />
<PackageReference Include="Microsoft.Kiota.Serialization.Multipart" Version="1.9.10" />
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.9.10" />
</ItemGroup>
- Create a
gensettings.json
file with the following structure
[
{
"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"
}
]
- Set up
Class library
project to build as a nuget package
<PropertyGroup>
... other properties
<IsPackable>true</IsPackable>
<PackageId>ExampleService.Client</PackageId>
</PropertyGroup>
- Pack
Class library
project - Enjoy using API client
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();
Advanced Usage
You can provide your own implementations of Microsoft.Kiota.Abstractions
from the Class library
project if you need
Usage:
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();
More Examples
See more examples here
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.16.1 | 118 | 7/23/2024 |
1.16.1-pre.2 | 59 | 7/23/2024 |