From f767e623c9734eb77778514087df9f96390a4b48 Mon Sep 17 00:00:00 2001 From: guoliangcao Date: Wed, 11 Aug 2021 16:00:31 +0800 Subject: [PATCH] add options examples --- examples/helloworld/server/main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/helloworld/server/main.go b/examples/helloworld/server/main.go index c38ac3b..9b937cb 100644 --- a/examples/helloworld/server/main.go +++ b/examples/helloworld/server/main.go @@ -5,6 +5,7 @@ import ( "fmt" "os" + "github.com/go-kratos/grpc-gateway/v2/protoc-gen-openapiv2/generator" "github.com/go-kratos/kratos/v2" "github.com/go-kratos/kratos/v2/errors" "github.com/go-kratos/kratos/v2/log" @@ -48,7 +49,11 @@ func main() { httpSrv := http.NewServer(http.Address(":8000")) pb.RegisterGreeterHTTPServer(httpSrv, s) - h := openapiv2.NewHandler() + h := openapiv2.NewHandler(openapiv2.WithGeneratorOptions( + // you can set UseJSONNamesForFields to false + // default is true + generator.UseJSONNamesForFields(true), + )) httpSrv.HandlePrefix("/q/", h) /* fs := httpx.FileServer(httpx.Dir("./dist"))