MCPcopy Create free account
hub / github.com/devspace-sh/devspace / GenerateReference

Function GenerateReference

docs/hack/util/schema.go:43–73  ·  view source on GitHub ↗
(schema *jsonschema.Schema, basePath string)

Source from the content-addressed store, hash-verified

41}
42
43func GenerateReference(schema *jsonschema.Schema, basePath string) {
44 versionField, ok := schema.Properties.Get(versionFieldName)
45 if ok {
46 if fieldSchema, ok := versionField.(*jsonschema.Schema); ok {
47 versionEnum := []string{}
48 for version := range versions.VersionLoader {
49 versionEnum = append(versionEnum, version)
50 }
51
52 sort.SliceStable(versionEnum, func(a, b int) bool {
53 majorA, _ := strconv.Atoi(string(versionEnum[a][1]))
54 majorB, _ := strconv.Atoi(string(versionEnum[b][1]))
55 minorA, _ := strconv.Atoi(string(versionEnum[a][6:]))
56 minorB, _ := strconv.Atoi(string(versionEnum[b][6:]))
57
58 if majorA == majorB {
59 return minorA > minorB
60 } else {
61 return majorA > majorB
62 }
63 })
64
65 fieldSchema.Enum = []interface{}{}
66 for _, version := range versionEnum {
67 fieldSchema.Enum = append(fieldSchema.Enum, version)
68 }
69 }
70 }
71
72 createSections(basePath, "", schema, schema.Definitions, 1, false)
73}
74
75func createSections(basePath, prefix string, schema *jsonschema.Schema, definitions jsonschema.Definitions, depth int, parentIsNameObjectMap bool) string {
76 partialImports := &[]string{}

Callers 1

mainFunction · 0.92

Calls 2

createSectionsFunction · 0.85
GetMethod · 0.45

Tested by

no test coverage detected