File tree Expand file tree Collapse file tree 1 file changed +28
-5
lines changed
src/LibKubernetesGenerator Expand file tree Collapse file tree 1 file changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -246,12 +246,14 @@ string toType()
246
246
247
247
break ;
248
248
case "T" :
249
- // Return single item type from list type (e.g., V1Pod from V1PodList)
250
- return ! string . IsNullOrEmpty ( t ) && t . EndsWith ( "List" , StringComparison . Ordinal )
251
- ? t . Substring ( 0 , t . Length - 4 )
252
- : t ;
249
+ var itemType = TryGetItemTypeFromSchema ( response ) ;
250
+ if ( itemType != null )
251
+ {
252
+ return itemType ;
253
+ }
254
+
255
+ break ;
253
256
case "TList" :
254
- // Return list type as-is
255
257
return t ;
256
258
}
257
259
@@ -291,5 +293,26 @@ public static bool IfType(JsonSchemaProperty property, string type)
291
293
292
294
return false ;
293
295
}
296
+
297
+ private string TryGetItemTypeFromSchema ( OpenApiResponse response )
298
+ {
299
+ var listSchema = response ? . Schema ? . Reference ;
300
+ if ( listSchema ? . Properties ? . TryGetValue ( "items" , out var itemsProperty ) != true )
301
+ {
302
+ return null ;
303
+ }
304
+
305
+ if ( itemsProperty . Reference != null )
306
+ {
307
+ return classNameHelper . GetClassNameForSchemaDefinition ( itemsProperty . Reference ) ;
308
+ }
309
+
310
+ if ( itemsProperty . Item ? . Reference != null )
311
+ {
312
+ return classNameHelper . GetClassNameForSchemaDefinition ( itemsProperty . Item . Reference ) ;
313
+ }
314
+
315
+ return null ;
316
+ }
294
317
}
295
318
}
You can’t perform that action at this time.
0 commit comments