-
Notifications
You must be signed in to change notification settings - Fork 1
/
request_body.cf.go
95 lines (83 loc) · 2.6 KB
/
request_body.cf.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
85
86
87
88
89
90
91
92
93
94
95
// Code generated by Conflow. DO NOT EDIT.
package openapi
import (
"fmt"
"github.com/conflowio/conflow/src/conflow"
"github.com/conflowio/conflow/src/conflow/annotations"
"github.com/conflowio/conflow/src/schema"
)
func init() {
schema.Register(&schema.Object{
Metadata: schema.Metadata{
Annotations: map[string]string{
annotations.Type: "configuration",
},
ID: "github.com/conflowio/conflow/src/openapi.RequestBody",
},
FieldNames: map[string]string{"content": "Content", "description": "Description", "required": "Required"},
Properties: map[string]schema.Schema{
"content": &schema.Map{
AdditionalProperties: &schema.Reference{
Nullable: true,
Ref: "github.com/conflowio/conflow/src/openapi.MediaType",
},
},
"description": &schema.String{},
"required": &schema.Boolean{},
},
Required: []string{"content"},
})
}
// RequestBodyInterpreter is the Conflow interpreter for the RequestBody block
type RequestBodyInterpreter struct {
}
func (i RequestBodyInterpreter) Schema() schema.Schema {
s, _ := schema.Get("github.com/conflowio/conflow/src/openapi.RequestBody")
return s
}
// Create creates a new RequestBody block
func (i RequestBodyInterpreter) CreateBlock(id conflow.ID, blockCtx *conflow.BlockContext) conflow.Block {
b := &RequestBody{}
b.Content = map[string]*MediaType{}
return b
}
// ValueParamName returns the name of the parameter marked as value field, if there is one set
func (i RequestBodyInterpreter) ValueParamName() conflow.ID {
return ""
}
// ParseContext returns with the parse context for the block
func (i RequestBodyInterpreter) ParseContext(ctx *conflow.ParseContext) *conflow.ParseContext {
var nilBlock *RequestBody
if b, ok := conflow.Block(nilBlock).(conflow.ParseContextOverrider); ok {
return ctx.New(b.ParseContextOverride())
}
return ctx
}
func (i RequestBodyInterpreter) Param(b conflow.Block, name conflow.ID) interface{} {
switch name {
case "description":
return b.(*RequestBody).Description
case "required":
return b.(*RequestBody).Required
default:
panic(fmt.Errorf("unexpected parameter %q in RequestBody", name))
}
}
func (i RequestBodyInterpreter) SetParam(block conflow.Block, name conflow.ID, value interface{}) error {
b := block.(*RequestBody)
switch name {
case "description":
b.Description = value.(string)
case "required":
b.Required = value.(bool)
}
return nil
}
func (i RequestBodyInterpreter) SetBlock(block conflow.Block, name conflow.ID, key string, value interface{}) error {
b := block.(*RequestBody)
switch name {
case "content":
b.Content[key] = value.(*MediaType)
}
return nil
}