...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package spec
16
17 import (
18 "encoding/json"
19
20 "github.com/go-openapi/swag"
21 )
22
23
24
25
26 type ContactInfo struct {
27 ContactInfoProps
28 VendorExtensible
29 }
30
31
32 type ContactInfoProps struct {
33 Name string `json:"name,omitempty"`
34 URL string `json:"url,omitempty"`
35 Email string `json:"email,omitempty"`
36 }
37
38
39 func (c *ContactInfo) UnmarshalJSON(data []byte) error {
40 if err := json.Unmarshal(data, &c.ContactInfoProps); err != nil {
41 return err
42 }
43 return json.Unmarshal(data, &c.VendorExtensible)
44 }
45
46
47 func (c ContactInfo) MarshalJSON() ([]byte, error) {
48 b1, err := json.Marshal(c.ContactInfoProps)
49 if err != nil {
50 return nil, err
51 }
52 b2, err := json.Marshal(c.VendorExtensible)
53 if err != nil {
54 return nil, err
55 }
56 return swag.ConcatJSON(b1, b2), nil
57 }
58
View as plain text