@@ -35,44 +35,44 @@ func schemaProperties() map[string]*jsonschema.Schema {
35
35
return composeSchema .Properties
36
36
}
37
37
38
- func nodeProperties (nodes []* ast.MappingValueNode , line , column int ) any {
38
+ func nodeProperties (nodes []* ast.MappingValueNode , line , column int ) ( any , bool ) {
39
39
if composeSchema != nil && slices .Contains (composeSchema .Types .ToStrings (), "object" ) && composeSchema .Properties != nil {
40
40
if prop , ok := composeSchema .Properties [nodes [0 ].Key .GetToken ().Value ]; ok {
41
41
for regexp , property := range prop .PatternProperties {
42
42
if regexp .MatchString (nodes [1 ].Key .GetToken ().Value ) {
43
43
if property .Ref != nil {
44
- return recurseNodeProperties (nodes , line , column , 2 , property .Ref .Properties )
44
+ return recurseNodeProperties (nodes , line , column , 2 , property .Ref .Properties , false )
45
45
}
46
46
}
47
47
}
48
48
}
49
49
}
50
- return nil
50
+ return nil , false
51
51
}
52
52
53
- func recurseNodeProperties (nodes []* ast.MappingValueNode , line , column , nodeOffset int , properties map [string ]* jsonschema.Schema ) any {
53
+ func recurseNodeProperties (nodes []* ast.MappingValueNode , line , column , nodeOffset int , properties map [string ]* jsonschema.Schema , arrayAttributes bool ) ( any , bool ) {
54
54
if len (nodes ) == nodeOffset {
55
- return properties
55
+ return properties , arrayAttributes
56
56
}
57
- if len (nodes ) >= nodeOffset + 2 && nodes [nodeOffset ].Key .GetToken ().Position .Column <= column && column < nodes [ nodeOffset + 1 ]. Key . GetToken (). Position . Column {
58
- return properties
57
+ if len (nodes ) >= nodeOffset + 2 && nodes [nodeOffset ].Key .GetToken ().Position .Column == column {
58
+ return properties , false
59
59
}
60
60
if column == nodes [nodeOffset ].Key .GetToken ().Position .Column {
61
- return properties
61
+ return properties , false
62
62
}
63
63
64
64
value := nodes [nodeOffset ].Key .GetToken ().Value
65
65
if prop , ok := properties [value ]; ok {
66
66
if prop .Ref != nil {
67
67
if len (prop .Ref .Properties ) > 0 {
68
- return recurseNodeProperties (nodes , line , column , nodeOffset + 1 , prop .Ref .Properties )
68
+ return recurseNodeProperties (nodes , line , column , nodeOffset + 1 , prop .Ref .Properties , false )
69
69
}
70
70
for regexp , property := range prop .Ref .PatternProperties {
71
71
nextValue := nodes [nodeOffset + 1 ].Key .GetToken ().Value
72
72
if regexp .MatchString (nextValue ) {
73
73
for _ , nested := range property .OneOf {
74
74
if slices .Contains (nested .Types .ToStrings (), "object" ) {
75
- return recurseNodeProperties (nodes , line , column , nodeOffset + 2 , nested .Properties )
75
+ return recurseNodeProperties (nodes , line , column , nodeOffset + 2 , nested .Properties , false )
76
76
}
77
77
}
78
78
}
@@ -81,7 +81,7 @@ func recurseNodeProperties(nodes []*ast.MappingValueNode, line, column, nodeOffs
81
81
for _ , nested := range schema .OneOf {
82
82
if nested .Types != nil && slices .Contains (nested .Types .ToStrings (), "object" ) {
83
83
if len (nested .Properties ) > 0 {
84
- return recurseNodeProperties (nodes , line , column , nodeOffset + 1 , nested .Properties )
84
+ return recurseNodeProperties (nodes , line , column , nodeOffset + 1 , nested .Properties , true )
85
85
}
86
86
}
87
87
}
@@ -91,19 +91,19 @@ func recurseNodeProperties(nodes []*ast.MappingValueNode, line, column, nodeOffs
91
91
for _ , schema := range prop .OneOf {
92
92
if schema .Types != nil && slices .Contains (schema .Types .ToStrings (), "object" ) {
93
93
if len (schema .Properties ) > 0 {
94
- return recurseNodeProperties (nodes , line , column , nodeOffset + 1 , schema .Properties )
94
+ return recurseNodeProperties (nodes , line , column , nodeOffset + 1 , schema .Properties , false )
95
95
}
96
96
97
97
for regexp , property := range schema .PatternProperties {
98
98
if len (nodes ) == nodeOffset + 1 {
99
- return nil
99
+ return nil , false
100
100
}
101
101
102
102
nextValue := nodes [nodeOffset + 1 ].Key .GetToken ().Value
103
103
if regexp .MatchString (nextValue ) {
104
104
for _ , nested := range property .OneOf {
105
105
if slices .Contains (nested .Types .ToStrings (), "object" ) {
106
- return recurseNodeProperties (nodes , line , column , nodeOffset + 2 , nested .Properties )
106
+ return recurseNodeProperties (nodes , line , column , nodeOffset + 2 , nested .Properties , false )
107
107
}
108
108
}
109
109
}
@@ -115,19 +115,19 @@ func recurseNodeProperties(nodes []*ast.MappingValueNode, line, column, nodeOffs
115
115
for _ , nested := range schema .OneOf {
116
116
if nested .Types != nil && slices .Contains (nested .Types .ToStrings (), "object" ) {
117
117
if len (nested .Properties ) > 0 {
118
- return recurseNodeProperties (nodes , line , column , nodeOffset + 1 , nested .Properties )
118
+ return recurseNodeProperties (nodes , line , column , nodeOffset + 1 , nested .Properties , true )
119
119
}
120
120
}
121
121
}
122
122
}
123
123
124
124
if nodes [nodeOffset ].Key .GetToken ().Position .Column < column {
125
125
if nodes [nodeOffset ].Key .GetToken ().Position .Line == line {
126
- return prop
126
+ return prop , false
127
127
}
128
- return recurseNodeProperties (nodes , line , column , nodeOffset + 1 , prop .Properties )
128
+ return recurseNodeProperties (nodes , line , column , nodeOffset + 1 , prop .Properties , false )
129
129
}
130
- return prop .Properties
130
+ return prop .Properties , false
131
131
}
132
- return properties
132
+ return properties , false
133
133
}
0 commit comments