GolangKratos
init 函数添加 json.MarshalOptions.UseProtoNames = true
func init() {
json.MarshalOptions.UseProtoNames = true
flag.StringVar(&flagconf, "conf", "../../configs", "config path, eg: -conf config.yaml")
}
Makfile 添加 naming=proto
.PHONY: api
# generate api proto
api:
protoc --proto_path=./api \
--proto_path=./third_party \
--go_out=paths=source_relative:./api \
--go-http_out=paths=source_relative:./api \
--go-grpc_out=paths=source_relative:./api \
--openapi_out=fq_schema_naming=true,naming=proto,default_response=false:. \
$(API_PROTO_FILES)
Openapi 添加 UseJSONNamesForFields(false)
openAPIhandler := openapiv2.NewHandler(
openapiv2.WithGeneratorOptions(
generator.UseJSONNamesForFields(false)))
参考资料