mirror of https://github.com/k3s-io/k3s
Merge pull request #42068 from mbohlool/openapigen-bugfix
Automatic merge from submit-queue (batch tested with PRs 41205, 42196, 42068, 41588, 41271) Openapigen should process types in a consistent order Types are sorted by name only in openapi-gen. This makes problems like #42051 for types with the same name. This PR adds an identity namer that includes full package name for the types and use that to sort types before processing them. fixes #42051pull/6/head
commit
131167ced9
|
@ -69,17 +69,26 @@ func hasOptionalTag(m *types.Member) bool {
|
|||
return hasOptionalCommentTag || hasOptionalJsonTag
|
||||
}
|
||||
|
||||
type identityNamer struct{}
|
||||
|
||||
func (_ identityNamer) Name(t *types.Type) string {
|
||||
return t.Name.String()
|
||||
}
|
||||
|
||||
var _ namer.Namer = identityNamer{}
|
||||
|
||||
// NameSystems returns the name system used by the generators in this package.
|
||||
func NameSystems() namer.NameSystems {
|
||||
return namer.NameSystems{
|
||||
"raw": namer.NewRawNamer("", nil),
|
||||
"raw": namer.NewRawNamer("", nil),
|
||||
"sorting_namer": identityNamer{},
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultNameSystem returns the default name system for ordering the types to be
|
||||
// processed by the generators in this package.
|
||||
func DefaultNameSystem() string {
|
||||
return "raw"
|
||||
return "sorting_namer"
|
||||
}
|
||||
|
||||
func Packages(context *generator.Context, arguments *args.GeneratorArgs) generator.Packages {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue