AspNetCoreToSwagger : Wrong output path when setting the "configuration" parameter
See original GitHub issueHi,
When I try to change the configuration parameter of the AspNetCoreToSwagger generator, NSwag searches the output in the wrong directory
I use NSwag.MSBuild 11.17.21
This is my original config and it works fine:
csproj
<Target Name="NSwag" AfterTargets="Build">
<Exec Command="$(NSwagExe_Core21) run nswag.json" />
</Target>
nswag.json
//
{
"runtime": "NetCore21",
"swaggerGenerator": {
"aspNetCoreToSwagger": {
"project": "MyProj.csproj",
"output": "wwwroot/dev/swagger/v1/swagger.json",
"noBuild": true,
"defaultEnumHandling": "String",
"defaultPropertyNameHandling": "CamelCase",
"defaultReferenceTypeNullHandling" : "NotNull"
}
}
}
As soon as I try to change the configuration, NSwag introduces the absolute path to Debug folder again.
System.InvalidOperationException: Project outputs could not be located in ‘/home/sro/projects/xxx/src/MyProj/bin/home/sro/projects/xxx/src/MyProj/Debug/netcoreapp2.1/’. Ensure that the project has been built.
this is the modified config:
csproj
<Target Name="NSwag" AfterTargets="Build">
<Exec Command="$(NSwagExe_Core21) run nswag.json /variables:Configuration=$(Configuration)" />
</Target>
nswag.json
//
{
"runtime": "NetCore21",
"defaultVariables": "Configuration=Debug",
"swaggerGenerator": {
"aspNetCoreToSwagger": {
"project": "MyProj.csproj",
"configuration": "$(Configuration)",
"output": "wwwroot/dev/swagger/v1/swagger.json",
"noBuild": true,
"defaultEnumHandling": "String",
"defaultPropertyNameHandling": "CamelCase",
"defaultReferenceTypeNullHandling" : "NotNull"
}
}
}
I tried both on Linux and Windows, same problem
Thanks for your help!
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Trouble with Swagger' correct configuration in .Net Core ...
ensure that your DocInclusionPrediate lambda is setup like this: setup.DocInclusionPredicate((version, desc) => { if (!desc.TryGetMethodInfo(out ...
Read more >Configuring and Using Swagger UI in ASP.NET Core Web ...
We are going to learn how to integrate the Swagger UI/OpenAPI in an ASP.NET Core Web API, extend the documentation, and customize UI....
Read more >Optional Route Parameters with Swagger and ASP.NET Core
Swagger UI is great for documenting your APIs. OpenAPI doesn't allow optional route parameters. I'll show you how you can bypass that and ......
Read more >Get started with Swashbuckle and ASP.NET Core
Learn how to add Swashbuckle to your ASP.NET Core web API project to integrate the Swagger UI.
Read more >Swashbuckle.AspNetCore
Take note of the first argument to SwaggerDoc. It MUST be a URI-friendly name that uniquely identifies the document. It's subsequently used to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry for the delay, I haven’t seen the notifications 😦
Here is a sample project based on the “dotnet new webapi” template I tried with the sdk 2.1.302
If you remove the “configuration” property from nswag.json, it works as expected
nswag_issue.zip
v11.18.1