@@ -40,3 +40,149 @@ func TestSchemaToMap_MissingEmptyProperties(t *testing.T) {
4040 "properties" : map [string ]any {},
4141 }, m )
4242}
43+
44+ func TestSchemaToMap_PropertyWithoutType (t * testing.T ) {
45+ m , err := SchemaToMap (map [string ]any {
46+ "type" : "object" ,
47+ "properties" : map [string ]any {
48+ "name" : map [string ]any {
49+ "type" : "string" ,
50+ },
51+ "metadata" : map [string ]any {
52+ "description" : "some metadata" ,
53+ },
54+ },
55+ })
56+ require .NoError (t , err )
57+
58+ assert .Equal (t , map [string ]any {
59+ "type" : "object" ,
60+ "properties" : map [string ]any {
61+ "name" : map [string ]any {
62+ "type" : "string" ,
63+ },
64+ "metadata" : map [string ]any {
65+ "type" : "object" ,
66+ "description" : "some metadata" ,
67+ },
68+ },
69+ }, m )
70+ }
71+
72+ func TestSchemaToMap_NestedPropertyWithoutType (t * testing.T ) {
73+ m , err := SchemaToMap (map [string ]any {
74+ "type" : "object" ,
75+ "properties" : map [string ]any {
76+ "config" : map [string ]any {
77+ "type" : "object" ,
78+ "properties" : map [string ]any {
79+ "host" : map [string ]any {
80+ "type" : "string" ,
81+ },
82+ "metadata" : map [string ]any {
83+ "description" : "nested metadata without type" ,
84+ },
85+ },
86+ },
87+ },
88+ })
89+ require .NoError (t , err )
90+
91+ assert .Equal (t , map [string ]any {
92+ "type" : "object" ,
93+ "properties" : map [string ]any {
94+ "config" : map [string ]any {
95+ "type" : "object" ,
96+ "properties" : map [string ]any {
97+ "host" : map [string ]any {
98+ "type" : "string" ,
99+ },
100+ "metadata" : map [string ]any {
101+ "type" : "object" ,
102+ "description" : "nested metadata without type" ,
103+ },
104+ },
105+ },
106+ },
107+ }, m )
108+ }
109+
110+ func TestSchemaToMap_ArrayItemsPropertyWithoutType (t * testing.T ) {
111+ m , err := SchemaToMap (map [string ]any {
112+ "type" : "object" ,
113+ "properties" : map [string ]any {
114+ "items" : map [string ]any {
115+ "type" : "array" ,
116+ "items" : map [string ]any {
117+ "type" : "object" ,
118+ "properties" : map [string ]any {
119+ "value" : map [string ]any {
120+ "description" : "value without type" ,
121+ },
122+ },
123+ },
124+ },
125+ },
126+ })
127+ require .NoError (t , err )
128+
129+ assert .Equal (t , map [string ]any {
130+ "type" : "object" ,
131+ "properties" : map [string ]any {
132+ "items" : map [string ]any {
133+ "type" : "array" ,
134+ "items" : map [string ]any {
135+ "type" : "object" ,
136+ "properties" : map [string ]any {
137+ "value" : map [string ]any {
138+ "type" : "object" ,
139+ "description" : "value without type" ,
140+ },
141+ },
142+ },
143+ },
144+ },
145+ }, m )
146+ }
147+
148+ func TestSchemaToMap_DeeplyNestedPropertyWithoutType (t * testing.T ) {
149+ m , err := SchemaToMap (map [string ]any {
150+ "type" : "object" ,
151+ "properties" : map [string ]any {
152+ "level1" : map [string ]any {
153+ "type" : "object" ,
154+ "properties" : map [string ]any {
155+ "level2" : map [string ]any {
156+ "type" : "object" ,
157+ "properties" : map [string ]any {
158+ "level3" : map [string ]any {
159+ "description" : "deeply nested without type" ,
160+ },
161+ },
162+ },
163+ },
164+ },
165+ },
166+ })
167+ require .NoError (t , err )
168+
169+ assert .Equal (t , map [string ]any {
170+ "type" : "object" ,
171+ "properties" : map [string ]any {
172+ "level1" : map [string ]any {
173+ "type" : "object" ,
174+ "properties" : map [string ]any {
175+ "level2" : map [string ]any {
176+ "type" : "object" ,
177+ "properties" : map [string ]any {
178+ "level3" : map [string ]any {
179+ "type" : "object" ,
180+ "description" : "deeply nested without type" ,
181+ },
182+ },
183+ },
184+ },
185+ },
186+ },
187+ }, m )
188+ }
0 commit comments