Add redoc
This commit is contained in:
parent
d81a830e3f
commit
b1e2efa75f
@ -3,7 +3,7 @@ package be.simplenotes.c2c.routes
|
||||
import be.simplenotes.c2c.templates.render
|
||||
import com.mitchellbosecke.pebble.PebbleEngine
|
||||
import org.http4k.contract.ContractRoute
|
||||
import org.http4k.contract.bindContract
|
||||
import org.http4k.contract.meta
|
||||
import org.http4k.core.HttpHandler
|
||||
import org.http4k.core.Method
|
||||
import org.http4k.core.Response
|
||||
@ -12,7 +12,9 @@ import org.http4k.core.Status
|
||||
class IndexRoute(private val engine: PebbleEngine) {
|
||||
|
||||
fun route(): ContractRoute {
|
||||
val spec = "/" bindContract Method.GET
|
||||
val spec = "/" meta {
|
||||
summary = "Redoc ui"
|
||||
} bindContract Method.GET
|
||||
|
||||
val route: HttpHandler = {
|
||||
Response(Status.OK).body(engine.render("index"))
|
||||
|
||||
@ -16,7 +16,7 @@ class PdfRoute(private val api: Api, private val pdfCreator: PdfCreator) {
|
||||
|
||||
fun route(): ContractRoute {
|
||||
val spec = "/route" / Path.of("id", "Route's ID") / "pdf" meta {
|
||||
summary = "Route details"
|
||||
summary = "Generate pdf from routes"
|
||||
} bindContract Method.GET
|
||||
|
||||
fun route(id: String, pdf: String): HttpHandler = {
|
||||
|
||||
@ -19,7 +19,7 @@ class SearchRoute(private val api: Api) {
|
||||
|
||||
val spec = "/search" meta {
|
||||
summary = "Search routes and waypoints"
|
||||
tags += Tag("Query")
|
||||
queries += query
|
||||
returning(Status.OK, responseLens to SearchResults(listOf(RouteResult(
|
||||
id = "57103",
|
||||
title = "Tour de Bavon : Thor",
|
||||
|
||||
@ -1,11 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="">
|
||||
<title>Title</title>
|
||||
<title>ReDoc</title>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
Hello
|
||||
<redoc spec-url='/api/swagger.json'></redoc>
|
||||
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user