From 9dbb092447ef86ba5bfaf5bd9cd354006e87c852 Mon Sep 17 00:00:00 2001 From: Ralph Slooten Date: Fri, 19 Jun 2026 21:51:55 +1200 Subject: [PATCH] Fix: Refactor Web UI configuration definitions in Swagger documentation --- server/apiv1/swaggerResponses.go | 78 ++++++++++---------- server/ui/api/v1/swagger.json | 119 ++++++++++++++++--------------- 2 files changed, 103 insertions(+), 94 deletions(-) diff --git a/server/apiv1/swaggerResponses.go b/server/apiv1/swaggerResponses.go index fa9cdfb..f31b39a 100644 --- a/server/apiv1/swaggerResponses.go +++ b/server/apiv1/swaggerResponses.go @@ -53,49 +53,53 @@ type jsonErrorResponse struct { } } +// Web UI configuration settings +// swagger:model WebUIConfiguration +type WebUIConfiguration struct { + // Optional label to identify this Mailpit instance + Label string + // Message Relay information + MessageRelay struct { + // Whether message relaying (release) is enabled + Enabled bool + // The configured SMTP server address + SMTPServer string + // Enforced Return-Path (if set) for relay bounces + ReturnPath string + // Only allow relaying to these recipients (regex) + AllowedRecipients string + // Block relaying to these recipients (regex) + BlockedRecipients string + // Overrides the "From" address for all relayed messages + OverrideFrom string + // Preserve the original Message-IDs when relaying messages + PreserveMessageIDs bool + + // DEPRECATED 2024/03/12 + // swagger:ignore + RecipientAllowlist string + } + + // Whether SpamAssassin is enabled + SpamAssassin bool + + // Whether Chaos support is enabled at runtime + ChaosEnabled bool + + // Whether messages with duplicate IDs are ignored + DuplicatesIgnored bool + + // Whether the delete button should be hidden + HideDeleteAllButton bool +} + // Web UI configuration response // swagger:response WebUIConfigurationResponse type webUIConfigurationResponse struct { // Web UI configuration settings // // in: body - Body struct { - // Optional label to identify this Mailpit instance - Label string - // Message Relay information - MessageRelay struct { - // Whether message relaying (release) is enabled - Enabled bool - // The configured SMTP server address - SMTPServer string - // Enforced Return-Path (if set) for relay bounces - ReturnPath string - // Only allow relaying to these recipients (regex) - AllowedRecipients string - // Block relaying to these recipients (regex) - BlockedRecipients string - // Overrides the "From" address for all relayed messages - OverrideFrom string - // Preserve the original Message-IDs when relaying messages - PreserveMessageIDs bool - - // DEPRECATED 2024/03/12 - // swagger:ignore - RecipientAllowlist string - } - - // Whether SpamAssassin is enabled - SpamAssassin bool - - // Whether Chaos support is enabled at runtime - ChaosEnabled bool - - // Whether messages with duplicate IDs are ignored - DuplicatesIgnored bool - - // Whether the delete button should be hidden - HideDeleteAllButton bool - } + Body WebUIConfiguration } // Application information diff --git a/server/ui/api/v1/swagger.json b/server/ui/api/v1/swagger.json index d9b11aa..5f0f3af 100644 --- a/server/ui/api/v1/swagger.json +++ b/server/ui/api/v1/swagger.json @@ -1955,6 +1955,67 @@ }, "x-go-name": "Result", "x-go-package": "github.com/axllent/mailpit/internal/spamassassin" + }, + "WebUIConfiguration": { + "description": "Web UI configuration settings", + "type": "object", + "properties": { + "ChaosEnabled": { + "description": "Whether Chaos support is enabled at runtime", + "type": "boolean" + }, + "DuplicatesIgnored": { + "description": "Whether messages with duplicate IDs are ignored", + "type": "boolean" + }, + "HideDeleteAllButton": { + "description": "Whether the delete button should be hidden", + "type": "boolean" + }, + "Label": { + "description": "Optional label to identify this Mailpit instance", + "type": "string" + }, + "MessageRelay": { + "description": "Message Relay information", + "type": "object", + "properties": { + "AllowedRecipients": { + "description": "Only allow relaying to these recipients (regex)", + "type": "string" + }, + "BlockedRecipients": { + "description": "Block relaying to these recipients (regex)", + "type": "string" + }, + "Enabled": { + "description": "Whether message relaying (release) is enabled", + "type": "boolean" + }, + "OverrideFrom": { + "description": "Overrides the \"From\" address for all relayed messages", + "type": "string" + }, + "PreserveMessageIDs": { + "description": "Preserve the original Message-IDs when relaying messages", + "type": "boolean" + }, + "ReturnPath": { + "description": "Enforced Return-Path (if set) for relay bounces", + "type": "string" + }, + "SMTPServer": { + "description": "The configured SMTP server address", + "type": "string" + } + } + }, + "SpamAssassin": { + "description": "Whether SpamAssassin is enabled", + "type": "boolean" + } + }, + "x-go-package": "github.com/axllent/mailpit/server/apiv1" } }, "responses": { @@ -2062,63 +2123,7 @@ "WebUIConfigurationResponse": { "description": "Web UI configuration response", "schema": { - "type": "object", - "properties": { - "ChaosEnabled": { - "description": "Whether Chaos support is enabled at runtime", - "type": "boolean" - }, - "DuplicatesIgnored": { - "description": "Whether messages with duplicate IDs are ignored", - "type": "boolean" - }, - "HideDeleteAllButton": { - "description": "Whether the delete button should be hidden", - "type": "boolean" - }, - "Label": { - "description": "Optional label to identify this Mailpit instance", - "type": "string" - }, - "MessageRelay": { - "description": "Message Relay information", - "type": "object", - "properties": { - "AllowedRecipients": { - "description": "Only allow relaying to these recipients (regex)", - "type": "string" - }, - "BlockedRecipients": { - "description": "Block relaying to these recipients (regex)", - "type": "string" - }, - "Enabled": { - "description": "Whether message relaying (release) is enabled", - "type": "boolean" - }, - "OverrideFrom": { - "description": "Overrides the \"From\" address for all relayed messages", - "type": "string" - }, - "PreserveMessageIDs": { - "description": "Preserve the original Message-IDs when relaying messages", - "type": "boolean" - }, - "ReturnPath": { - "description": "Enforced Return-Path (if set) for relay bounces", - "type": "string" - }, - "SMTPServer": { - "description": "The configured SMTP server address", - "type": "string" - } - } - }, - "SpamAssassin": { - "description": "Whether SpamAssassin is enabled", - "type": "boolean" - } - } + "$ref": "#/definitions/WebUIConfiguration" } } }