Handle lack of parameters
This commit is contained in:
parent
833745395f
commit
0d50afac8e
@ -26,10 +26,12 @@ func (r *RoutesGenerator) Generate(routes []extractor.Route) error {
|
|||||||
f.Comment(r.Summary)
|
f.Comment(r.Summary)
|
||||||
f.Func().Params(
|
f.Func().Params(
|
||||||
jen.Id("c").Id("*Client"),
|
jen.Id("c").Id("*Client"),
|
||||||
).Id(transformName(r.Name)).Params(
|
).Id(transformName(r.Name)).ParamsFunc(func(g *jen.Group) {
|
||||||
jen.Id("ctx").Qual("context", "Context"),
|
g.Id("ctx").Qual("context", "Context")
|
||||||
jen.Id("data").Qual("go.elara.ws/go-lemmy/types", r.ParamsName),
|
if r.ParamsName != "" {
|
||||||
).ParamsFunc(func(g *jen.Group) {
|
g.Id("data").Qual("go.elara.ws/go-lemmy/types", r.ParamsName)
|
||||||
|
}
|
||||||
|
}).ParamsFunc(func(g *jen.Group) {
|
||||||
if r.ReturnName != "" {
|
if r.ReturnName != "" {
|
||||||
g.Op("*").Qual("go.elara.ws/go-lemmy/types", r.ReturnName)
|
g.Op("*").Qual("go.elara.ws/go-lemmy/types", r.ReturnName)
|
||||||
}
|
}
|
||||||
@ -40,6 +42,10 @@ func (r *RoutesGenerator) Generate(routes []extractor.Route) error {
|
|||||||
returnName = "EmptyResponse"
|
returnName = "EmptyResponse"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if r.ParamsName == "" {
|
||||||
|
g.Id("data").Op(":=").Qual("go.elara.ws/go-lemmy/types", "EmptyData").Block()
|
||||||
|
}
|
||||||
|
|
||||||
g.Id("resData").Op(":=").Op("&").Qual("go.elara.ws/go-lemmy/types", returnName).Block()
|
g.Id("resData").Op(":=").Op("&").Qual("go.elara.ws/go-lemmy/types", returnName).Block()
|
||||||
|
|
||||||
var funcName string
|
var funcName string
|
||||||
|
@ -11,6 +11,10 @@ type EmptyResponse struct {
|
|||||||
LemmyResponse
|
LemmyResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type EmptyData struct {
|
||||||
|
Auth string `json:"auth" url:"auth,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type LemmyResponse struct {
|
type LemmyResponse struct {
|
||||||
Error Optional[string] `json:"error" url:"error,omitempty"`
|
Error Optional[string] `json:"error" url:"error,omitempty"`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user