'Launching Swagger automatically when running .NET Core web API in VSCode (macOS)

I'm running VSCode on macOS and when running a .NET Core web API solution, the solution opens in a browser on https://localhost:7188/. Is there anyway to automatically open it on https://localhost:7188/swagger/index.html?

I've tried to modify the launchSettings.json from the line below:

  "applicationUrl": "https://localhost:7188;http://localhost:5161",

to

  "applicationUrl": "https://localhost:7188/swagger;http://localhost:5161/swagger",

However, that causes a build error:

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Private.CoreLib.dll: 'A path base can only be configured using IApplicationBuilder.UsePathBase().'
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.ParseAddress(String address, Boolean& https)
   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.AddressesStrategy.<BindAsync>d__2.MoveNext()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source