-
Notifications
You must be signed in to change notification settings - Fork 266
Feature/swagger #218
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
Feature/swagger #218
Conversation
@rflechner "I just pushed fixes." - merged your changes to the temporal https://github.com/cotyar/Giraffe/tree/SwaggerAndWebsockets |
…o fix/swagger_discovery_bugs1
Would this support TokenRouter? |
I don't think but I could try to implement this in a next PR or commit. |
So, I just tried to get this up and running on my machine (Ubuntu 18.04) and it seemed to work. A few things though:
Hope this helps. Super excited to see this feature get in!! |
And of course, please let me know if there's anything I can do to help it along @dustinmoris @rflechner |
<ItemGroup> | ||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.*" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is why the tests are failing.
@rflechner Could you give me access to this branch so I could fix it? |
@rflechner Thank you! |
@ElijahReva @NatElkins, is it right for you now ? |
@rflechner Not able to check at the moment. But while I've got you here, can I suggest making this feature an entirely separate repo/Nuget package? That would allow it to have a separate release cadence from Giraffe and be more flexible about making updates to it. When I last tested this feature with my project, an exception was thrown at startup (didn't have a chance to look too deeply into it). I'll try to take another look and see what went wrong. |
Also then @dustinmoris won't have to worry about it affecting the larger Giraffe code base. |
This PR is a technical proposition. |
Guys, @dustinmoris hasn't updated Giraffe since Feb. |
@cotyar The develop branch was updated in May. |
What's the best way to try this out while this PR is pending? |
I am closing this PR. |
Hello,
In this PR I propose a solution to generate a swagger for Giraffe.
Issue #79 has label
help wanted
😃 .My solution for Suave was effectively not really easy to use.
Documentation and service implementation were too strongly coupled and the DSL was really verbose.
The good news is that we still have to declare our API routes the same way as before but to enable the route analysis we have to surround the app declaration with quotation marks.
With that in place we can decouple the app declaration from the analysis required to generate the swagger documentation. In other words this solution has the avantage to avoid corrupting your service implementation.
How does it work ?
I introduced the
documents
function that takes two arguments:DocumentationConfig
argument.This function does the analysis of your quotation to generate Swagger documentation.
DocumentationConfig
contains the following properties:MethodCallRules
: allow you to provide custom functions to enrich DSL and / or quotation analysis.DocumentationAddendums
: allow you to add more informations to the documentation without introducing service implementation modification.I introduced
==>
operator that gives the possibility to adddecorations
in routes implementations.Examples
There are 2 solutions to add documentation for a route.
See example
using
DocumentationAddendums
PS: I added a SLN file to improve experience with Jetbrains Rider IDE.
I propose to create a separated NuGet for
Giraffe.Swagger
.In futur, SwaggerUi could be a submodule of the repository (if you like and accept this PR 😄 ).
Some features could be missing and some quotations could be difficult to parse.
For the moment, analyzer works with most basics default httphandlers.
I only implemented:
You can build and run SwaggerSample/Program.fs and
go to http://localhost:5000/swaggerui/
Regards.
@rflechner