podman
56 строк · 1.5 Кб
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// License information for the exposed API.
24//
25// For more information: http://goo.gl/8us55a#licenseObject
26type License struct {
27LicenseProps
28VendorExtensible
29}
30
31// LicenseProps holds the properties of a License object
32type LicenseProps struct {
33Name string `json:"name,omitempty"`
34URL string `json:"url,omitempty"`
35}
36
37// UnmarshalJSON hydrates License from json
38func (l *License) UnmarshalJSON(data []byte) error {
39if err := json.Unmarshal(data, &l.LicenseProps); err != nil {
40return err
41}
42return json.Unmarshal(data, &l.VendorExtensible)
43}
44
45// MarshalJSON produces License as json
46func (l License) MarshalJSON() ([]byte, error) {
47b1, err := json.Marshal(l.LicenseProps)
48if err != nil {
49return nil, err
50}
51b2, err := json.Marshal(l.VendorExtensible)
52if err != nil {
53return nil, err
54}
55return swag.ConcatJSON(b1, b2), nil
56}
57