forked from chanced/openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.go
40 lines (34 loc) · 1.08 KB
/
contact.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
package openapi
import "github.com/chanced/openapi/yamlutil"
// Contact information for the exposed API.
type Contact struct {
// The identifying name of the contact person/organization.
Name string `json:"name,omitempty"`
// The URL pointing to the contact information. This MUST be in the form of
// a URL.
URL string `json:"url,omitempty"`
// The email address of the contact person/organization. This MUST be in the
// form of an email address.
Emails string `json:"email,omitempty"`
Extensions `json:"-"`
}
type contact Contact
// MarshalJSON marshals JSON
func (c Contact) MarshalJSON() ([]byte, error) {
return marshalExtendedJSON(contact(c))
}
// UnmarshalJSON unmarshals JSON
func (c *Contact) UnmarshalJSON(data []byte) error {
var v contact
err := unmarshalExtendedJSON(data, &v)
*c = Contact(v)
return err
}
// MarshalYAML marshals YAML
func (c Contact) MarshalYAML() (interface{}, error) {
return yamlutil.Marshal(c)
}
// UnmarshalYAML unmarshals YAML
func (c *Contact) UnmarshalYAML(unmarshal func(interface{}) error) error {
return yamlutil.Unmarshal(unmarshal, c)
}