Skip to content
This repository was archived by the owner on Mar 1, 2019. It is now read-only.

Commit 1818a81

Browse files
authored
Merge pull request input-output-hk/cardano-sl#3391 from input-output-hk/Squad1/CO-351/fix-swagger-doc-rendering
[CO-351] Re-introduce custom template for rendering swagger
2 parents de99fa8 + 2a95a94 commit 1818a81

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

redoc-dist/redoc.min.js

-7
This file was deleted.

src/Cardano/Wallet/API/V1/Swagger.hs

+30-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ import Servant (Handler, ServantErr (..), Server)
4646
import Servant.API.Sub
4747
import Servant.Swagger
4848
import Servant.Swagger.UI (SwaggerSchemaUI')
49-
import Servant.Swagger.UI.ReDoc (redocSchemaUIServer)
49+
import Servant.Swagger.UI.Core (swaggerSchemaUIServerImpl)
50+
import Servant.Swagger.UI.ReDoc (redocFiles)
5051
import Test.QuickCheck
5152
import Test.QuickCheck.Gen
5253
import Test.QuickCheck.Random
@@ -822,7 +823,34 @@ leverage the API capabilities.
822823
swaggerSchemaUIServer
823824
:: (Server api ~ Handler Swagger)
824825
=> Swagger -> Server (SwaggerSchemaUI' dir api)
825-
swaggerSchemaUIServer = redocSchemaUIServer
826+
swaggerSchemaUIServer =
827+
swaggerSchemaUIServerImpl redocIndexTemplate redocFiles
828+
where
829+
redocIndexTemplate :: Text
830+
redocIndexTemplate = [text|
831+
<!doctype html>
832+
<html lang="en">
833+
<head>
834+
<title>ReDoc</title>
835+
<meta charset="utf-8"/>
836+
<meta name="viewport" content="width=device-width, initial-scale=1">
837+
<style>
838+
body { margin: 0; padding: 0; }
839+
</style>
840+
<script>
841+
// Force Strict-URL Routing for assets relative paths
842+
(function onload() {
843+
if (!window.location.href.endsWith("/")) {
844+
window.location.href += "/";
845+
}
846+
}());
847+
</script>
848+
</head>
849+
<body>
850+
<redoc spec-url="../SERVANT_SWAGGER_UI_SCHEMA"></redoc>
851+
<script src="redoc.min.js"> </script>
852+
</body>
853+
</html>|]
826854

827855
--
828856
-- The API

0 commit comments

Comments
 (0)