-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlink.go
More file actions
57 lines (49 loc) · 1.47 KB
/
link.go
File metadata and controls
57 lines (49 loc) · 1.47 KB
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
package openapi
// Link represents a link in OpenAPI
type Link struct {
OperationRef string `json:"operationRef,omitempty"`
OperationID string `json:"operationId,omitempty"`
Parameters map[string]interface{} `json:"parameters,omitempty"`
RequestBody interface{} `json:"requestBody,omitempty"`
Description string `json:"description,omitempty"`
Server *Server `json:"server,omitempty"`
}
// NewLink creates a new link
func NewLink() Link {
return Link{
Parameters: make(map[string]interface{}),
}
}
// WithOperationRef sets the operation reference
func (l Link) WithOperationRef(ref string) Link {
l.OperationRef = ref
return l
}
// WithOperationID sets the operation ID
func (l Link) WithOperationID(operationID string) Link {
l.OperationID = operationID
return l
}
// WithParameter adds a parameter to the link
func (l Link) WithParameter(name string, value interface{}) Link {
if l.Parameters == nil {
l.Parameters = make(map[string]interface{})
}
l.Parameters[name] = value
return l
}
// WithRequestBody sets the request body for the link
func (l Link) WithRequestBody(body interface{}) Link {
l.RequestBody = body
return l
}
// WithDescription sets the description
func (l Link) WithDescription(description string) Link {
l.Description = description
return l
}
// WithServer sets the server for the link
func (l Link) WithServer(server *Server) Link {
l.Server = server
return l
}