2022-08-04 11:51:12 -05:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2023-08-01 03:27:44 -05:00
|
|
|
"strings"
|
2022-08-04 11:51:12 -05:00
|
|
|
|
2023-01-27 01:50:36 -06:00
|
|
|
contextmodel "github.com/grafana/grafana/pkg/services/contexthandler/model"
|
2022-08-04 11:51:12 -05:00
|
|
|
)
|
|
|
|
|
2023-01-27 01:50:36 -06:00
|
|
|
func openapi3(c *contextmodel.ReqContext) {
|
2023-08-30 10:46:47 -05:00
|
|
|
data := map[string]any{
|
2023-08-01 03:27:44 -05:00
|
|
|
"Nonce": c.RequestNonce,
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add CSP for unpkg.com to allow loading of Swagger UI assets
|
|
|
|
if existingCSP := c.Resp.Header().Get("Content-Security-Policy"); existingCSP != "" {
|
|
|
|
newCSP := strings.Replace(existingCSP, "style-src", "style-src https://unpkg.com/", 1)
|
|
|
|
c.Resp.Header().Set("Content-Security-Policy", newCSP)
|
|
|
|
}
|
|
|
|
|
|
|
|
c.HTML(http.StatusOK, "openapi3", data)
|
2022-08-04 11:51:12 -05:00
|
|
|
}
|