🐛 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:
Andrey Antukh 2026-05-18 12:54:16 +02:00 committed by GitHub
parent 9928249d4f
commit 9de25c5404
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 3 deletions

View File

@ -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 [_]

View File

@ -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"]))))))