forked from chanced/openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
external_docs.go
39 lines (33 loc) · 1.12 KB
/
external_docs.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
package openapi
import "github.com/chanced/openapi/yamlutil"
// ExternalDocs allows referencing an external resource for extended
// documentation.
type ExternalDocs struct {
// The URL for the target documentation. This MUST be in the form of a URL.
//
// *required*
URL string `json:"url"`
// A description of the target documentation. CommonMark syntax MAY be used for rich text representation.
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Extensions `json:"-"`
}
type externaldocs ExternalDocs
// MarshalJSON marshals JSON
func (ed ExternalDocs) MarshalJSON() ([]byte, error) {
return marshalExtendedJSON(externaldocs(ed))
}
// UnmarshalJSON unmarshals JSON
func (ed *ExternalDocs) UnmarshalJSON(data []byte) error {
var v externaldocs
err := unmarshalExtendedJSON(data, &v)
*ed = ExternalDocs(v)
return err
}
// MarshalYAML marshals YAML
func (ed ExternalDocs) MarshalYAML() (interface{}, error) {
return yamlutil.Marshal(ed)
}
// UnmarshalYAML unmarshals YAML
func (ed *ExternalDocs) UnmarshalYAML(unmarshal func(interface{}) error) error {
return yamlutil.Unmarshal(unmarshal, ed)
}