-
Notifications
You must be signed in to change notification settings - Fork 0
/
media_types.go
128 lines (116 loc) · 2.85 KB
/
media_types.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package design
import (
. "github.com/Gys/goa/design"
. "github.com/Gys/goa/design/apidsl"
)
// Account is the account resource media type.
var Account = MediaType("application/vnd.account+json", func() {
Description("A tenant account")
Attributes(func() {
Attribute("id", Integer, "ID of account", func() {
Example(1)
})
Attribute("href", String, "API href of account", func() {
Example("/accounts/1")
})
Attribute("name", String, "Name of account", func() {
Example("test")
})
Attribute("created_at", DateTime, "Date of creation")
Attribute("created_by", String, "Email of account owner", func() {
Format("email")
Example("me@goa.design")
})
Required("id", "href", "name", "created_at", "created_by")
})
View("default", func() {
Attribute("id")
Attribute("href")
Attribute("name")
Attribute("created_at")
Attribute("created_by")
})
View("tiny", func() {
Description("tiny is the view used to list accounts")
Attribute("id")
Attribute("href")
Attribute("name")
})
View("link", func() {
Attribute("id")
Attribute("href")
})
})
// Bottle is the bottle resource media type.
var Bottle = MediaType("application/vnd.bottle+json", func() {
Description("A bottle of wine")
Reference(BottlePayload)
Attributes(func() {
Attribute("id", Integer, "ID of bottle", func() {
Example(1)
})
Attribute("href", String, "API href of bottle", func() {
Example("/accounts/1/bottles/1")
})
Attribute("rating", Integer, "Rating of bottle between 1 and 5", func() {
Minimum(1)
Maximum(5)
})
Attribute("account", Account, "Account that owns bottle")
Attribute("created_at", DateTime, "Date of creation")
Attribute("updated_at", DateTime, "Date of last update")
// Attributes below inherit from the base type
Attribute("name")
Attribute("vineyard")
Attribute("varietal")
Attribute("vintage")
Attribute("color")
Attribute("sweetness")
Attribute("country")
Attribute("region")
Attribute("review")
Required("id", "href", "name", "vineyard", "varietal", "vintage", "color")
Required("created_at")
})
Links(func() {
Link("account")
})
View("default", func() {
Attribute("id")
Attribute("href")
Attribute("name")
Attribute("rating")
Attribute("vineyard")
Attribute("varietal")
Attribute("vintage")
Attribute("account", func() {
View("tiny")
})
Attribute("links")
})
View("tiny", func() {
Attribute("id")
Attribute("href")
Attribute("name")
Attribute("rating")
Attribute("links")
})
View("full", func() {
Attribute("id")
Attribute("href")
Attribute("name")
Attribute("account")
Attribute("rating")
Attribute("vineyard")
Attribute("varietal")
Attribute("vintage")
Attribute("color")
Attribute("sweetness")
Attribute("country")
Attribute("region")
Attribute("review")
Attribute("created_at")
Attribute("updated_at")
Attribute("links")
})
})