@@ -102,12 +102,31 @@ export async function getBodyParams(schema, topLevel = false) {
102102 keyParam . childParamsGroups . push ( ...( await getBodyParams ( param . additionalProperties , false ) ) )
103103 childParamsGroups . push ( keyParam )
104104 } else if ( paramType && paramType . includes ( 'array' ) ) {
105- const arrayType = param . items . type
106- if ( arrayType ) {
107- paramType . splice ( paramType . indexOf ( 'array' ) , 1 , `array of ${ arrayType } s` )
108- }
109- if ( arrayType === 'object' ) {
110- childParamsGroups . push ( ...( await getBodyParams ( param . items , false ) ) )
105+ if ( param . items && param . items . oneOf ) {
106+ if ( param . items . oneOf . every ( ( object ) => object . type === 'object' ) ) {
107+ paramType . splice ( paramType . indexOf ( 'array' ) , 1 , `array of objects` )
108+ param . oneOfObject = true
109+
110+ for ( const oneOfParam of param . items . oneOf ) {
111+ const objParam = {
112+ type : 'object' ,
113+ name : oneOfParam . title ,
114+ description : await renderContent ( oneOfParam . description ) ,
115+ isRequired : oneOfParam . required ,
116+ childParamsGroups : [ ] ,
117+ }
118+ objParam . childParamsGroups . push ( ...( await getBodyParams ( oneOfParam , false ) ) )
119+ childParamsGroups . push ( objParam )
120+ }
121+ }
122+ } else {
123+ const arrayType = param . items . type
124+ if ( arrayType ) {
125+ paramType . splice ( paramType . indexOf ( 'array' ) , 1 , `array of ${ arrayType } s` )
126+ }
127+ if ( arrayType === 'object' ) {
128+ childParamsGroups . push ( ...( await getBodyParams ( param . items , false ) ) )
129+ }
111130 }
112131 } else if ( paramType && paramType . includes ( 'object' ) ) {
113132 childParamsGroups . push ( ...( await getBodyParams ( param , false ) ) )
@@ -138,13 +157,12 @@ export async function getBodyParams(schema, topLevel = false) {
138157 const oneOfDescriptions = descriptions . length ? descriptions [ 0 ] . description : ''
139158 if ( ! param . description ) param . description = oneOfDescriptions
140159
141- // This is a workaround for an operation that incorrectly defines allOf for a
142- // body parameter. As a workaround, we will use the first object in the list of
143- // the allOf array. Otherwise, fallback to the first item in the array.
144- // This isn't ideal, and in the case of an actual allOf occurrence, we should
145- // handle it differently by merging all of the properties. There is currently
146- // only one occurrence for the operation id repos/update-information-about-pages-site
147- // See Ecosystem API issue number #3332 for future plans to fix this in the OpenAPI
160+ // This is a workaround for an operation that incorrectly defines anyOf
161+ // for a body parameter. As a workaround, we will use the first object
162+ // in the list of the anyOf array. Otherwise, fallback to the first item
163+ // in the array. There is currently only one occurrence for the operation
164+ // id repos/update-information-about-pages-site. See Ecosystem API issue
165+ // number #3332 for future plans to fix this in the OpenAPI
148166 } else if ( param && param . anyOf && Object . keys ( param ) . length === 1 ) {
149167 const firstObject = Object . values ( param . anyOf ) . find ( ( item ) => item . type === 'object' )
150168 if ( firstObject ) {
@@ -212,6 +230,10 @@ async function getTransformedParam(param, paramType, props) {
212230 paramDecorated . enum = param . enum
213231 }
214232
233+ if ( param . oneOfObject ) {
234+ paramDecorated . oneOfObject = true
235+ }
236+
215237 // we also want to catch default values of `false` for booleans
216238 if ( param . default !== undefined ) {
217239 paramDecorated . default = param . default
0 commit comments