-
Notifications
You must be signed in to change notification settings - Fork 2
/
request_body_builder_gen.go
67 lines (57 loc) · 1.76 KB
/
request_body_builder_gen.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
package openapi
// This file was automatically generated.
// DO NOT EDIT MANUALLY. All changes will be lost
import "github.com/pkg/errors"
var _ = errors.Cause
// RequestBodyBuilder is used to build an instance of RequestBody. The user must
// call `Build()` after providing all the necessary information to
// build an instance of RequestBody
type RequestBodyBuilder struct {
target *requestBody
}
// MustBuild is a convenience function for those time when you know that
// the result of the builder must be successful
func (b *RequestBodyBuilder) MustBuild(options ...Option) RequestBody {
v, err := b.Build()
if err != nil {
panic(err)
}
return v
}
// Build finalizes the building process for RequestBody and returns the result
func (b *RequestBodyBuilder) Build(options ...Option) (RequestBody, error) {
validate := true
for _, option := range options {
switch option.Name() {
case optkeyValidate:
validate = option.Value().(bool)
}
}
if validate {
if err := b.target.Validate(false); err != nil {
return nil, errors.Wrap(err, `validation failed`)
}
}
return b.target, nil
}
// NewRequestBody creates a new builder object for RequestBody
func NewRequestBody() *RequestBodyBuilder {
return &RequestBodyBuilder{
target: &requestBody{},
}
}
// Description sets the Description field for object RequestBody.
func (b *RequestBodyBuilder) Description(v string) *RequestBodyBuilder {
b.target.description = v
return b
}
// Required sets the Required field for object RequestBody.
func (b *RequestBodyBuilder) Required(v bool) *RequestBodyBuilder {
b.target.required = v
return b
}
// Reference sets the $ref (reference) field for object RequestBody.
func (b *RequestBodyBuilder) Reference(v string) *RequestBodyBuilder {
b.target.reference = v
return b
}