-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencoding.go
More file actions
50 lines (43 loc) · 1.26 KB
/
encoding.go
File metadata and controls
50 lines (43 loc) · 1.26 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
package openapi
// Encoding represents encoding in OpenAPI
type Encoding struct {
ContentType string `json:"contentType,omitempty"`
Headers map[string]Header `json:"headers,omitempty"`
Style string `json:"style,omitempty"`
Explode bool `json:"explode,omitempty"`
AllowReserved bool `json:"allowReserved,omitempty"`
}
// NewEncoding creates a new encoding
func NewEncoding() Encoding {
return Encoding{
Headers: make(map[string]Header),
}
}
// WithContentType sets the content type
func (e Encoding) WithContentType(contentType string) Encoding {
e.ContentType = contentType
return e
}
// WithHeader adds a header to the encoding
func (e Encoding) WithHeader(name string, header Header) Encoding {
if e.Headers == nil {
e.Headers = make(map[string]Header)
}
e.Headers[name] = header
return e
}
// WithStyle sets the style
func (e Encoding) WithStyle(style string) Encoding {
e.Style = style
return e
}
// WithExplode sets the explode option
func (e Encoding) WithExplode(explode bool) Encoding {
e.Explode = explode
return e
}
// WithAllowReserved sets whether reserved characters are allowed
func (e Encoding) WithAllowReserved(allow bool) Encoding {
e.AllowReserved = allow
return e
}