Add redoc

This commit is contained in:
Hubert Van De Walle 2020-09-26 13:50:50 +02:00
parent d81a830e3f
commit b1e2efa75f
4 changed files with 18 additions and 8 deletions

View File

@ -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"))

View File

@ -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 = {

View File

@ -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",

View File

@ -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>