forked from fabric8-services/fabric8-wit
/
api.go
71 lines (62 loc) · 1.66 KB
/
api.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
package design
import (
d "github.com/goadesign/goa/design"
a "github.com/goadesign/goa/design/apidsl"
)
var _ = a.API("wit", func() {
a.Title("Fabric8-wit: One to rule them all")
a.Description("The next big thing")
a.Version("1.0")
a.Host("openshift.io")
a.Scheme("http")
a.BasePath("/api")
a.Consumes("application/json")
a.Produces("application/json")
a.License(func() {
a.Name("Apache License Version 2.0")
a.URL("http://www.apache.org/licenses/LICENSE-2.0")
})
a.Origin("/[.*openshift.io|localhost]/", func() {
a.Methods("GET", "POST", "PUT", "PATCH", "DELETE")
a.Headers("X-Request-Id", "Content-Type", "Authorization", "If-None-Match", "If-Modified-Since")
a.MaxAge(600)
a.Credentials()
})
a.Trait("GenericLinksTrait", func() {
a.Attribute("self", d.String)
a.Attribute("related", d.String)
a.Attribute("meta", a.HashOf(d.String, d.Any))
})
a.Trait("jsonapi-media-type", func() {
a.ContentType("application/vnd.api+json")
})
a.Trait("conditional", func() {
a.Headers(func() {
a.Header("If-Modified-Since", d.String)
a.Header("If-None-Match", d.String)
})
})
a.JWTSecurity("jwt", func() {
a.Description("JWT Token Auth")
a.TokenURL("/api/login/authorize")
a.Header("Authorization")
})
a.ResponseTemplate(d.OK, func() {
a.Description("Resource created")
a.Status(200)
a.Headers(func() {
a.Header("Last-Modified", d.DateTime)
a.Header("ETag")
a.Header("Cache-Control")
})
})
a.ResponseTemplate(d.Created, func(pattern string) {
a.Description("Resource created")
a.Status(201)
a.Headers(func() {
a.Header("Location", d.String, "href to created resource", func() {
a.Pattern(pattern)
})
})
})
})