mirror of https://github.com/databricks/cli.git
fix: Remove type inconsistency in maps
This commit is contained in:
parent
14721deb3a
commit
26466d23b4
|
@ -69,7 +69,7 @@ func generateDocs(inputPaths []string, outputPath string, rootType reflect.Type,
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
schemas := map[string]jsonschema.Schema{}
|
schemas := map[string]*jsonschema.Schema{}
|
||||||
customFields := map[string]bool{}
|
customFields := map[string]bool{}
|
||||||
|
|
||||||
s, err := jsonschema.FromType(rootType, []func(reflect.Type, jsonschema.Schema) jsonschema.Schema{
|
s, err := jsonschema.FromType(rootType, []func(reflect.Type, jsonschema.Schema) jsonschema.Schema{
|
||||||
|
@ -82,7 +82,7 @@ func generateDocs(inputPaths []string, outputPath string, rootType reflect.Type,
|
||||||
refPath := getPath(typ)
|
refPath := getPath(typ)
|
||||||
shouldHandle := strings.HasPrefix(refPath, "github.com")
|
shouldHandle := strings.HasPrefix(refPath, "github.com")
|
||||||
if !shouldHandle {
|
if !shouldHandle {
|
||||||
schemas[jsonschema.TypePath(typ)] = s
|
schemas[jsonschema.TypePath(typ)] = &s
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ func generateDocs(inputPaths []string, outputPath string, rootType reflect.Type,
|
||||||
assignAnnotation(v, a[k])
|
assignAnnotation(v, a[k])
|
||||||
}
|
}
|
||||||
|
|
||||||
schemas[jsonschema.TypePath(typ)] = s
|
schemas[jsonschema.TypePath(typ)] = &s
|
||||||
return s
|
return s
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -42,7 +42,7 @@ type rootProp struct {
|
||||||
|
|
||||||
const MapType = "Map"
|
const MapType = "Map"
|
||||||
|
|
||||||
func getNodes(s jsonschema.Schema, refs map[string]jsonschema.Schema, customFields map[string]bool) []rootNode {
|
func getNodes(s jsonschema.Schema, refs map[string]*jsonschema.Schema, customFields map[string]bool) []rootNode {
|
||||||
rootProps := []rootProp{}
|
rootProps := []rootProp{}
|
||||||
for k, v := range s.Properties {
|
for k, v := range s.Properties {
|
||||||
rootProps = append(rootProps, rootProp{k, v, true, false})
|
rootProps = append(rootProps, rootProp{k, v, true, false})
|
||||||
|
@ -125,7 +125,7 @@ func getHumanReadableType(t jsonschema.Type) string {
|
||||||
return typesMapping[string(t)]
|
return typesMapping[string(t)]
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAttributes(props map[string]*jsonschema.Schema, refs map[string]jsonschema.Schema, customFields map[string]bool, prefix string, circular bool) []attributeNode {
|
func getAttributes(props, refs map[string]*jsonschema.Schema, customFields map[string]bool, prefix string, circular bool) []attributeNode {
|
||||||
attributes := []attributeNode{}
|
attributes := []attributeNode{}
|
||||||
for k, v := range props {
|
for k, v := range props {
|
||||||
v = resolveRefs(v, refs)
|
v = resolveRefs(v, refs)
|
||||||
|
@ -165,7 +165,7 @@ func shouldExtract(ref string, customFields map[string]bool) bool {
|
||||||
return isCustomField
|
return isCustomField
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractNodes(prefix string, props map[string]*jsonschema.Schema, refs map[string]jsonschema.Schema, customFields map[string]bool) []rootProp {
|
func extractNodes(prefix string, props, refs map[string]*jsonschema.Schema, customFields map[string]bool) []rootProp {
|
||||||
nodes := []rootProp{}
|
nodes := []rootProp{}
|
||||||
for k, v := range props {
|
for k, v := range props {
|
||||||
if !shouldExtract(*v.Reference, customFields) {
|
if !shouldExtract(*v.Reference, customFields) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"github.com/databricks/cli/libs/jsonschema"
|
"github.com/databricks/cli/libs/jsonschema"
|
||||||
)
|
)
|
||||||
|
|
||||||
func isReferenceType(v *jsonschema.Schema, refs map[string]jsonschema.Schema, customFields map[string]bool) bool {
|
func isReferenceType(v *jsonschema.Schema, refs map[string]*jsonschema.Schema, customFields map[string]bool) bool {
|
||||||
if v.Type != "object" && v.Type != "array" {
|
if v.Type != "object" && v.Type != "array" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ func resolveAdditionalProperties(v *jsonschema.Schema) *jsonschema.Schema {
|
||||||
return additionalProps
|
return additionalProps
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolveRefs(s *jsonschema.Schema, schemas map[string]jsonschema.Schema) *jsonschema.Schema {
|
func resolveRefs(s *jsonschema.Schema, schemas map[string]*jsonschema.Schema) *jsonschema.Schema {
|
||||||
node := s
|
node := s
|
||||||
|
|
||||||
description := s.Description
|
description := s.Description
|
||||||
|
@ -74,14 +74,15 @@ func resolveRefs(s *jsonschema.Schema, schemas map[string]jsonschema.Schema) *js
|
||||||
examples = newNode.Examples
|
examples = newNode.Examples
|
||||||
}
|
}
|
||||||
|
|
||||||
node = &newNode
|
node = newNode
|
||||||
}
|
}
|
||||||
|
|
||||||
node.Description = description
|
newNode := *node
|
||||||
node.MarkdownDescription = markdownDescription
|
newNode.Description = description
|
||||||
node.Examples = examples
|
newNode.MarkdownDescription = markdownDescription
|
||||||
|
newNode.Examples = examples
|
||||||
|
|
||||||
return node
|
return &newNode
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRefType(node *jsonschema.Schema) string {
|
func getRefType(node *jsonschema.Schema) string {
|
||||||
|
|
Loading…
Reference in New Issue