From b2bc74fafa33e340504d3b5671dc0c82661baf6c Mon Sep 17 00:00:00 2001
From: Kyle Doherty <5248953+kdoh@users.noreply.github.com>
Date: Thu, 21 Mar 2024 11:25:28 -0400
Subject: [PATCH] Small bit of api doc styling (#40443)

* tweak styling to better match MB

* add Lato as rapidoc font

---------

Co-authored-by: Alexander Solovyov <alexander@solovyov.net>
---
 resources/openapi/index.html | 5 ++++-
 src/metabase/api/routes.clj  | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/resources/openapi/index.html b/resources/openapi/index.html
index c86ab2c80bb..173aaf33d1d 100644
--- a/resources/openapi/index.html
+++ b/resources/openapi/index.html
@@ -4,6 +4,7 @@
     <meta charset="utf-8">
     <title>Metabase API doc</title>
     <script src="rapidoc-min.js"></script>
+    <link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,400;0,700;0,900;1,400;1,700&display=swap" rel="stylesheet" />
   </head>
   <body>
     <!-- https://rapidocweb.com/api.html -->
@@ -11,7 +12,9 @@
               render-style="read"
               heading-text="Metabase"
               show-header="false"
-              allow-server-selection="false">
+              allow-server-selection="false"
+              regular-font="Lato, sans-serif"
+              primary-color="#509ee3">
     </rapi-doc>
   </body>
 </html>
diff --git a/src/metabase/api/routes.clj b/src/metabase/api/routes.clj
index e12e15ace0d..30adfda8313 100644
--- a/src/metabase/api/routes.clj
+++ b/src/metabase/api/routes.clj
@@ -87,7 +87,7 @@
       "/"               (-> (respond "index.html")
                             ;; Better would be to append this to our CSP, but there is no good way right now and it's
                             ;; just a single page. Necessary for rapidoc to work, script injects styles in runtime.
-                            (assoc-in [:headers "Content-Security-Policy"] "style-src 'unsafe-inline'"))
+                            (assoc-in [:headers "Content-Security-Policy"] "script-src 'self' 'unsafe-inline'"))
       "/rapidoc-min.js" (respond "rapidoc-min.js")
       "/openapi.json"   (merge
                          (api/openapi-object (resolve 'metabase.api.routes/routes))
-- 
GitLab