(basePath, prefix string, schema *jsonschema.Schema, definitions jsonschema.Definitions, depth int, parentIsNameObjectMap bool)
| 73 | } |
| 74 | |
| 75 | func createSections(basePath, prefix string, schema *jsonschema.Schema, definitions jsonschema.Definitions, depth int, parentIsNameObjectMap bool) string { |
| 76 | partialImports := &[]string{} |
| 77 | content := "" |
| 78 | headlinePrefix := strings.Repeat("#", depth+1) + " " |
| 79 | anchorPrefix := strings.TrimPrefix(strings.ReplaceAll(prefix, prefixSeparator, anchorSeparator), anchorSeparator) |
| 80 | |
| 81 | groups := map[string]*Group{} |
| 82 | |
| 83 | for _, fieldName := range schema.Properties.Keys() { |
| 84 | if parentIsNameObjectMap && fieldName == nameFieldName { |
| 85 | continue |
| 86 | } |
| 87 | |
| 88 | field, ok := schema.Properties.Get(fieldName) |
| 89 | if ok { |
| 90 | if fieldSchema, ok := field.(*jsonschema.Schema); ok { |
| 91 | fieldContent := "" |
| 92 | fieldFile := fmt.Sprintf("%s%s%s.mdx", basePath, prefix, fieldName) |
| 93 | fieldFileReference := fieldFile |
| 94 | fieldType := "object" |
| 95 | isNameObjectMap := false |
| 96 | groupID, _ := fieldSchema.Extras[groupKey].(string) |
| 97 | expandable := false |
| 98 | |
| 99 | var patternPropertySchema *jsonschema.Schema |
| 100 | var nestedSchema *jsonschema.Schema |
| 101 | |
| 102 | ref := "" |
| 103 | if fieldSchema.Type == "array" { |
| 104 | ref = fieldSchema.Items.Ref |
| 105 | fieldType = "object[]" |
| 106 | } else if patternPropertySchema, ok = fieldSchema.PatternProperties[".*"]; ok { |
| 107 | ref = patternPropertySchema.Ref |
| 108 | isNameObjectMap = true |
| 109 | } else if fieldSchema.Ref != "" { |
| 110 | ref = fieldSchema.Ref |
| 111 | } |
| 112 | |
| 113 | if ref != "" { |
| 114 | refSplit := strings.Split(ref, "/") |
| 115 | nestedSchema, ok = definitions[refSplit[len(refSplit)-1]] |
| 116 | |
| 117 | if ok { |
| 118 | newPrefix := prefix + fieldName + prefixSeparator |
| 119 | createSections(basePath, newPrefix, nestedSchema, definitions, depth+1, isNameObjectMap) |
| 120 | fieldFileReference = fmt.Sprintf("%s%s%s_reference.mdx", basePath, prefix, fieldName) |
| 121 | |
| 122 | fieldContent = GetPartialImport(fieldFileReference, fieldFile) + "\n\n" + fmt.Sprintf(TemplatePartialUse, GetPartialImportName(fieldFileReference)) |
| 123 | |
| 124 | expandable = true |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | required := contains(schema.Required, fieldName) |
| 129 | fieldDefault := "" |
| 130 | |
| 131 | fieldType = fieldSchema.Type |
| 132 | if fieldType == "" && fieldSchema.OneOf != nil { |
no test coverage detected