forked from goadesign/gorma
/
media_types.go
139 lines (126 loc) · 3.46 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
129
130
131
132
133
134
135
136
137
138
139
package design
import (
. "github.com/goadesign/goa/design"
. "github.com/goadesign/goa/design/apidsl"
)
// User is the user resource media type.
var User = MediaType("application/vnd.user+json", func() {
Description("A user belonging to a tenant account")
Reference(UserPayload)
Attributes(func() {
Attribute("id", Integer, "ID of user")
Attribute("href", String, "API href of user")
Attribute("firstname", String, "First name of user")
Attribute("lastname", String, "Last name of user")
Attribute("city", String, "City of residence")
Attribute("state", String, "State of residence")
Attribute("country", String, "Country of residence")
Attribute("bio", String, "Biography of user")
Attribute("role", String, "Role of user")
Attribute("email", String, "Email address of user", func() {
Format("email")
})
})
View("default", func() {
Attribute("id")
Attribute("href")
Attribute("firstname")
Attribute("lastname")
Attribute("email")
Attribute("city")
Attribute("state")
Attribute("country")
Attribute("bio")
Attribute("role")
})
View("link", func() {
Attribute("id")
Attribute("href")
Attribute("email")
})
})
// Authorize is the authorize resource media type.
var Authorize = MediaType("application/vnd.authorize+json", func() {
Description("Token authorization response")
Attributes(func() {
Attribute("access_token", String, "access token", func() {
})
Attribute("expires_in", Integer, "Time to expiration in seconds", func() {
})
Attribute("token_type", String, "type of token", func() {
})
})
View("default", func() {
Attribute("access_token")
Attribute("expires_in")
Attribute("token_type")
})
})
// Login is the Login resource media type.
var Login = MediaType("application/vnd.login+json", func() {
Description("")
Attributes(func() {
Attribute("email", String, "email", func() {
})
Attribute("password", String, "password", func() {
})
Attribute("application", String, "UUID of requesting application", func() {
})
})
View("default", func() {
Attribute("email")
Attribute("password")
Attribute("application")
})
})
// Review is the review resource mediatype
var Review = MediaType("application/vnd.review+json", func() {
Description("A review is submitted by a reviewer")
Reference(ReviewPayload)
Attributes(func() {
Attribute("id", Integer, "ID of user")
Attribute("href", String, "API href of user")
Attribute("comment", String, "Review comments")
Attribute("rating", Integer, "Rating of proposal, from 1-5")
})
View("default", func() {
Attribute("id")
Attribute("href")
Attribute("comment")
Attribute("rating")
})
View("link", func() {
Attribute("id")
Attribute("href")
})
})
// Proposal is the proposal resource mediatype
var Proposal = MediaType("application/vnd.proposal+json", func() {
Description("A response to a CFP")
Reference(ProposalPayload)
Attributes(func() {
Attribute("id", Integer, "ID of user")
Attribute("href", String, "API href of user")
Attribute("title", String, "Response title")
Attribute("abstract", String, "Response abstract")
Attribute("detail", String, "Response detail")
Attribute("reviews", CollectionOf(Review), "Reviews")
})
Links(func() {
Link("reviews")
})
View("default", func() {
Attribute("id")
Attribute("href")
Attribute("title")
Attribute("abstract")
Attribute("detail")
Attribute("reviews")
Attribute("links")
})
View("link", func() {
Attribute("id")
Attribute("href")
Attribute("title")
})
})