forked from chanced/openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
components.go
57 lines (51 loc) · 1.97 KB
/
components.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package openapi
import "github.com/chanced/openapi/yamlutil"
// Components holds a set of reusable objects for different aspects of the OAS.
// All objects defined within the components object will have no effect on the
// API unless they are explicitly referenced from properties outside the
// components object.
type Components struct {
// An object to hold reusable Schema Objects.
Schemas *Schemas `json:"schemas,omitempty"`
// An object to hold reusable Response Objects.
Responses *Responses `json:"responses,omitempty"`
// An object to hold reusable Parameter Objects.
Parameters *Parameters `json:"parameters,omitempty"`
// An object to hold reusable Example Objects.
Examples *Examples `json:"examples,omitempty"`
// An object to hold reusable Request Body Objects.
RequestBodies *RequestBodies `json:"requestBodies,omitempty"`
// An object to hold reusable Header Objects.
Headers *Headers `json:"headers,omitempty"`
// An object to hold reusable Security Scheme Objects.
SecuritySchemes *SecuritySchemes `json:"securitySchemes,omitempty"`
// An object to hold reusable Link Objects.
Links *Links `json:"links,omitempty"`
// An object to hold reusable Callback Objects.
Callbacks *Callbacks `json:"callbacks,omitempty"`
// An object to hold reusable Path Item Object.
PathItems *PathItems `json:"pathItems,omitempty"`
Extensions `json:"-"`
}
type components Components
// MarshalJSON marshals JSON
func (c Components) MarshalJSON() ([]byte, error) {
return marshalExtendedJSON(components(c))
}
// UnmarshalJSON unmarshals JSON
func (c *Components) UnmarshalJSON(data []byte) error {
var v components
if err := unmarshalExtendedJSON(data, &v); err != nil {
return err
}
*c = Components(v)
return nil
}
// MarshalYAML marshals YAML
func (c Components) MarshalYAML() (interface{}, error) {
return yamlutil.Marshal(c)
}
// UnmarshalYAML unmarshals YAML
func (c *Components) UnmarshalYAML(unmarshal func(interface{}) error) error {
return yamlutil.Unmarshal(unmarshal, c)
}