Closed podhmo closed 2 years ago
e.g.
function such as following
func Do(logger *log.Logger, data DoInput, debug *bool, targetID string) (interface{}, error) {
}
transform to
type Input struct {
Data DoInput `json:"data"`
Debug *bool `json:"debug"`
TargetID string `json:"targetID"`
}
💠with embedded
option, maybe using data as embedded field
https://docs.aws.amazon.com/lambda/latest/dg/golang-handler.html
lambda handler is also not having path and query-string, so another handling way for the argument that treated as primitive and primitive-pointer is needed. this is same in the situation using cli.
func -> reflectshape.Shape is better, I think.
(plus point: reflect-openapi is also using reflect.Shape #122 )
like go-stripe do
https://github.com/stripe/stripe-go/blob/6be0c4f6f5da607d7e6482d5925ee16c471aa6a6/event.go#L35-L43 https://github.com/stripe/stripe-go/blob/6be0c4f6f5da607d7e6482d5925ee16c471aa6a6/event.go#L81-L91
hmm https://github.com/podhmo/apikit/issues/147#issuecomment-953762656
if func -> struct transformation automatically, cannot handle validation?
or something like below
g.Generate(pkg, action.Do, WithTag("targetId", `validate: regexp="^[a-f0-9]{24}"`))
or
type ObjectID string func (id *ObjectId) TagString() string { return `<tag>` }
or
for these issues
147
142