mirror of
https://github.com/penpot/penpot.git
synced 2026-05-20 07:23:42 +00:00
🐛 Fix incorrect content-type on doc endpoint response (#9681)
The /api/main/doc endpoint was returning HTML content with a text/plain content-type header instead of text/html. This caused browsers to render the response as plain text. Added content-type: text/html; charset=utf-8 header to the response in the doc handler and added a regression test to verify the fix. Closes #9680 Signed-off-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
parent
9928249d4f
commit
9de25c5404
@ -96,6 +96,7 @@
|
||||
context (assoc @context :param-style pstyle)]
|
||||
|
||||
{::yres/status 200
|
||||
::yres/headers {"content-type" "text/html; charset=utf-8"}
|
||||
::yres/body (-> (io/resource template)
|
||||
(tmpl/render context))})))
|
||||
(fn [_]
|
||||
|
||||
@ -12,10 +12,12 @@
|
||||
[app.common.schema :as sm]
|
||||
[app.common.schema.generators :as sg]
|
||||
[app.common.schema.test :as smt]
|
||||
[app.config :as cf]
|
||||
[app.rpc :as-alias rpc]
|
||||
[app.rpc.doc :as rpc.doc]
|
||||
[backend-tests.helpers :as th]
|
||||
[clojure.test :as t]))
|
||||
[clojure.test :as t]
|
||||
[yetti.response :as-alias yres]))
|
||||
|
||||
(t/use-fixtures :once th/state-init)
|
||||
|
||||
@ -31,6 +33,17 @@
|
||||
false)))
|
||||
{:num 15}))
|
||||
|
||||
|
||||
|
||||
(t/deftest doc-handler-returns-html-content-type
|
||||
(with-redefs [cf/flags #{:backend-api-doc}]
|
||||
(let [methods (::rpc/methods th/*system*)
|
||||
handler (#'rpc.doc/handler :methods methods
|
||||
:label "main"
|
||||
:entrypoint "http://localhost/api/main/methods"
|
||||
:openapi "http://localhost/api/main/doc/openapi"
|
||||
:template "app/templates/main-api-doc.tmpl")
|
||||
request {}
|
||||
response (handler request)]
|
||||
(t/is (= 200 (::yres/status response)))
|
||||
(t/is (= "text/html; charset=utf-8"
|
||||
(get-in response [::yres/headers "content-type"]))))))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user