-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Swagger supports normal minimal asp.net core apis but not work for Giraffe endpoints #488
Comments
This root reason should be similar with falco: |
This was mentioned in the talk at https://www.twitch.tv/videos/1092464368 yesterday (right at the end, and in relation to https://github.com/baronfel/Giraffe.EndpointRouting.OpenAPI I think). |
Yep I brought it up on purpose because I'd seen this discussion pop up again (and also I'm the Falco repo). The relevant code in aspnetcore is here, the gist of which is to translate specifically minimal endpoints that are described by lambdas (or method groups) by their endpoint Metadata (which includes the reflection Method info) into ApiDescriptors. This doesn't work for giraffe at all because composed endpoints don't match this pattern, so if we want to interop at the level that Swashbuckle does, we'd need to implement our own Apidescriptor provider that could create these same structures from giraffe apis. Swashbuckle would then be able to take our ApiDescription and generate the swagger doc from that. That's where the fiddly work comes in, as far as I can see it. Link to the brief video clip where I go over this is here |
this project was archived but could be helpful, at least for the openapi CE writer part? |
maybe something new can be tried with these updates on openapi and metadata? https://devblogs.microsoft.com/dotnet/asp-net-core-updates-in-dotnet-7-preview-4/ |
This would be really helpful for companies that are reliant on openapi and swagger. @baronfel thanks for the work to describe this. |
Coming across this issue from domaindrivendev/Swashbuckle.AspNetCore#2300.
@baronfel's recommendation here is exactly right. Providing a custom The link above points to minimal API's implementation (see here). There's also implementations for MVC (see here) and gRPC (see here) that can be used as examples. |
@captainsafia thank you so much for helping provide tangible examples. maybe one day if I can find the time I'll try and mess around with an implementation attempt. Having swagger for Giraffe would really help unify our C# and F# api descriptions. |
Apparently it was fixed by PR #599. What you think? |
One thing about this approach I spotted is that it makes use of the One thing I'm observing about your implementation though: do the endpoints generated by Giraffe eventually get populated into the |
It's likely that they're added as RequestDelegates instead of taking the Delegate overload. Only the latter will populate the MethodInfo required to make them flow through automatically through the built-in |
I've a working sample app here. It uses the |
Does anything need to get merged or is this currently working? |
I think this currently works with the caveat that it uses the soon-to-be-deprecated-ish |
I am playing around with asp.net core 6.0.100-preview.6.21355.2
I found the swagger works for default endpoint routes like in below code the /hello2 will be picked by swagger, but not work with giraffe endpoints.
The text was updated successfully, but these errors were encountered: