mirror of
https://github.com/niusmallnan/steve.git
synced 2025-09-02 21:55:44 +00:00
Fix openapi schema to steve schema generation
This commit is contained in:
@@ -97,8 +97,7 @@ func toField(schema proto.Schema) schemas.Field {
|
|||||||
case *proto.Map:
|
case *proto.Map:
|
||||||
f.Type = "map[" + toField(v.SubType).Type + "]"
|
f.Type = "map[" + toField(v.SubType).Type + "]"
|
||||||
case *proto.Kind:
|
case *proto.Kind:
|
||||||
parts := v.Path.Get()
|
f.Type = v.Path.String()
|
||||||
f.Type = parts[len(parts)-1]
|
|
||||||
case proto.Reference:
|
case proto.Reference:
|
||||||
sub := v.SubSchema()
|
sub := v.SubSchema()
|
||||||
if p, ok := sub.(*proto.Primitive); ok {
|
if p, ok := sub.(*proto.Primitive); ok {
|
||||||
|
@@ -3,7 +3,7 @@ package converter
|
|||||||
import (
|
import (
|
||||||
"github.com/rancher/apiserver/pkg/types"
|
"github.com/rancher/apiserver/pkg/types"
|
||||||
"github.com/rancher/wrangler/pkg/schemas"
|
"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 {
|
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 {
|
if existing, ok := schemasMap[s.ID]; ok && len(existing.Attributes) > 0 {
|
||||||
schemasMap[s.ID] = &s
|
s.Attributes = existing.Attributes
|
||||||
}
|
}
|
||||||
|
schemasMap[s.ID] = &s
|
||||||
|
|
||||||
for k, v := range s.ResourceFields {
|
for k, v := range s.ResourceFields {
|
||||||
if types.ReservedFields[k] {
|
if types.ReservedFields[k] {
|
||||||
|
Reference in New Issue
Block a user