-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Labels
Description
I want to create a WebSocket endpoint.
If I use just [Route]
attribute, Swagger throws an error.
Currently ASP.NET does not provide [HttpConnect]
attribute., so I had to declare it myself:
public sealed class HttpConnectAttribute : HttpMethodAttribute
{
private static readonly string[] _httpMethods = ["CONNECT"];
public HttpConnectAttribute() : base(_httpMethods)
{
}
public HttpConnectAttribute(string template) : base(_httpMethods, template)
{
}
}
And after I applied it to the method, swagger throws:
System.Collections.Generic.KeyNotFoundException: The given key 'CONNECT' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GenerateOperations(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GeneratePaths(IEnumerable`1 apiDescriptions, SchemaRepository schemaRepository)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwaggerDocumentWithoutFilters(String documentName, String host, String basePath)
at Swashbuckle.AspNetCore.SwaggerGen.SwaggerGenerator.GetSwaggerAsync(String documentName, String host, String basePath)
at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
I had to exclude that endpoint from the docs: [ApiExplorerSettings(IgnoreApi = true)]
- How do I add support for 'CONNECT' to Swagger docs?
- Is there any WebSocket support at all?
Angelinsky7 and HongSic