-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserverOptions.go
64 lines (57 loc) · 1.28 KB
/
serverOptions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package shiftapi
import "github.com/getkin/kin-openapi/openapi3"
type ServerInfo struct {
Summary string
Title string
Description string
TermsOfService string
Contact *Contact
License *License
Version string
}
type Contact struct {
Name string
URL string
Email string
}
type License struct {
Name string
URL string
Identifier string
}
func WithServerInfo(info ServerInfo) func(*ShiftAPI) *ShiftAPI {
return func(api *ShiftAPI) *ShiftAPI {
api.spec.Info = &openapi3.Info{
Title: info.Title,
Description: info.Description,
Version: info.Version,
}
if info.Contact != nil {
api.spec.Info.Contact = &openapi3.Contact{
Name: info.Contact.Name,
URL: info.Contact.URL,
Email: info.Contact.Email,
}
}
if info.License != nil {
api.spec.Info.License = &openapi3.License{
Name: info.License.Name,
URL: info.License.URL,
}
}
return api
}
}
type ExternalDocs struct {
Description string
URL string
}
func WithExternalDocs(externalDocs ExternalDocs) func(*ShiftAPI) *ShiftAPI {
return func(api *ShiftAPI) *ShiftAPI {
api.spec.ExternalDocs = &openapi3.ExternalDocs{
Description: externalDocs.Description,
URL: externalDocs.URL,
}
return api
}
}