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 #42051
pull/6/head
Kubernetes Submit Queue 2017-02-27 21:09:51 -08:00 committed by GitHub
commit 131167ced9
2 changed files with 6073 additions and 6064 deletions

View File

@ -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