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, } }