Solve cross platform issue
fix issue - "Unhandled Exception: System.IO.FileNotFoundException" run on Macpull/2149/head
parent
401228c695
commit
21dacc2e8e
|
@ -227,7 +227,7 @@ Configure Swagger to use the generated XML file.
|
|||
> [!NOTE]
|
||||
> For Linux or non-Windows operating systems, file names and paths can be case sensitive. So `ToDoApi.XML` would be found on Windows but not CentOS for example.
|
||||
|
||||
[!code-csharp[Main](../tutorials/web-api-help-pages-using-swagger/sample/src/TodoApi/Startup.cs?name=snippet_Configure&highlight=29,32)]
|
||||
[!code-csharp[Main](../tutorials/web-api-help-pages-using-swagger/sample/src/TodoApi/Startup.cs?name=snippet_Configure&highlight=29,33)]
|
||||
|
||||
In the code above, ApplicationBasePath gets the base path of the app, which is needed to set the full path to the XML comments. `TodoApi.xml` only works for this example, the name of the generated XML comments file is based on the name of your application.
|
||||
|
||||
|
|
|
@ -45,7 +45,8 @@ namespace TodoApi
|
|||
var basePath = PlatformServices.Default.Application.ApplicationBasePath;
|
||||
|
||||
//Set the comments path for the swagger json and ui.
|
||||
options.IncludeXmlComments(basePath + "\\TodoApi.xml");
|
||||
var xmlPath = Path.Combine(basePath, "TodoApi.xml");
|
||||
options.IncludeXmlComments(xmlPath);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue