Skip to content

Commit 8ae0445

Browse files
committed
Fix #67: Recover swagger.json url in template
1 parent fb9c34b commit 8ae0445

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

servant-swagger-ui/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
- 0.3.4.3.22.2
2+
- Fix #67: We didn't use served `swagger.json`
3+
14
- 0.3.3.3.22.2
25
- Update to `swagger-ui-3.22.2`
36
- Add `swaggerSchemaUIServer'`

servant-swagger-ui/index.html.tmpl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,18 @@
4747
<script src="./swagger-ui-standalone-preset.js"> </script>
4848
<script>
4949
window.onload = function() {
50+
// servant-swagger-ui addition
51+
var ssuDir = "SERVANT_SWAGGER_UI_DIR";
52+
var ssuSchema = "SERVANT_SWAGGER_UI_SCHEMA";
53+
// more concretely:
54+
// replace /swagger-ui/ or /swagger-ui/index.html with /swagger.json
55+
// we always have trailing slash!
56+
var re = new RegExp("\/" + ssuDir + "/(?:index\\.html)?$","g");
57+
var url = window.location.pathname.replace(re, "/" + ssuSchema);
58+
5059
// Begin Swagger UI call region
5160
const ui = SwaggerUIBundle({
52-
url: "https://petstore.swagger.io/v2/swagger.json",
61+
url: url,
5362
dom_id: '#swagger-ui',
5463
deepLinking: true,
5564
presets: [

servant-swagger-ui/servant-swagger-ui.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 1.12
22
name: servant-swagger-ui
3-
version: 0.3.3.3.22.2
3+
version: 0.3.4.3.22.2
44
synopsis: Servant swagger ui
55
category: Web, Servant, Swagger
66
description:

0 commit comments

Comments
 (0)