- Document every D-09 admin route for the OpenAPI contract. - Fail the gate on skipped tests, zero-test runs, and a missing admin path.
380 lines
12 KiB
Go
380 lines
12 KiB
Go
package cabana
|
|
|
|
// Admin API annotations. swag reads these with the handler package so
|
|
// docs/openapi.json lists every D-09 route. The functions are not mounted;
|
|
// service.mount in http.go is the runtime route table, and
|
|
// TestPhase09PermissionMatrix fails if the two lists diverge.
|
|
|
|
// ErrorBody is one D-10 error object.
|
|
type ErrorBody struct {
|
|
Code string `json:"code"`
|
|
Message string `json:"message"`
|
|
Details map[string]any `json:"details"`
|
|
}
|
|
|
|
// ErrorEnvelope is the D-10 error envelope.
|
|
type ErrorEnvelope struct {
|
|
Error ErrorBody `json:"error"`
|
|
}
|
|
|
|
// SuccessMeta is the D-10 meta object.
|
|
type SuccessMeta struct {
|
|
Locale string `json:"locale,omitempty"`
|
|
Page int `json:"page,omitempty"`
|
|
PerPage int `json:"per_page,omitempty"`
|
|
Total int `json:"total,omitempty"`
|
|
LastPage int `json:"last_page,omitempty"`
|
|
}
|
|
|
|
// SuccessEnvelope is the D-10 success envelope.
|
|
type SuccessEnvelope struct {
|
|
Data any `json:"data"`
|
|
Meta SuccessMeta `json:"meta"`
|
|
}
|
|
|
|
// AdminLoginData is the admin login payload.
|
|
type AdminLoginData struct {
|
|
AccessToken string `json:"access_token"`
|
|
TokenType string `json:"token_type"`
|
|
}
|
|
|
|
// AdminLoginEnvelope is the admin login success body.
|
|
type AdminLoginEnvelope struct {
|
|
Data AdminLoginData `json:"data"`
|
|
Meta SuccessMeta `json:"meta"`
|
|
}
|
|
|
|
// AdminLogin documents POST /_admin/api/v1/auth/login.
|
|
//
|
|
// @Summary Admin login
|
|
// @Tags admin
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Success 200 {object} AdminLoginEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/auth/login [post]
|
|
func AdminLogin() {}
|
|
|
|
// AdminRefresh documents POST /_admin/api/v1/auth/refresh.
|
|
//
|
|
// @Summary Refresh an admin token
|
|
// @Tags admin
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Success 200 {object} AdminLoginEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/auth/refresh [post]
|
|
func AdminRefresh() {}
|
|
|
|
// AdminLogout documents POST /_admin/api/v1/auth/logout.
|
|
//
|
|
// @Summary Admin logout
|
|
// @Tags admin
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/auth/logout [post]
|
|
func AdminLogout() {}
|
|
|
|
// AdminMe documents GET /_admin/api/v1/auth/me.
|
|
//
|
|
// @Summary Current admin
|
|
// @Tags admin
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/auth/me [get]
|
|
func AdminMe() {}
|
|
|
|
// AdminNavigation documents GET /_admin/api/v1/navigation.
|
|
//
|
|
// @Summary Admin navigation
|
|
// @Tags admin
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/navigation [get]
|
|
func AdminNavigation() {}
|
|
|
|
// AdminSettingsList documents GET /_admin/api/v1/settings.
|
|
//
|
|
// @Summary List admin settings
|
|
// @Tags admin
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/settings [get]
|
|
func AdminSettingsList() {}
|
|
|
|
// AdminSettingsSchema documents GET /_admin/api/v1/settings/{code}/schema.
|
|
//
|
|
// @Summary Admin settings schema
|
|
// @Tags admin
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param code path string true "Settings code"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Failure 404 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/settings/{code}/schema [get]
|
|
func AdminSettingsSchema() {}
|
|
|
|
// AdminSettingsGet documents GET /_admin/api/v1/settings/{code}.
|
|
//
|
|
// @Summary Read admin settings
|
|
// @Tags admin
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param code path string true "Settings code"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Failure 404 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/settings/{code} [get]
|
|
func AdminSettingsGet() {}
|
|
|
|
// AdminSettingsPut documents PUT /_admin/api/v1/settings/{code}.
|
|
//
|
|
// @Summary Update admin settings
|
|
// @Tags admin
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param code path string true "Settings code"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Failure 422 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/settings/{code} [put]
|
|
func AdminSettingsPut() {}
|
|
|
|
// AdminListSchema documents the list schema route.
|
|
//
|
|
// @Summary Admin list schema
|
|
// @Tags admin
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param vendor path string true "Vendor"
|
|
// @Param plugin path string true "Plugin"
|
|
// @Param controller path string true "Controller"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Failure 404 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/{vendor}/{plugin}/{controller}/schema/list [get]
|
|
func AdminListSchema() {}
|
|
|
|
// AdminFormSchema documents the form schema route.
|
|
//
|
|
// @Summary Admin form schema
|
|
// @Tags admin
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param vendor path string true "Vendor"
|
|
// @Param plugin path string true "Plugin"
|
|
// @Param controller path string true "Controller"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Failure 404 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/{vendor}/{plugin}/{controller}/schema/form [get]
|
|
func AdminFormSchema() {}
|
|
|
|
// AdminRelationSchema documents the relation schema route.
|
|
//
|
|
// @Summary Admin relation schema
|
|
// @Tags admin
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param vendor path string true "Vendor"
|
|
// @Param plugin path string true "Plugin"
|
|
// @Param controller path string true "Controller"
|
|
// @Param name path string true "Relation name"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Failure 404 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/{vendor}/{plugin}/{controller}/schema/relation/{name} [get]
|
|
func AdminRelationSchema() {}
|
|
|
|
// AdminList documents the record list route.
|
|
//
|
|
// @Summary List admin records
|
|
// @Tags admin
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param vendor path string true "Vendor"
|
|
// @Param plugin path string true "Plugin"
|
|
// @Param controller path string true "Controller"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Failure 422 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/{vendor}/{plugin}/{controller} [get]
|
|
func AdminList() {}
|
|
|
|
// AdminCreate documents the record create route.
|
|
//
|
|
// @Summary Create an admin record
|
|
// @Tags admin
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param vendor path string true "Vendor"
|
|
// @Param plugin path string true "Plugin"
|
|
// @Param controller path string true "Controller"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Failure 422 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/{vendor}/{plugin}/{controller} [post]
|
|
func AdminCreate() {}
|
|
|
|
// AdminBulkDelete documents the bulk delete route.
|
|
//
|
|
// @Summary Bulk-delete admin records
|
|
// @Tags admin
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param vendor path string true "Vendor"
|
|
// @Param plugin path string true "Plugin"
|
|
// @Param controller path string true "Controller"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Failure 422 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/{vendor}/{plugin}/{controller}/bulk-delete [post]
|
|
func AdminBulkDelete() {}
|
|
|
|
// AdminShow documents the record show route.
|
|
//
|
|
// @Summary Show an admin record
|
|
// @Tags admin
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param vendor path string true "Vendor"
|
|
// @Param plugin path string true "Plugin"
|
|
// @Param controller path string true "Controller"
|
|
// @Param id path integer true "Record id"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Failure 404 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/{vendor}/{plugin}/{controller}/{id} [get]
|
|
func AdminShow() {}
|
|
|
|
// AdminUpdate documents the record update route.
|
|
//
|
|
// @Summary Update an admin record
|
|
// @Tags admin
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param vendor path string true "Vendor"
|
|
// @Param plugin path string true "Plugin"
|
|
// @Param controller path string true "Controller"
|
|
// @Param id path integer true "Record id"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Failure 422 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/{vendor}/{plugin}/{controller}/{id} [put]
|
|
func AdminUpdate() {}
|
|
|
|
// AdminDelete documents the record delete route.
|
|
//
|
|
// @Summary Delete an admin record
|
|
// @Tags admin
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param vendor path string true "Vendor"
|
|
// @Param plugin path string true "Plugin"
|
|
// @Param controller path string true "Controller"
|
|
// @Param id path integer true "Record id"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Failure 404 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/{vendor}/{plugin}/{controller}/{id} [delete]
|
|
func AdminDelete() {}
|
|
|
|
// AdminRelationLinked documents the linked-relation route.
|
|
//
|
|
// @Summary List linked relation records
|
|
// @Tags admin
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param vendor path string true "Vendor"
|
|
// @Param plugin path string true "Plugin"
|
|
// @Param controller path string true "Controller"
|
|
// @Param id path integer true "Owner id"
|
|
// @Param name path string true "Relation name"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/{vendor}/{plugin}/{controller}/{id}/relations/{name} [get]
|
|
func AdminRelationLinked() {}
|
|
|
|
// AdminRelationCandidates documents the relation candidate route.
|
|
//
|
|
// @Summary List relation candidates
|
|
// @Tags admin
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param vendor path string true "Vendor"
|
|
// @Param plugin path string true "Plugin"
|
|
// @Param controller path string true "Controller"
|
|
// @Param id path integer true "Owner id"
|
|
// @Param name path string true "Relation name"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/{vendor}/{plugin}/{controller}/{id}/relations/{name}/candidates [get]
|
|
func AdminRelationCandidates() {}
|
|
|
|
// AdminRelationLink documents the relation link route.
|
|
//
|
|
// @Summary Link relation records
|
|
// @Tags admin
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param vendor path string true "Vendor"
|
|
// @Param plugin path string true "Plugin"
|
|
// @Param controller path string true "Controller"
|
|
// @Param id path integer true "Owner id"
|
|
// @Param name path string true "Relation name"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Failure 422 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/{vendor}/{plugin}/{controller}/{id}/relations/{name}/link [post]
|
|
func AdminRelationLink() {}
|
|
|
|
// AdminRelationUnlink documents the relation unlink route.
|
|
//
|
|
// @Summary Unlink relation records
|
|
// @Tags admin
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security BackendBearer
|
|
// @Param vendor path string true "Vendor"
|
|
// @Param plugin path string true "Plugin"
|
|
// @Param controller path string true "Controller"
|
|
// @Param id path integer true "Owner id"
|
|
// @Param name path string true "Relation name"
|
|
// @Success 200 {object} SuccessEnvelope
|
|
// @Failure 401 {object} ErrorEnvelope
|
|
// @Failure 403 {object} ErrorEnvelope
|
|
// @Failure 422 {object} ErrorEnvelope
|
|
// @Router /_admin/api/v1/{vendor}/{plugin}/{controller}/{id}/relations/{name}/unlink [post]
|
|
func AdminRelationUnlink() {}
|