(spacing, attributeName string, schema *jsonschema.Schema)
| 859 | } |
| 860 | |
| 861 | func insertText(spacing, attributeName string, schema *jsonschema.Schema) string { |
| 862 | schemaTypes := referencedTypes(schema) |
| 863 | if slices.Contains(schemaTypes, "array") { |
| 864 | if len(schemaTypes) == 1 { |
| 865 | required := requiredFieldsText(spacing, schema, schemaTypes) |
| 866 | if len(required) > 0 { |
| 867 | slices.Sort(required) |
| 868 | sb := strings.Builder{} |
| 869 | sb.WriteString(attributeName) |
| 870 | sb.WriteString(":") |
| 871 | for i, requiredAttribute := range required { |
| 872 | sb.WriteString("\n") |
| 873 | sb.WriteString(spacing) |
| 874 | if i == 0 { |
| 875 | sb.WriteString("- ") |
| 876 | } else { |
| 877 | sb.WriteString(" ") |
| 878 | } |
| 879 | sb.WriteString(requiredAttribute) |
| 880 | if len(required) != 1 { |
| 881 | sb.WriteString(fmt.Sprintf("${%v}", i+1)) |
| 882 | } |
| 883 | } |
| 884 | return sb.String() |
| 885 | } |
| 886 | return fmt.Sprintf("%v:\n%v- ", attributeName, spacing) |
| 887 | } else if len(schemaTypes) == 2 && slices.Contains(schemaTypes, "object") { |
| 888 | return fmt.Sprintf("%v:\n%v", attributeName, spacing) |
| 889 | } |
| 890 | return fmt.Sprintf("%v:", attributeName) |
| 891 | } |
| 892 | if slices.Contains(schemaTypes, "object") { |
| 893 | if len(schemaTypes) == 1 { |
| 894 | return fmt.Sprintf("%v:\n%v", attributeName, spacing) |
| 895 | } |
| 896 | return fmt.Sprintf("%v:", attributeName) |
| 897 | } |
| 898 | if slices.Contains(schemaTypes, "boolean") { |
| 899 | return fmt.Sprintf("%v: ${1|true,false|}", attributeName) |
| 900 | } |
| 901 | return fmt.Sprintf("%v: ", attributeName) |
| 902 | } |
no test coverage detected