RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.67k stars 1.23k forks source link

Version 14.0.1.0 - aspnetcore2openapi generate code where NSwagStudio will #4730

Closed haverjes closed 7 months ago

haverjes commented 7 months ago

I have a minimal api .net8 app and I need an automated way to generate an OpenApi file at build time (one without the Servers property). I thought aspnetcore2openapi would be the ideal tool because Studio generates it from the project with no problem. But when I run the console command I get the following error:

Done executing command. Exit Code: 0. Done executing command Output: AssemblyName: Miniter.Services.ImagingApi OutputPath: bin\Debug\net8.0\ PlatformTarget: Platform: AnyCPU ProjectDepsFilePath: C:\Projects\Miniter\Miniter.Webs\Imaging\Miniter.Services.ImagingApi\bin\Debug\net8.0\Miniter.Services.ImagingApi.deps.json ProjectDir: C:\Projects\Miniter\Miniter.Webs\Imaging\Miniter.Services.ImagingApi\ ProjectRuntimeConfigFilePath: C:\Projects\Miniter\Miniter.Webs\Imaging\Miniter.Services.ImagingApi\bin\Debug\net8.0\Miniter.Services.ImagingApi.runtimeconfig.json TargetFileName: Miniter.Services.ImagingApi.dll TargetFrameworkIdentifier: .NETCoreApp System.InvalidOperationException: Unsupported target framework '.NETCoreApp'. at NSwag.Commands.Generation.AspNetCore.AspNetCoreToOpenApiCommand.d45.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NConsole.CommandLineProcessor.d12.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at NConsole.CommandLineProcessor.d11.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.Commands.NSwagCommandProcessor.d3.MoveNext()

Bonuspunkt commented 7 months ago

ran into the same issue, using the correct executable

<Exec ... Command="$(NSwagExe_Net80) ..."/>

fixed it

haverjes commented 7 months ago

Thank you. I could have sworn I tried that and got a different error. But doing it this morning worked like a charm.