From 419af78d90fc478b909e39c1908db3258d3cacc1 Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Wed, 29 Jan 2020 15:27:53 +0100 Subject: [PATCH] TT#74005 add print support to the swagger doc Change-Id: Ia6a07e0d79504cedd57169114bdbf85be8dae7d4 --- share/templates/api/root/chswaggerui.tt | 57 +++++++++++++++++-------- 1 file changed, 39 insertions(+), 18 deletions(-) diff --git a/share/templates/api/root/chswaggerui.tt b/share/templates/api/root/chswaggerui.tt index 01373a1eb2..e9a9f83d4c 100644 --- a/share/templates/api/root/chswaggerui.tt +++ b/share/templates/api/root/chswaggerui.tt @@ -102,24 +102,45 @@ function HideTopbarPlugin() { window.onload = function() { // Build a system - const ui = SwaggerUIBundle({ - url: "/api?swagger=1", - dom_id: '#swagger-ui', - deepLinking: true, - presets: [ - SwaggerUIBundle.presets.apis, - SwaggerUIStandalonePreset - ], - plugins: [ - SwaggerUIBundle.plugins.DownloadUrl, - HideTopbarPlugin - ], - layout: "StandaloneLayout", - //layout: "BaseLayout", - docExpansion: "none", - defaultModelsExpandDepth: 0, - validatorUrl: null - }) + if (window.matchMedia("print").matches) { + const ui = SwaggerUIBundle({ + url: "/api?swagger=1", + dom_id: '#swagger-ui', + deepLinking: true, + presets: [ + SwaggerUIBundle.presets.apis, + SwaggerUIStandalonePreset + ], + plugins: [ + SwaggerUIBundle.plugins.DownloadUrl, + HideTopbarPlugin + ], + layout: "StandaloneLayout", + //layout: "BaseLayout", + docExpansion: "full", + defaultModelsExpandDepth: 0, + validatorUrl: null + }) + } else { + const ui = SwaggerUIBundle({ + url: "/api?swagger=1", + dom_id: '#swagger-ui', + deepLinking: true, + presets: [ + SwaggerUIBundle.presets.apis, + SwaggerUIStandalonePreset + ], + plugins: [ + SwaggerUIBundle.plugins.DownloadUrl, + HideTopbarPlugin + ], + layout: "StandaloneLayout", + //layout: "BaseLayout", + docExpansion: "none", + defaultModelsExpandDepth: 0, + validatorUrl: null + }) + } window.ui = ui };