-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample.go
45 lines (40 loc) · 799 Bytes
/
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
package godoc2api
import (
"fmt"
"github.com/florenthobein/godoc2api/raml"
)
type Example struct {
URI string
Body string
Response string
HTTPCode uint
Description string
}
func (e *Example) toRAMLQuery() (ex *raml.Example, err error) {
if e.Body == "" {
return
}
ex = &raml.Example{
Description: e.Description,
Value: e.Body,
Strict: false,
}
if e.URI != "" {
ex.Description = fmt.Sprintf("%s\n`%s`", ex.Description, e.URI)
}
return
}
func (e *Example) toRAMLResponse() (ex *raml.Example, err error) {
if e.Response == "" {
return
}
ex = &raml.Example{
Description: e.Description,
Value: e.Response,
Strict: false,
}
if e.URI != "" {
ex.Description = fmt.Sprintf("%s\n`%s`", ex.Description, e.URI)
}
return
}