-
Notifications
You must be signed in to change notification settings - Fork 6
/
example.go
84 lines (67 loc) · 1.42 KB
/
example.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
// nolint
package example
import (
"fmt"
"github.com/teamwork/kommentaar/example/exampleimport"
)
// POST /foo/{id} foobar
// Create a new foo.
//
// This will create a new foo object for a customer. It's important to remember
// that only Pro customers have access to foos.
//
// Request body (application/json): RequestObj
// Response 200 (application/json): AnObject
// Response 400 (application/json): ErrorObject
// Response 401 (application/json): exampleimport.Foo
// These docs are general Go docs, and not parsed (note the blank line).
// Actually, the above OpenAPI block could be anywhere in the code; and doesn't
// *have* to be right above the handler.
func MyHandler() {
x := RequestObj{}
y := AnObject{}
_ = exampleimport.Foo{}
fmt.Println(x, y)
}
type formParams struct {
ID int64
}
// POST /second/endpoint
//
// Just to see if that works correct.
//
// Response 200: {empty}
// Other others a lot!
func Other() {
}
// RequestObj is now documented.
type RequestObj struct {
// woot woot
Asd string
// HelloasXXXX
zxcvzxcv string
// Hello qwer
qqzxcvzxcv string
// Hello asdf
zxcvxzxcvzxcv string
}
type AnObject struct {
// Just any comment here really (int, required)
ID int
// Document it!
Subject string
// Document it!
XSubject string
}
// ErrorObject ..
type ErrorObject struct {
// Errors..
Errors []MyError
}
// MyError ..
type MyError struct {
Message string
Code int
}
func main() {
}