We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在写proto方式的项目时,proto里定义的bool, int无法判断前端是传了默认值还是没传。 使用google.protobuf.BoolValue这种包装类型时,生成的pb文件又无法正常解析HTTP请求参数。
google.protobuf.BoolValue
The text was updated successfully, but these errors were encountered:
可以通过validate检查前端是否传参数,如果不传会返回参数错误,示例如下
import "google/protobuf/wrappers.proto"; import "validate/validate.proto"; message CheckRequest{ google.protobuf.BoolValue isLocal = 1 [(validate.rules).message.required = true]; }
请求参数
curl -X 'PUT' \ 'http://localhost:8080/api/v1/check' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{"isLocal": {"value":false}}'
如果想要在swagger上请求,需要人工修改apis.swagger.json文件,改为对应go结构体
"isLocal": { "type": "object", "properties": { "value": { "type": "boolean" } } }
Sorry, something went wrong.
所以这样写的话,更新必须是全量更新对吧,没办法只单独修改某个字段
No branches or pull requests
在写proto方式的项目时,proto里定义的bool, int无法判断前端是传了默认值还是没传。
使用
google.protobuf.BoolValue
这种包装类型时,生成的pb文件又无法正常解析HTTP请求参数。The text was updated successfully, but these errors were encountered: