podman
57 строк · 1.6 Кб
1// Copyright 2015 go-swagger maintainers
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package spec
16
17import (
18"encoding/json"
19
20"github.com/go-openapi/swag"
21)
22
23// ContactInfo contact information for the exposed API.
24//
25// For more information: http://goo.gl/8us55a#contactObject
26type ContactInfo struct {
27ContactInfoProps
28VendorExtensible
29}
30
31// ContactInfoProps hold the properties of a ContactInfo object
32type ContactInfoProps struct {
33Name string `json:"name,omitempty"`
34URL string `json:"url,omitempty"`
35Email string `json:"email,omitempty"`
36}
37
38// UnmarshalJSON hydrates ContactInfo from json
39func (c *ContactInfo) UnmarshalJSON(data []byte) error {
40if err := json.Unmarshal(data, &c.ContactInfoProps); err != nil {
41return err
42}
43return json.Unmarshal(data, &c.VendorExtensible)
44}
45
46// MarshalJSON produces ContactInfo as json
47func (c ContactInfo) MarshalJSON() ([]byte, error) {
48b1, err := json.Marshal(c.ContactInfoProps)
49if err != nil {
50return nil, err
51}
52b2, err := json.Marshal(c.VendorExtensible)
53if err != nil {
54return nil, err
55}
56return swag.ConcatJSON(b1, b2), nil
57}
58