Commit 75affa4a authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #37059 from mbohlool/dev2

Automatic merge from submit-queue OpenAPI Bugfix: []byte should be treated as integer array data field of v1.Secret is a map of string to byte array. Generated spec should generate a map of string to (type="string", format="byte" that means map of base64 string) however current code converts it to an array of integer that is wrong. fixes #37126
parents d725b3e3 5c3e078c
...@@ -34956,11 +34956,8 @@ ...@@ -34956,11 +34956,8 @@
"description": "Data contains the secret data. Each key must be a valid DNS_SUBDOMAIN or leading dot followed by valid DNS_SUBDOMAIN. The serialized form of the secret data is a base64 encoded string, representing the arbitrary (possibly non-string) data value here. Described in https://tools.ietf.org/html/rfc4648#section-4", "description": "Data contains the secret data. Each key must be a valid DNS_SUBDOMAIN or leading dot followed by valid DNS_SUBDOMAIN. The serialized form of the secret data is a base64 encoded string, representing the arbitrary (possibly non-string) data value here. Described in https://tools.ietf.org/html/rfc4648#section-4",
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": {
"type": "array", "type": "string",
"items": { "format": "byte"
"type": "integer",
"format": "byte"
}
} }
}, },
"metadata": { "metadata": {
......
...@@ -446,10 +446,15 @@ func (g openAPITypeWriter) generateMapProperty(t *types.Type) error { ...@@ -446,10 +446,15 @@ func (g openAPITypeWriter) generateMapProperty(t *types.Type) error {
} }
g.Do("Type: []string{\"object\"},\n", nil) g.Do("Type: []string{\"object\"},\n", nil)
g.Do("AdditionalProperties: &spec.SchemaOrBool{\nSchema: &spec.Schema{\nSchemaProps: spec.SchemaProps{\n", nil) g.Do("AdditionalProperties: &spec.SchemaOrBool{\nSchema: &spec.Schema{\nSchemaProps: spec.SchemaProps{\n", nil)
typeString, format := common.GetOpenAPITypeFormat(elemType.String())
if typeString != "" {
g.generateSimpleProperty(typeString, format)
g.Do("},\n},\n},\n", nil)
return nil
}
switch elemType.Kind { switch elemType.Kind {
case types.Builtin: case types.Builtin:
typeString, format := common.GetOpenAPITypeFormat(elemType.String()) return fmt.Errorf("please add type %v to getOpenAPITypeFormat function.", elemType)
g.generateSimpleProperty(typeString, format)
case types.Struct: case types.Struct:
g.generateReferenceProperty(t.Elem) g.generateReferenceProperty(t.Elem)
case types.Slice, types.Array: case types.Slice, types.Array:
...@@ -465,10 +470,15 @@ func (g openAPITypeWriter) generateSliceProperty(t *types.Type) error { ...@@ -465,10 +470,15 @@ func (g openAPITypeWriter) generateSliceProperty(t *types.Type) error {
elemType := resolveAliasAndPtrType(t.Elem) elemType := resolveAliasAndPtrType(t.Elem)
g.Do("Type: []string{\"array\"},\n", nil) g.Do("Type: []string{\"array\"},\n", nil)
g.Do("Items: &spec.SchemaOrArray{\nSchema: &spec.Schema{\nSchemaProps: spec.SchemaProps{\n", nil) g.Do("Items: &spec.SchemaOrArray{\nSchema: &spec.Schema{\nSchemaProps: spec.SchemaProps{\n", nil)
typeString, format := common.GetOpenAPITypeFormat(elemType.String())
if typeString != "" {
g.generateSimpleProperty(typeString, format)
g.Do("},\n},\n},\n", nil)
return nil
}
switch elemType.Kind { switch elemType.Kind {
case types.Builtin: case types.Builtin:
typeString, format := common.GetOpenAPITypeFormat(elemType.String()) return fmt.Errorf("please add type %v to getOpenAPITypeFormat function.", elemType)
g.generateSimpleProperty(typeString, format)
case types.Struct: case types.Struct:
g.generateReferenceProperty(t.Elem) g.generateReferenceProperty(t.Elem)
default: default:
......
...@@ -9273,11 +9273,8 @@ ...@@ -9273,11 +9273,8 @@
"description": "Data contains the secret data. Each key must be a valid DNS_SUBDOMAIN or leading dot followed by valid DNS_SUBDOMAIN. The serialized form of the secret data is a base64 encoded string, representing the arbitrary (possibly non-string) data value here. Described in https://tools.ietf.org/html/rfc4648#section-4", "description": "Data contains the secret data. Each key must be a valid DNS_SUBDOMAIN or leading dot followed by valid DNS_SUBDOMAIN. The serialized form of the secret data is a base64 encoded string, representing the arbitrary (possibly non-string) data value here. Described in https://tools.ietf.org/html/rfc4648#section-4",
"type": "object", "type": "object",
"additionalProperties": { "additionalProperties": {
"type": "array", "type": "string",
"items": { "format": "byte"
"type": "integer",
"format": "byte"
}
} }
}, },
"metadata": { "metadata": {
......
...@@ -12326,15 +12326,8 @@ var OpenAPIDefinitions *common.OpenAPIDefinitions = &common.OpenAPIDefinitions{ ...@@ -12326,15 +12326,8 @@ var OpenAPIDefinitions *common.OpenAPIDefinitions = &common.OpenAPIDefinitions{
AdditionalProperties: &spec.SchemaOrBool{ AdditionalProperties: &spec.SchemaOrBool{
Schema: &spec.Schema{ Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{ SchemaProps: spec.SchemaProps{
Type: []string{"array"}, Type: []string{"string"},
Items: &spec.SchemaOrArray{ Format: "byte",
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Type: []string{"integer"},
Format: "byte",
},
},
},
}, },
}, },
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment