Skip to content

Commit b24c73d

Browse files
feat: path (method & service) generation
1 parent cc5feff commit b24c73d

File tree

5 files changed

+546
-70
lines changed

5 files changed

+546
-70
lines changed

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require (
77
github.com/getkin/kin-openapi v0.132.0
88
github.com/google/go-cmp v0.7.0
99
github.com/rogpeppe/fastuuid v1.2.0
10+
github.com/stretchr/testify v1.9.0
1011
golang.org/x/oauth2 v0.30.0
1112
golang.org/x/text v0.25.0
1213
google.golang.org/genproto/googleapis/api v0.0.0-20250512202823-5a2f75b736a9
@@ -17,6 +18,7 @@ require (
1718
)
1819

1920
require (
21+
github.com/davecgh/go-spew v1.1.1 // indirect
2022
github.com/go-openapi/jsonpointer v0.21.0 // indirect
2123
github.com/go-openapi/swag v0.23.0 // indirect
2224
github.com/josharian/intern v1.0.0 // indirect
@@ -25,6 +27,7 @@ require (
2527
github.com/oasdiff/yaml v0.0.0-20250309154309-f31be36b4037 // indirect
2628
github.com/oasdiff/yaml3 v0.0.0-20250309153720-d2182401db90 // indirect
2729
github.com/perimeterx/marshmallow v1.1.5 // indirect
30+
github.com/pmezard/go-difflib v1.0.0 // indirect
2831
golang.org/x/net v0.37.0 // indirect
2932
golang.org/x/sys v0.31.0 // indirect
3033
)

internal/descriptor/registry.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ type Registry struct {
181181

182182
// generateXGoType is a global generator option for generating x-go-type annotations
183183
generateXGoType bool
184+
185+
// indicates how the one ofs are handled
186+
oneOfStrategy string
184187
}
185188

186189
type repeatedFieldSeparator struct {
@@ -930,3 +933,11 @@ func (r *Registry) SetGenerateXGoType(generateXGoType bool) {
930933
func (r *Registry) GetGenerateXGoType() bool {
931934
return r.generateXGoType
932935
}
936+
937+
func (r *Registry) SetOneOfStrategy(oneOfStrategy string) {
938+
r.oneOfStrategy = oneOfStrategy
939+
}
940+
941+
func (r *Registry) GetOneOfStrategy() string {
942+
return r.oneOfStrategy
943+
}

protoc-gen-openapiv3/internal/genopenapiv3/file_options.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import (
99

1010
func (g *generator) extractFileOptions(target *descriptor.File) (*openapi3.T, bool) {
1111
if openAPIAno := proto.GetExtension(target.GetOptions(), options.E_Openapiv3Document).(*options.OpenAPI); openAPIAno != nil {
12-
doc := &openapi3.T{}
12+
doc := &openapi3.T{
13+
OpenAPI: "3.0.2",
14+
}
1315
doc.Info = g.extractInfo(openAPIAno.GetInfo())
1416
// TODO: implement other openapi file annotation fields
1517
return doc, true

0 commit comments

Comments
 (0)