@@ -16,32 +16,31 @@ import (
16
16
//
17
17
// Example:
18
18
//
19
- // var _ = API("adder", func() {
20
- // Title("title") // Title used in documentation
21
- // Description("description") // Description used in documentation
22
- // Version("2.0") // Version of API
23
- // TermsOfService("terms") // Terms of use
24
- // Contact(func() { // Contact info
25
- // Name("contact name")
26
- // Email("contact email")
27
- // URL("contact URL")
28
- // })
29
- // License(func() { // License
30
- // Name("license name")
31
- // URL("license URL")
32
- // })
33
- // Docs(func() { // Documentation links
34
- // Description("doc description")
35
- // URL("doc URL")
36
- // })
37
- // Server("addersvr", func() {
38
- // Host("development", func() {
39
- // URI("http://localhost:80")
40
- // URI("grpc://localhost:8080")
41
- // })
42
- // })
43
- // }
44
- //
19
+ // var _ = API("adder", func() {
20
+ // Title("title") // Title used in documentation
21
+ // Description("description") // Description used in documentation
22
+ // Version("2.0") // Version of API
23
+ // TermsOfService("terms") // Terms of use
24
+ // Contact(func() { // Contact info
25
+ // Name("contact name")
26
+ // Email("contact email")
27
+ // URL("contact URL")
28
+ // })
29
+ // License(func() { // License
30
+ // Name("license name")
31
+ // URL("license URL")
32
+ // })
33
+ // Docs(func() { // Documentation links
34
+ // Description("doc description")
35
+ // URL("doc URL")
36
+ // })
37
+ // Server("addersvr", func() {
38
+ // Host("development", func() {
39
+ // URI("http://localhost:80")
40
+ // URI("grpc://localhost:8080")
41
+ // })
42
+ // })
43
+ // }
45
44
func API (name string , fn func ()) * expr.APIExpr {
46
45
if name == "" {
47
46
eval .ReportError ("API first argument cannot be empty" )
@@ -63,10 +62,9 @@ func API(name string, fn func()) *expr.APIExpr {
63
62
//
64
63
// Example:
65
64
//
66
- // var _ = API("divider", func() {
67
- // Title("divider API")
68
- // })
69
- //
65
+ // var _ = API("divider", func() {
66
+ // Title("divider API")
67
+ // })
70
68
func Title (val string ) {
71
69
if s , ok := eval .Current ().(* expr.APIExpr ); ok {
72
70
s .Title = val
@@ -83,10 +81,9 @@ func Title(val string) {
83
81
//
84
82
// Example:
85
83
//
86
- // var _ = API("divider", func() {
87
- // Version("1.0")
88
- // })
89
- //
84
+ // var _ = API("divider", func() {
85
+ // Version("1.0")
86
+ // })
90
87
func Version (ver string ) {
91
88
if s , ok := eval .Current ().(* expr.APIExpr ); ok {
92
89
s .Version = ver
@@ -103,14 +100,13 @@ func Version(ver string) {
103
100
//
104
101
// Example:
105
102
//
106
- // var _ = API("divider", func() {
107
- // Contact(func() {
108
- // Name("support")
109
-
110
- // URL("https://goa.design")
111
- // })
112
- // })
113
- //
103
+ // var _ = API("divider", func() {
104
+ // Contact(func() {
105
+ // Name("support")
106
+
107
+ // URL("https://goa.design")
108
+ // })
109
+ // })
114
110
func Contact (fn func ()) {
115
111
contact := new (expr.ContactExpr )
116
112
if ! eval .Execute (fn , contact ) {
@@ -131,13 +127,12 @@ func Contact(fn func()) {
131
127
//
132
128
// Example:
133
129
//
134
- // var _ = API("divider", func() {
135
- // License(func() {
136
- // Name("MIT")
137
- // URL("https://github.com/goadesign/goa/blob/master/LICENSE")
138
- // })
139
- // })
140
- //
130
+ // var _ = API("divider", func() {
131
+ // License(func() {
132
+ // Name("MIT")
133
+ // URL("https://github.com/goadesign/goa/blob/master/LICENSE")
134
+ // })
135
+ // })
141
136
func License (fn func ()) {
142
137
license := new (expr.LicenseExpr )
143
138
if ! eval .Execute (fn , license ) {
@@ -162,18 +157,18 @@ func License(fn func()) {
162
157
//
163
158
// Example:
164
159
//
165
- // var _ = API("divider", func() {
166
- // Randomizer(expr.NewFakerRandomizer("different seed"))
167
- // })
160
+ // var _ = API("divider", func() {
161
+ // Randomizer(expr.NewFakerRandomizer("different seed"))
162
+ // })
168
163
//
169
164
// There's also a deterministic randomizer which will only generate one example
170
165
// for each type, so all strings are "abc123", all ints are 1, etc.
171
166
//
172
167
// Example:
173
168
//
174
- // var _ = API("divider", func() {
175
- // Randomizer(expr.NewDeterministicRandomizer())
176
- // })
169
+ // var _ = API("divider", func() {
170
+ // Randomizer(expr.NewDeterministicRandomizer())
171
+ // })
177
172
func Randomizer (randomizer expr.Randomizer ) {
178
173
if s , ok := eval .Current ().(* expr.APIExpr ); ok {
179
174
s .ExampleGenerator = & expr.ExampleGenerator {Randomizer : randomizer }
@@ -191,13 +186,12 @@ func Randomizer(randomizer expr.Randomizer) {
191
186
//
192
187
// Example:
193
188
//
194
- // var _ = API("cellar", func() {
195
- // Docs(func() {
196
- // Description("Additional documentation")
197
- // URL("https://goa.design")
198
- // })
199
- // })
200
- //
189
+ // var _ = API("cellar", func() {
190
+ // Docs(func() {
191
+ // Description("Additional documentation")
192
+ // URL("https://goa.design")
193
+ // })
194
+ // })
201
195
func Docs (fn func ()) {
202
196
docs := new (expr.DocsExpr )
203
197
if ! eval .Execute (fn , docs ) {
@@ -227,10 +221,9 @@ func Docs(fn func()) {
227
221
//
228
222
// Example:
229
223
//
230
- // var _ = API("github", func() {
231
- // TermsOfService("https://help.github.com/articles/github-terms-of-API/"
232
- // })
233
- //
224
+ // var _ = API("github", func() {
225
+ // TermsOfService("https://help.github.com/articles/github-terms-of-API/"
226
+ // })
234
227
func TermsOfService (terms string ) {
235
228
if s , ok := eval .Current ().(* expr.APIExpr ); ok {
236
229
s .TermsOfService = terms
@@ -247,13 +240,12 @@ func TermsOfService(terms string) {
247
240
//
248
241
// Example:
249
242
//
250
- // var _ = API("divider", func() {
251
- // License(func() {
252
- // Name("MIT")
253
- // URL("https://github.com/goadesign/goa/blob/master/LICENSE")
254
- // })
255
- // })
256
- //
243
+ // var _ = API("divider", func() {
244
+ // License(func() {
245
+ // Name("MIT")
246
+ // URL("https://github.com/goadesign/goa/blob/master/LICENSE")
247
+ // })
248
+ // })
257
249
func Name (name string ) {
258
250
switch def := eval .Current ().(type ) {
259
251
case * expr.ContactExpr :
@@ -273,12 +265,11 @@ func Name(name string) {
273
265
//
274
266
// Example:
275
267
//
276
- // var _ = API("divider", func() {
277
- // Contact(func() {
278
-
279
- // })
280
- // })
281
- //
268
+ // var _ = API("divider", func() {
269
+ // Contact(func() {
270
+
271
+ // })
272
+ // })
282
273
func Email (email string ) {
283
274
if c , ok := eval .Current ().(* expr.ContactExpr ); ok {
284
275
c .Email = email
@@ -293,10 +284,9 @@ func Email(email string) {
293
284
//
294
285
// Example:
295
286
//
296
- // Docs(func() {
297
- // URL("https://goa.design")
298
- // })
299
- //
287
+ // Docs(func() {
288
+ // URL("https://goa.design")
289
+ // })
300
290
func URL (url string ) {
301
291
switch def := eval .Current ().(type ) {
302
292
case * expr.ContactExpr :
0 commit comments