Update OpenAPI and fix openAPI tests to handle unexported jsonreferences

Co-authored-by: Alexander Zielensk <alexzielenski@gmail.com>

Kubernetes-commit: 700e3b566428bca46d2d37514c8fd7af60c7ff34
This commit is contained in:
Joe Betz 2024-10-25 13:51:03 -04:00 committed by Kubernetes Publisher
parent 5295d256f6
commit b5002f17ec
4 changed files with 26 additions and 0 deletions

View File

@ -56,3 +56,7 @@ func (g *groupversion) Schema(contentType string) ([]byte, error) {
return cachedInfo.data, cachedInfo.err return cachedInfo.data, cachedInfo.err
} }
func (c *groupversion) ServerRelativeURL() string {
return c.delegate.ServerRelativeURL()
}

View File

@ -27,6 +27,12 @@ const ContentTypeOpenAPIV3PB = "application/com.github.proto-openapi.spec.v3@v1.
type GroupVersion interface { type GroupVersion interface {
Schema(contentType string) ([]byte, error) Schema(contentType string) ([]byte, error)
// ServerRelativeURL. Returns the path and parameters used to fetch the schema.
// You should use the Schema method to fetch it, but this value can be used
// to key the current version of the schema in a cache since it contains a
// hash string which changes upon schema update.
ServerRelativeURL() string
} }
type groupversion struct { type groupversion struct {
@ -68,3 +74,9 @@ func (g *groupversion) Schema(contentType string) ([]byte, error) {
return path.Do(context.TODO()).Raw() return path.Do(context.TODO()).Raw()
} }
// URL used for fetching the schema. The URL includes a hash and can be used
// to key the current version of the schema in a cache.
func (g *groupversion) ServerRelativeURL() string {
return g.item.ServerRelativeURL
}

View File

@ -77,3 +77,8 @@ func (f FakeGroupVersion) Schema(contentType string) ([]byte, error) {
} }
return f.GVSpec, nil return f.GVSpec, nil
} }
// ServerRelativeURL returns an empty string.
func (f FakeGroupVersion) ServerRelativeURL() string {
panic("unimplemented")
}

View File

@ -94,3 +94,8 @@ func (f *fileGroupVersion) Schema(contentType string) ([]byte, error) {
} }
return fs.ReadFile(f.f, f.filename) return fs.ReadFile(f.f, f.filename)
} }
// ServerRelativeURL returns an empty string.
func (f *fileGroupVersion) ServerRelativeURL() string {
return f.filename
}