RESTly 0.9.0
See the version list below for details.
dotnet add package RESTly --version 0.9.0
NuGet\Install-Package RESTly -Version 0.9.0
<PackageReference Include="RESTly" Version="0.9.0" />
paket add RESTly --version 0.9.0
#r "nuget: RESTly, 0.9.0"
// Install RESTly as a Cake Addin #addin nuget:?package=RESTly&version=0.9.0 // Install RESTly as a Cake Tool #tool nuget:?package=RESTly&version=0.9.0
RESTly
A (experimental, WIP) C# source generator for generating REST clients out of OpenApi specifications. Currently, supports .NET 8 SDK. Generated code can target as low as netstandard2.0, but with additional polyfills needed.
Getting Started
- Add NuGet package
RESTly
to your project - Add a OpenApi specification as
AdditionalFiles
to your project - Add assembly attribute
RestlyClient
into your code with the name of the OpenApi specification file and the name of the api client to generate - The generated API client is located in the
Restly
namespace
Native AOT
This source generator generates AOT compatible code from version 0.7 onwards. For using AOT there is the need to add a client library project additionally to the application itself. In the application project the JSON serialization context for the generated API models must be defined. The split into projects is necessary as RESTly and JSON serialization context need source generators and those can not be chained.
Target older framework versions
Building RESTly client libraries makes a new .NET SDK version necessary. Target is to support at least the latest LTS version (but no guarantee).
With RESTly it is possible to build REST clients for older .NET versions
netstandard 2.0 and onwards compatible (, see https://learn.microsoft.com/en-us/dotnet/standard/net-standard).
When building for older .NET versions, additional dependencies might become necessary.
This can be seen in the ClientLibrary
example project.
File uploads
There is one possible issue with file upload.
When using minimal APIs with the .WithOpenApi()
extension method and
call parameters of type IFormFile
the generated schema contains no names
for the form field names. This makes the automated generation of client code hardly possible.
For using such endpoints the correct names must be given in the Name
field of the body parameter.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- Microsoft.CodeAnalysis.CSharp (>= 4.8.0)
- Microsoft.CodeAnalysis.CSharp.Workspaces (>= 4.8.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.