feat(cabana): add markdown preview admin route

- POST {prefix}/api/v1/markdown/preview renders {markdown} through
  cabana.RenderMarkdown in the backend-guarded group behind requireAjax
- refused output is a 422 validation_failed on markdown with a fixed message
- swag annotation, regenerated admin.json and schema.d.ts
- route inventories, CSRF walk (26) and OpenAPI conformance learn the route
- README and docs/backend/forms.md document the route
This commit is contained in:
Jakub Zych
2026-10-06 20:53:07 +02:00
parent 0ff928d6cf
commit b492e79f2b
13 changed files with 517 additions and 6 deletions

View File

@@ -245,6 +245,24 @@ func AdminSettingsGet() {}
// @Router /settings/{code} [put]
func AdminSettingsPut() {}
// AdminMarkdownPreview documents POST /markdown/preview.
//
// @Summary Render a markdown preview
// @Description Renders the markdown source through cabana.RenderMarkdown (goldmark without unsafe HTML) and answers the sanitized HTML. Output the renderer's gate refuses is a 422 on markdown. Any backend session may call it.
// @Tags admin
// @Accept json
// @Produce json
// @Security BackendBearer
// @Param body body AdminMarkdownPreviewRequest true "Markdown source"
// @Success 200 {object} Envelope[AdminMarkdownPreviewResult]
// @Failure 401 {object} ErrorEnvelope
// @Failure 403 {object} ErrorEnvelope
// @Failure 404 {object} ErrorEnvelope
// @Failure 413 {object} ErrorEnvelope
// @Failure 422 {object} ErrorEnvelope
// @Router /markdown/preview [post]
func AdminMarkdownPreview() {}
// AdminListSchema documents the list schema route.
//
// @Summary Admin list schema