2024-05-14 13:07:09 +00:00
|
|
|
// Copyright 2015 go-swagger maintainers
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
//
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
// you may not use this file except in compliance with the License.
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
// You may obtain a copy of the License at
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
//
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
//
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
// See the License for the specific language governing permissions and
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package spec
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
"github.com/go-openapi/swag"
|
|
|
|
)
|
|
|
|
|
|
|
|
// License information for the exposed API.
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
//
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
// For more information: http://goo.gl/8us55a#licenseObject
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
type License struct {
|
|
|
|
LicenseProps
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
VendorExtensible
|
|
|
|
}
|
|
|
|
|
|
|
|
// LicenseProps holds the properties of a License object
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
type LicenseProps struct {
|
|
|
|
Name string `json:"name,omitempty"`
|
2024-07-24 23:45:04 +00:00
|
|
|
|
|
|
|
URL string `json:"url,omitempty"`
|
2024-05-14 13:07:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// UnmarshalJSON hydrates License from json
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
func (l *License) UnmarshalJSON(data []byte) error {
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
if err := json.Unmarshal(data, &l.LicenseProps); err != nil {
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
return err
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
}
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
return json.Unmarshal(data, &l.VendorExtensible)
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// MarshalJSON produces License as json
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
func (l License) MarshalJSON() ([]byte, error) {
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
b1, err := json.Marshal(l.LicenseProps)
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
if err != nil {
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
return nil, err
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
}
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
b2, err := json.Marshal(l.VendorExtensible)
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
if err != nil {
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
return nil, err
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
}
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
return swag.ConcatJSON(b1, b2), nil
|
2024-07-24 23:45:04 +00:00
|
|
|
|
2024-05-14 13:07:09 +00:00
|
|
|
}
|