Swashbuckle.AspNetCore icon indicating copy to clipboard operation
Swashbuckle.AspNetCore copied to clipboard

Allow the usage of custom http verbs like "QUERY"

Open dotlogix opened this issue 2 years ago • 7 comments

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 avatar Jan 29 '23 02:01 dotlogix

@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.

captainsafia avatar Mar 29 '23 21:03 captainsafia

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!

jlchavez avatar Jun 17 '23 15:06 jlchavez

#2740 will at least stop the exception (or make it more understandable).

martincostello avatar Apr 14 '24 10:04 martincostello

Having looked into #2740, I now see we can't directly support this without Microsoft.OpenApi.Models.OperationType being extended.

martincostello avatar Apr 14 '24 12:04 martincostello

@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.

captainsafia avatar Apr 15 '24 19:04 captainsafia

Any update on this?

cts-tradeit avatar May 24 '24 13:05 cts-tradeit

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.

martincostello avatar May 24 '24 14:05 martincostello

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.

github-actions[bot] avatar Jul 25 '24 01:07 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Aug 08 '24 01:08 github-actions[bot]