-
Notifications
You must be signed in to change notification settings - Fork 412
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
Middleware for adding swagger ui endpoint (#2494) #2556
Conversation
a12d489
to
03d7325
Compare
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #2556 +/- ##
==========================================
+ Coverage 64.59% 64.84% +0.25%
==========================================
Files 138 139 +1
Lines 8086 8118 +32
Branches 1459 1482 +23
==========================================
+ Hits 5223 5264 +41
+ Misses 2863 2854 -9 ☔ View full report in Codecov by Sentry. |
* of the OpenAPI specification and is url encoded. | ||
*/ | ||
def swaggerUI(path: PathCodec[Unit], api: OpenAPI, apis: OpenAPI*): Middleware[Any] = | ||
swaggerUI(path, "5.10.3", api, apis: _*) |
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.
What is this hard-coded version here?
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.
It is just a default version, that is the latest for now. I thought it might be nice to not have to look up a swagger ui version for a simple use case.
val routes = Routes(getUserRoute, getUserPostsRoute) | ||
val openAPI = OpenAPIGen.fromEndpoints(title = "Endpoint Example", version = "1.0", getUser, getUserPosts) | ||
|
||
val routes = Routes(getUserRoute, getUserPostsRoute) @@ Middleware.swaggerUI("docs" / "openapi", openAPI) |
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 would like to ask the question why is this functionality a middleware? It is not modifying the behavior of existing routes just generates one or more new ones. Would not it be more logical if it is just a function returning Routes
which can be appended to an existing Routes
?
03d7325
to
8155395
Compare
Html template script rendering fix (#2521)
I also removed
Since it lead to code like
Middleware.swaggerUI("docs" / "openapi", openAPI)
being invalid.Here
"docs" / "openapi"
was ambiguous, since there is a implicit conversion from string toPathCodec
and toSegmentCodec
and a/
method for each of them. I saw that theSegmentCodec
method was internally used only in one place. And I don't think that ppl will explicitly createSegmentCodec
in there user code.It seems reasonable to only have one impl of
def /...