-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.go
More file actions
39 lines (33 loc) · 1.04 KB
/
example.go
File metadata and controls
39 lines (33 loc) · 1.04 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
package openapi
// Example represents an example in OpenAPI
type Example struct {
Summary string `json:"summary,omitempty"`
Description string `json:"description,omitempty"`
Value interface{} `json:"value,omitempty"`
ExternalValue string `json:"externalValue,omitempty"`
Extensions map[string]interface{} `json:"-"`
}
// NewExample creates a new example
func NewExample() Example {
return Example{}
}
// WithSummary sets the summary of the example
func (e Example) WithSummary(summary string) Example {
e.Summary = summary
return e
}
// WithDescription sets the description of the example
func (e Example) WithDescription(description string) Example {
e.Description = description
return e
}
// WithValue sets the value of the example
func (e Example) WithValue(value interface{}) Example {
e.Value = value
return e
}
// WithExternalValue sets the external value reference
func (e Example) WithExternalValue(url string) Example {
e.ExternalValue = url
return e
}