From 69177ebcd195aafb91a54c58fae675288f808e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Tue, 30 Sep 2025 17:00:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DNewSwaggerUI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- swagger_ui.go | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/swagger_ui.go b/swagger_ui.go index b6c740d..ac73b80 100644 --- a/swagger_ui.go +++ b/swagger_ui.go @@ -26,9 +26,43 @@ import ( // NewSwaggerUI ... func NewSwaggerUI(info *define.Info, servers []*define.ServerItem, uiTheme enums.SwaggerUITheme) *SwaggerUI { + if nil == info { + info = &define.Info{ + Description: "", + Title: "", + TermsOfService: "", + Contact: &define.Contact{ + Name: "", + Url: "", + Email: "", + }, + License: nil, + Version: "", + } + } + if nil == info.Contact { + info.Contact = &define.Contact{ + Name: "", + Url: "", + Email: "", + } + } + if nil == info.License { + info.License = &define.License{ + Name: "", + Url: "", + } + } return &SwaggerUI{ - docInstance: NewOpenapiDoc(info, servers), - uiTheme: uiTheme, + docInstance: NewOpenapiDoc( + WithDocDescription(info.Description), + WithDocTitle(info.Title), + WithDocContactEmail(info.Contact.Email), + WithDocContactName(info.Contact.Name), + WithDocLicense(info.License.Name), + WithDocServers(servers), + ), + uiTheme: uiTheme, } }