Skip to content
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

Use ReDoc 2.0.0-rc.76 from CDN #102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions servant-swagger-ui-redoc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
- 0.3.5.2.0.0.76
- Update to ReDoc-2.0.0-rc.76
- Use Redocly's CDN

- 0.3.2.1.22.3
- Update to ReDoc-1.22.3

Expand Down
8 changes: 0 additions & 8 deletions servant-swagger-ui-redoc/redoc-dist-1.22.3/redoc.min.js

This file was deleted.

5 changes: 3 additions & 2 deletions servant-swagger-ui-redoc/redoc.index.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
</style>
<script>
// Force Strict-URL Routing for assets relative paths
// if the path contains no fragment (otherwise fragment links don't work)
(function onload() {
if (!window.location.href.endsWith("/")) {
if (!window.location.href.endsWith("/") && window.location.href.indexOf("#") === -1) {
window.location.href += "/";
}
}());
</script>
</head>
<body>
<redoc spec-url='../SERVANT_SWAGGER_UI_SCHEMA'></redoc>
<script src="redoc.min.js"> </script>
<script src="https://cdn.redoc.ly/redoc/v2.0.0-rc.76/bundles/redoc.standalone.js"> </script>
</body>
</html>
3 changes: 1 addition & 2 deletions servant-swagger-ui-redoc/servant-swagger-ui-redoc.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.12
name: servant-swagger-ui-redoc
version: 0.3.4.1.22.3
version: 0.3.5.2.0.0.76
synopsis: Servant swagger ui: ReDoc theme
category: Web, Servant, Swagger
description:
Expand All @@ -25,7 +25,6 @@ tested-with:
|| ==9.2.2

extra-source-files:
redoc-dist-1.22.3/redoc.min.js
redoc.index.html.tmpl
CHANGELOG.md

Expand Down
15 changes: 5 additions & 10 deletions servant-swagger-ui-redoc/src/Servant/Swagger/UI/ReDoc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,12 @@ module Servant.Swagger.UI.ReDoc (
redocSchemaUIServerT',

-- ** ReDoc theme
redocIndexTemplate,
redocFiles
redocIndexTemplate
) where

import Servant.Swagger.UI.Core

import Data.Aeson (ToJSON, Value)
import Data.ByteString (ByteString)
import Data.Text (Text)
import FileEmbedLzma
import Servant
Expand All @@ -70,7 +68,7 @@ redocSchemaUIServer
:: (Server api ~ Handler Value, ToJSON a)
=> a -> Server (SwaggerSchemaUI' dir api)
redocSchemaUIServer =
swaggerSchemaUIServerImpl redocIndexTemplate redocFiles
swaggerSchemaUIServerImpl redocIndexTemplate []

-- | Serve Redoc Swagger UI on @/dir@ using @api@ as a Swagger spec source.
--
Expand All @@ -83,13 +81,13 @@ redocSchemaUIServerT
:: (Monad m, ServerT api m ~ m Value, ToJSON a)
=> a -> ServerT (SwaggerSchemaUI' dir api) m
redocSchemaUIServerT =
swaggerSchemaUIServerImpl redocIndexTemplate redocFiles
swaggerSchemaUIServerImpl redocIndexTemplate []

-- | Use a custom server to serve the Swagger spec source.
redocSchemaUIServer'
:: Server api -> Server (SwaggerSchemaUI' dir api)
redocSchemaUIServer' =
swaggerSchemaUIServerImpl' redocIndexTemplate redocFiles
swaggerSchemaUIServerImpl' redocIndexTemplate []

-- | Use a custom server to serve the Redoc Swagger spec source.
--
Expand All @@ -103,10 +101,7 @@ redocSchemaUIServer' =
redocSchemaUIServerT'
:: Monad m => ServerT api m -> ServerT (SwaggerSchemaUI' dir api) m
redocSchemaUIServerT' =
swaggerSchemaUIServerImpl' redocIndexTemplate redocFiles
swaggerSchemaUIServerImpl' redocIndexTemplate []

redocIndexTemplate :: Text
redocIndexTemplate = $(embedText "redoc.index.html.tmpl")

redocFiles :: [(FilePath, ByteString)]
redocFiles = $(embedRecursiveDir "redoc-dist-1.22.3")