From 5c104f3c99fd5b287f4fea170518b7db4961de6a Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Thu, 26 Mar 2026 08:58:03 +0700 Subject: [PATCH] Merge RspamdSymbol into SpamTestDetail in OpenAPI spec Add params field to SpamTestDetail, update RspamdResult.symbols to reference SpamTestDetail instead of the now-removed RspamdSymbol schema, and update Go code accordingly. --- api/openapi.yaml | 25 +++++-------------------- pkg/analyzer/rspamd.go | 4 ++-- pkg/analyzer/rspamd_test.go | 2 +- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/api/openapi.yaml b/api/openapi.yaml index e989261..225e26c 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -926,6 +926,10 @@ components: format: float description: Score contribution of this test example: -1.9 + params: + type: string + description: Symbol parameters or options + example: "0.02" description: type: string description: Human-readable description of what this test checks @@ -975,7 +979,7 @@ components: symbols: type: object additionalProperties: - $ref: '#/components/schemas/RspamdSymbol' + $ref: '#/components/schemas/SpamTestDetail' description: Map of triggered rspamd symbols to their details example: BAYES_HAM: @@ -986,25 +990,6 @@ components: type: string description: Full rspamd report (raw X-Spamd-Result header) - RspamdSymbol: - type: object - required: - - name - - score - properties: - name: - type: string - description: Symbol name - example: "BAYES_HAM" - score: - type: number - format: float - description: Score contribution of this symbol - example: -1.9 - params: - type: string - description: Symbol parameters or options - example: "0.02" DNSResults: type: object diff --git a/pkg/analyzer/rspamd.go b/pkg/analyzer/rspamd.go index 3fed81d..f37467b 100644 --- a/pkg/analyzer/rspamd.go +++ b/pkg/analyzer/rspamd.go @@ -59,7 +59,7 @@ func (a *RspamdAnalyzer) AnalyzeRspamd(email *EmailMessage) *api.RspamdResult { } result := &api.RspamdResult{ - Symbols: make(map[string]api.RspamdSymbol), + Symbols: make(map[string]api.SpamTestDetail), } // Parse X-Spamd-Result header (primary source for score, threshold, and symbols) @@ -129,7 +129,7 @@ func (a *RspamdAnalyzer) parseSpamdResult(header string, result *api.RspamdResul if len(matches) > 2 { name := matches[1] score, _ := strconv.ParseFloat(matches[2], 64) - sym := api.RspamdSymbol{ + sym := api.SpamTestDetail{ Name: name, Score: float32(score), } diff --git a/pkg/analyzer/rspamd_test.go b/pkg/analyzer/rspamd_test.go index de98fe8..df37744 100644 --- a/pkg/analyzer/rspamd_test.go +++ b/pkg/analyzer/rspamd_test.go @@ -131,7 +131,7 @@ func TestParseSpamdResult(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { result := &api.RspamdResult{ - Symbols: make(map[string]api.RspamdSymbol), + Symbols: make(map[string]api.SpamTestDetail), } analyzer.parseSpamdResult(tt.header, result)