Swashbuckle.AspNetCore
Swashbuckle.AspNetCore copied to clipboard
Allow the usage of custom http verbs like "QUERY"
Hey there I know it might be an edge case but the HTTP protocol allows to use custom verbs, unfortunately this is currently not supported. I would like to expand on the verbs for my service but still use this awesome library.
It would be nice if it would be possible to expand the OperationTypes to additional verbs. atm I get a dictionary key not found exception because it can not map "QUERY" to an operation type:
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)
Since it is easily possible in ASP to customize the HTTP method used by an endpoint, please consider either ignoring these methods or add support for custom verbs.
Thanks in advance <3
@dotlogix You might have some luck opening this feature for discussion in the repo for the OpenAPI specification. Swashbuckle/ASP.NET don't control what is feasible to write into the OpenAPI document and a change like this would need to be made at the specification level.
I just want to let you know that it has been approved this week and that changes are coming to the spec about this:
https://github.com/OAI/OpenAPI-Specification/issues/1747#issuecomment-1593407689
Finally, I've been waiting for this!
#2740 will at least stop the exception (or make it more understandable).
Having looked into #2740, I now see we can't directly support this without Microsoft.OpenApi.Models.OperationType
being extended.
@martincostello Yes, AFAIK, the spec comment referenced in https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/2600#issuecomment-1595793690 outlines the intent to support this in OpenAPI v4. Versions v3 and v2 still only support the finite set denoted in OperationType
above. Until v4 of the spec is adopted, I think throwing an exception is sensible in this case.
Any update on this?
Nope - when there's a version of Microsoft.OpenAPI available that supports it, then we can update and then it'll work. Until then there will be no updates.
This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made.
This issue was closed because it has been inactive for 14 days since being marked as stale.