question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AspNetCoreToSwagger : Wrong output path when setting the "configuration" parameter

See original GitHub issue

Hi,

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:closed
  • Created 5 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
srollinetcommented, Jul 31, 2018

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

0reactions
RicoSutercommented, Aug 3, 2018

v11.18.1

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found