forked from goadesign/goa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
design.go
70 lines (61 loc) · 1.49 KB
/
design.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
package design
import (
. "github.com/goadesign/goa/design"
. "github.com/goadesign/goa/design/apidsl"
)
var _ = API("media", func() {
Title("An API exercising the DefaultMedia definition")
Host("localhost:8080")
Scheme("http")
})
var Greeting = Type("Greeting", func() {
Attribute("id", Integer, func() {
Description("A required int field in the parent type.")
})
Attribute("message", String, func() {
Description("A required string field in the parent type.")
})
Attribute("parent_optional", Boolean, func() {
Description("An optional boolean field in the parent type.")
})
Required("id", "message")
})
var GreetingMedia = MediaType("application/vnd.io.bluecanvas.helloworld.greeting.v1+json", func() {
TypeName("GreetingMedia")
Reference(Greeting)
Attributes(func() {
Attribute("id")
Attribute("message")
Attribute("parent_optional")
Attribute("href", String, func() {
Description("A required string field in the response media type.")
})
Required("id", "message", "href")
})
View("default", func() {
Attribute("id")
Attribute("message")
Attribute("parent_optional")
Attribute("href")
})
})
var _ = Resource("Greeting", func() {
DefaultMedia(GreetingMedia)
Action("show", func() {
Routing(
GET("/"))
Response(OK, GreetingMedia)
Response(BadRequest)
})
Action("create", func() {
Routing(
POST("/"))
Payload(func() {
Member("message")
Member("parent_optional")
Required("message")
})
Response(Created)
Response(BadRequest)
})
})