Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Commit

Permalink
add options examples
Browse files Browse the repository at this point in the history
  • Loading branch information
guoliangcao committed Aug 11, 2021
1 parent 88e9db2 commit f767e62
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion examples/helloworld/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"))
Expand Down

0 comments on commit f767e62

Please sign in to comment.