Skip to content

Commit

Permalink
Improve implementation of OpenAPIRouter for Scala DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
ihostage committed Jun 11, 2021
1 parent b9be319 commit d5cc96a
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ class OpenAPIRouter(action: DefaultActionBuilder, config: Config) {
def router(service: Service, path: Option[String] = None): Router = {
val openapi: OpenAPIContainer = OpenAPIContainer(service, config)
val route = path.getOrElse(s"/_${service.descriptor.name}/openapi")
val pathExtractor = new StringContext(route).p
Router
.from {
case GET(p"$p*") if p.equals(route) =>
case GET(pathExtractor()) =>
action { request =>
val isJson = "json".equalsIgnoreCase(request.getQueryString("format").orNull)
if (isJson) response(openapi.spec.json, "application/json")
Expand Down

0 comments on commit d5cc96a

Please sign in to comment.