@@ -251,6 +251,15 @@ interface RecordProperty extends BaseProperty {
251251interface ListProperty extends BaseProperty {
252252 format : 'list'
253253 jsonType : 'array'
254+ itemFormat ?: Property [ 'format' ] | 'discriminated_object'
255+ itemProperties ?: Property [ ]
256+ itemEnumValues ?: EnumValue [ ]
257+ discriminator ?: string
258+ variants ?: Array < {
259+ jsonType : string
260+ properties : Property [ ]
261+ description : BaseProperty [ 'description' ]
262+ } >
254263}
255264
256265interface BooleanProperty extends BaseProperty {
@@ -1114,7 +1123,55 @@ const createProperty = (
11141123 case 'boolean' :
11151124 return { ...baseProperty , format : 'boolean' , jsonType : 'boolean' }
11161125 case 'array' :
1117- return { ...baseProperty , format : 'list' , jsonType : 'array' }
1126+ const baseListProperty : ListProperty = {
1127+ ...baseProperty ,
1128+ format : 'list' ,
1129+ jsonType : 'array' ,
1130+ }
1131+
1132+ if ( prop . items == null ) {
1133+ return baseListProperty
1134+ }
1135+
1136+ if ( 'oneOf' in prop . items ) {
1137+ if ( ! prop . items . oneOf . every ( ( schema ) => schema . type === 'object' ) ) {
1138+ return baseListProperty
1139+ }
1140+
1141+ return {
1142+ ...baseListProperty ,
1143+ itemFormat : 'discriminated_object' ,
1144+ variants : prop . items . oneOf . map ( ( schema ) => ( {
1145+ jsonType : schema . type ?? '' ,
1146+ properties : createProperties ( schema . properties ?? { } , [
1147+ ...parentPaths ,
1148+ name ,
1149+ ] ) ,
1150+ description : schema . description ?? '' ,
1151+ } ) ) ,
1152+ ...( prop . items . discriminator ?. propertyName && {
1153+ discriminator : prop . items . discriminator . propertyName ,
1154+ } ) ,
1155+ }
1156+ }
1157+
1158+ const itemProperty = createProperty ( 'items' , prop . items , [
1159+ ...parentPaths ,
1160+ name ,
1161+ ] )
1162+ return {
1163+ ...baseProperty ,
1164+ format : 'list' ,
1165+ jsonType : 'array' ,
1166+ itemFormat : itemProperty . format ,
1167+ ...( itemProperty . format === 'object' && {
1168+ itemProperties : itemProperty . properties ,
1169+ } ) ,
1170+ ...( itemProperty . format === 'enum' && {
1171+ itemEnumValues : itemProperty . values ,
1172+ } ) ,
1173+ }
1174+
11181175 case 'object' :
11191176 if ( prop . properties !== undefined ) {
11201177 return {
0 commit comments