Hi,
first off, great template! absolutely love it.
Im having issues with swagger and WebEssentials.AspNetCore.ServiceWorker.
cant get swagger to work after you latest commit.
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.NotSupportedException: Ambiguous HTTP method for action - WebEssentials.AspNetCore.Pwa.PwaController.ServiceWorkerAsync (WebEssentials.AspNetCore.Pwa). Actions
require an explicit HttpMethod binding for Swagger 2.0
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreatePathItem(IEnumerable1 apiDescriptions, ISchemaRegistry schemaRegistry)
at System.Linq.Enumerable.ToDictionaryTSource,TKey,TElement
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath, String[] schemes)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.SpaServices.Webpack.ConditionalProxyMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.SpaServices.Webpack.ConditionalProxyMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.NotSupportedException: Ambiguous HTTP method for action - WebEssentials.AspNetCore.Pwa.PwaController.ServiceWorkerAsync (WebEssentials.AspNetCore.Pwa). Actions
require an explicit HttpMethod binding for Swagger 2.0
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.CreatePathItem(IEnumerable1 apiDescriptions, ISchemaRegistry schemaRegistry)
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwagger(String documentName, String host, String basePath, String[] schemes)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.SpaServices.Webpack.ConditionalProxyMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.SpaServices.Webpack.ConditionalProxyMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
It seems they do not play nice together. Sadly swagger only supports ignoring controllers through attributes as far as i can tell. Anyone found a way around this?
arguably this is a bug in WebEssentials.AspNetCore.ServiceWorker to add the Method binding?
Quick fix on this if anyone runs into it, implement a custom IActionModelConvention and make sure the Pwa Controller is hidden.
add to mvc.
services.AddMvc(c =>
c.Conventions.Add(new ApiExplorerIgnores())
)
and create the IActionModelConvention somewhere
public class ApiExplorerIgnores : IActionModelConvention
{
public void Apply(ActionModel action)
{
if (action.Controller.ControllerName.Equals("Pwa"))
action.ApiExplorer.IsVisible = false;
}
}
Thanks! Did work for me.
Thanks ! Finally it work .
Most helpful comment
Quick fix on this if anyone runs into it, implement a custom IActionModelConvention and make sure the Pwa Controller is hidden.
add to mvc.
services.AddMvc(c => c.Conventions.Add(new ApiExplorerIgnores()) )and create the IActionModelConvention somewhere
public class ApiExplorerIgnores : IActionModelConvention
{
public void Apply(ActionModel action)
{
if (action.Controller.ControllerName.Equals("Pwa"))
action.ApiExplorer.IsVisible = false;
}
}