-
Notifications
You must be signed in to change notification settings - Fork 0
/
pathItem.go
60 lines (50 loc) · 2.02 KB
/
pathItem.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
58
59
60
package oasm
import "encoding/json"
// Describes the operations available on a single path. A Path Item MAY be empty, due to ACL constraints.
// The path itself is still exposed to the documentation viewer but they will not know which operations and
// parameters are available.
type PathItem struct {
// Allows for an external definition of this path item. The referenced structure MUST be in the format of a Path
// Item Object. If there are conflicts between the referenced definition and this Path Item's definition,
// the behavior is undefined.
Ref string
// An optional, string summary, intended to apply to all operations in this path.
Summary string
// An optional, string description, intended to apply to all operations in this path.
// CommonMark syntax MAY be used for rich text representation.
Description string
// A map of HTTP methods to their operation definitions.
Methods map[string]Operation
// An alternative server array to service all operations in this path.
Servers []Server
// A list of parameters that are applicable for all the operations described under this path. These parameters can
// be overridden at the operation level, but cannot be removed there. The list MUST NOT include duplicated
// parameters. A unique parameter is defined by a combination of a name and location. The list can use the
// Reference Object to link to parameters that are defined at the OpenAPI Object's components/parameters.
Parameters []Parameter
}
func (p PathItem) MarshalJSON() (_ []byte, err error) {
x := make(JSON)
for key, value := range p.Methods {
if x[key], err = json.Marshal(value); err != nil {
return
}
}
if p.Servers != nil {
x["servers"], err = json.Marshal(p.Servers)
if err != nil {
return
}
}
if p.Parameters != nil {
x["parameters"], err = json.Marshal(p.Parameters)
if err != nil {
return
}
}
marshalStrIfLen(p.Ref, "$ref", x)
marshalStrIfLen(p.Summary, "summary", x)
marshalStrIfLen(p.Description, "description", x)
return json.Marshal(x)
}
// TODO: UnmarshalJSON()