Fix openapi schema to steve schema generation

This commit is contained in:
Darren Shepherd
2021-04-27 17:08:38 -07:00
parent 10cf4e69c2
commit 9ddd83c343
2 changed files with 5 additions and 5 deletions

View File

@@ -97,8 +97,7 @@ func toField(schema proto.Schema) schemas.Field {
case *proto.Map:
f.Type = "map[" + toField(v.SubType).Type + "]"
case *proto.Kind:
parts := v.Path.Get()
f.Type = parts[len(parts)-1]
f.Type = v.Path.String()
case proto.Reference:
sub := v.SubSchema()
if p, ok := sub.(*proto.Primitive); ok {

View File

@@ -3,7 +3,7 @@ package converter
import (
"github.com/rancher/apiserver/pkg/types"
"github.com/rancher/wrangler/pkg/schemas"
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
v1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
)
func modelV3ToSchema(name string, k *v1.JSONSchemaProps, schemasMap map[string]*types.APISchema) *types.APISchema {
@@ -27,9 +27,10 @@ func modelV3ToSchema(name string, k *v1.JSONSchemaProps, schemasMap map[string]*
}
}
if _, ok := schemasMap[s.ID]; !ok {
schemasMap[s.ID] = &s
if existing, ok := schemasMap[s.ID]; ok && len(existing.Attributes) > 0 {
s.Attributes = existing.Attributes
}
schemasMap[s.ID] = &s
for k, v := range s.ResourceFields {
if types.ReservedFields[k] {