[zeromicro/go-zero]根据api自动生成dart代码出错

2024-03-08 30 views
3
Snipaste_2021-01-16_19-03-48 Snipaste_2021-01-16_19-03-12

如图,使用官方greet demo测试api dart代码自动生成时报错 是我哪里操作不对吗?

回答

1
CleanShot 2021-02-16 at 19 28 16@2x

I also got this error.

2021/02/16 19:31:38 gen.go:31 template: dataTemplate:13:45: executing "dataTemplate" at <.Type>: wrong type for value; expected string; got spec.PrimitiveType

1

+1 报同样的错误

0

goctl api dart --api account.api --dir . 2021/06/10 01:04:41 gen.go:32 template: dataTemplate:13:45: executing "dataTemplate" at <.Type>: wrong type for value; expected string; got spec.PrimitiveType

api定义如下

type RegisterRequest struct {
    Email string `json:"email"`           // 邮箱
    Password string `json:"password"`     // 密码长度大于6
    Repassword string `json:"repassword"` // 重复密码
}

type RegisterResponse struct {
    Uid int64 `json:"uid"`      // uid账号ID
    Token string `json:"token"` // 账号token
}
type LoginRequest struct {
    Email string `json:"email"`       // 邮箱
    Password string `json:"password"` // 密码
}

type LoginResponse struct {
    Uid int64 `json:"uid"`      // uid
    Token string `json:"token"` // 账号token
}

type RegInfoResponse struct {
    Uid int64 `json:"uid"`               // uid
    Email string `json:"email"`          // 邮箱
    Phone string `json:"phone"`          // 手机号
    Status int64 `json:"status"`         // 状态 0默认 1已激活 2已删除
    CreateTime int64 `json:"createTime"` // 创建时间戳(秒级别)
    UpdateTime int64 `json:"updateTime"` // 更新时间戳(秒级别)
}
@server(
    group: account
)
service boom-api {
    @doc "邮箱注册"
    @handler RegisterHandler
    post /api/user/register (RegisterRequest) returns (RegisterResponse);

    @doc "邮箱登录"
    @handler LoginHandler
    post /api/user/login (LoginRequest) returns (LoginResponse);
}

@server(
    jwt: Auth
    middleware: AuthCheck
    group: account
)
service boom-api {
    @doc "注册信息"
    @handler RegInfoHandler
    get /api/user/reginfo () returns (RegInfoResponse)
}
6

+1,同样的错, gen.go:32 template: dataTemplate:13:45: executing "dataTemplate" at <.Type>: wrong type for value; expected string; got spec.PrimitiveType

9

谁熟悉dart的PR一下?:)