mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Merge pull request #108907 from Jefftree/crd-openapi-bug
Fix OpenAPI v3 bug with #/definitions
This commit is contained in:
commit
697c685187
@ -501,7 +501,7 @@ func (b *builder) buildListSchema(v2 bool) *spec.Schema {
|
||||
doc := fmt.Sprintf("List of %s. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md", b.plural)
|
||||
s := new(spec.Schema).WithDescription(fmt.Sprintf("%s is a list of %s", b.listKind, b.kind)).
|
||||
WithRequired("items").
|
||||
SetProperty("items", *spec.ArrayProperty(spec.RefSchema(name)).WithDescription(doc)).
|
||||
SetProperty("items", *spec.ArrayProperty(spec.RefSchema(refForOpenAPIVersion(name, v2))).WithDescription(doc)).
|
||||
SetProperty("metadata", *spec.RefSchema(refForOpenAPIVersion(listMetaSchemaRef, v2)).WithDescription(swaggerPartialObjectMetadataListDescriptions["metadata"]))
|
||||
|
||||
addTypeMetaProperties(s, v2)
|
||||
|
@ -782,6 +782,10 @@ func TestBuildOpenAPIV3(t *testing.T) {
|
||||
}
|
||||
|
||||
gotSchema := *got.Components.Schemas["io.k8s.bar.v1.Foo"]
|
||||
listSchemaRef := got.Components.Schemas["io.k8s.bar.v1.FooList"].Properties["items"].Items.Schema.Ref.String()
|
||||
if strings.Contains(listSchemaRef, "#/definitions/") || !strings.Contains(listSchemaRef, "#/components/schemas/") {
|
||||
t.Errorf("Expected list schema ref to contain #/components/schemas/ prefix. Got %s", listSchemaRef)
|
||||
}
|
||||
gotProperties := properties(gotSchema.Properties)
|
||||
wantedProperties := properties(wantedSchema.Properties)
|
||||
if !gotProperties.Equal(wantedProperties) {
|
||||
|
Loading…
Reference in New Issue
Block a user