-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Can I use NSwag.ApiDescription.Client? #2251
Comments
/cc @dougbu |
The latest NSwag.ApiDescription.Client includes a reference to the latest Microsoft.ApiDescription.Client package but, because #2226 is not merged, doesn't support project references. Either
|
Thank you for your quick reply. We have decided to go back to using the .Design version while waiting for a “preview” version :). Do you know if the ApiDescription.Client will be .net Core 3.0 only or will it work for 2.2 as well? |
If you mean the Microsoft.Extensions.ApiDescription.Client package, it should work for most target frameworks because it contains only MSBuild files. For future reference, the Microsoft.Extensions.ApiDescription.Server package for document generation in web projects supports .NET Framework 4.6.1 and .NET Core 2.1 or later. The NSwag.ApiDescription.Client package supports .NET Framework 4.6.1 and .NET Core 1.0 or later. |
I re-tested this locally and found there's a bug in the NSwag.ApiDescription.Client -- it references an older version of NSwag.MSBuild but uses the latest NSwag CLI commands. You could resolve this by directly referencing the same version of NSwag.MSBuild from your project. But, you might want to wait for a release containing the #2226 updates. (I fixed the dependency from NSWag.ApiDescription.Client.nuspec in that PR because it was inconsistent, not realizing the change addressed a real bug.) |
@RicoSuter Do you know if #2226 was included in the latest 13.0.4 release? We are using the old preview functionality in 12.x atm but we can switch once this works to try it out and give feedback if you want :) |
I'm trying to get the Client generation going with the new .Net Core 3.0 bits but I just can't seem to figure it out. Should I be using NSwag.ApiDescription.Client or the Microsoft.Extensions.ApiDescription.Server package to generate a C# client at build? Using "Microsoft.Extensions.ApiDescription.Server" gives me an error telling me if cannot find the start point. |
NSwag.ApiDescription.Client is the correct package to reference. But, it currently brings in an old version of the Microsoft.Extensions.ApiDescription.Client package. To update it, also add a reference to the 3.0.0 version of Microsoft.Extensions.ApiDescription.Client however you prefer to update package references. The end result should be something like <PackageReference Include="Microsoft.Extensions.ApiDescription.Client" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference> The items you want to include in your project for code generation are now named |
Thanks for the info! I can see that the OpenApiReference now wants me to reference a .json file directly and not a .csproj file as the old one did. I can create a .json file from my Micro Service project using the msbuild task, but I dont want to pay the compilation time cost every time I rebuild that project. Are there another way to create the .json file only when I rebuild my "Client" project? |
Set |
I dont mind rough edges :)
Everything is almost as I want it except three issues:
Both the obj and the root path has the same security settings.
What I realy would want is to:
Adding both theese files to source control makes it easy to check whenever a update to NSwag or other package, changes the behavior of the client. Is this solution possible with todays version of OpenApiProjectReference? |
BTW I tend to use "API project" when referring to an ASP.NET Core MVC project exposing a Web API and "client project" when referring to the project containing (generated) code to use that API. What do you mean by "API project" and "service project"? |
<PropertyGroup>
<OpenApiCodeDirectory>$(ProjectDir)</OpenApiCodeDirectory>
</PropertyGroup>
<ItemGroup>
<OpenApiProjectReference Include="..\WebApi\WebApi.csproj">
<CodeGenerator>NSwagCSharp</CodeGenerator>
<Options>/GenerateClientInterfaces:true /UseBaseUrl:false</Options>
</OpenApiProjectReference>
</ItemGroup> It maybe helpful. |
Hi!
I'm trying to use the
NSwag.ApiDescription.Client
to generate a C# client using "ServiceProjectReference" (as described here https://github.com/RicoSuter/NSwag/wiki/ServiceProjectReference) but I'm getting aMicrosoft.Extensions.ApiDescription.Client.targets(141,5): error : ServiceProjectReference items are no longer supported.
exception :(
I know this is still under development but I would like to beta test it :)
Is it posible to use this with .Net Core 2.2 atm or is it outdated?
The text was updated successfully, but these errors were encountered: