-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
param.go
62 lines (53 loc) · 1.46 KB
/
param.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
package fuego
func ParamRequired() func(param *OpenAPIParam) {
return func(param *OpenAPIParam) {
param.Required = true
}
}
func ParamNullable() func(param *OpenAPIParam) {
return func(param *OpenAPIParam) {
param.Nullable = true
}
}
func ParamString() func(param *OpenAPIParam) {
return func(param *OpenAPIParam) {
param.GoType = "string"
}
}
func ParamInteger() func(param *OpenAPIParam) {
return func(param *OpenAPIParam) {
param.GoType = "integer"
}
}
func ParamBool() func(param *OpenAPIParam) {
return func(param *OpenAPIParam) {
param.GoType = "boolean"
}
}
func ParamDescription(description string) func(param *OpenAPIParam) {
return func(param *OpenAPIParam) {
param.Description = description
}
}
func ParamDefault(value any) func(param *OpenAPIParam) {
return func(param *OpenAPIParam) {
param.Default = value
}
}
// Example adds an example to the parameter. As per the OpenAPI 3.0 standard, the example must be given a name.
func ParamExample(exampleName string, value any) func(param *OpenAPIParam) {
return func(param *OpenAPIParam) {
if param.Examples == nil {
param.Examples = make(map[string]any)
}
param.Examples[exampleName] = value
}
}
// StatusCodes sets the status codes for which this parameter is required.
// Only used for response parameters.
// If empty, it is required for 200 status codes.
func ParamStatusCodes(codes ...int) func(param *OpenAPIParam) {
return func(param *OpenAPIParam) {
param.StatusCodes = codes
}
}