@@ -293,6 +293,12 @@ async function getBodyParams(paramsObject, requiredParams) {
293293 param . name = paramKey
294294 param . in = 'body'
295295 param . rawType = param . type
296+ // OpenAPI 3.0 only had a single value for `type`. OpenAPI 3.1
297+ // will either be a single value or an array of values.
298+ // This makes type an array regardless of how many values the array
299+ // includes. This allows us to support 3.1 while remaining backwards
300+ // compatible with 3.0.
301+ if ( ! Array . isArray ( param . type ) ) param . type = [ param . type ]
296302 param . rawDescription = param . description
297303
298304 // Stores the types listed under the `Type` column in the `Parameters`
@@ -328,16 +334,24 @@ async function getBodyParams(paramsObject, requiredParams) {
328334 }
329335
330336 // Arrays require modifying the displayed type (e.g., array of strings)
331- if ( param . type === 'array' ) {
337+ if ( param . type . includes ( 'array' ) ) {
332338 if ( param . items . type ) paramArray . push ( `array of ${ param . items . type } s` )
333339 if ( param . items . oneOf ) {
334340 paramArray . push ( param . items . oneOf . map ( ( elem ) => `array of ${ elem . type } s` ) )
335341 }
342+ // push the remaining types in the param.type array
343+ // that aren't type array
344+ const remainingItems = param . type
345+ const indexOfArrayType = remainingItems . indexOf ( 'array' )
346+ remainingItems . splice ( indexOfArrayType , 1 )
347+ paramArray . push ( ...remainingItems )
336348 } else if ( param . type ) {
337- paramArray . push ( param . type )
349+ paramArray . push ( ... param . type )
338350 }
339-
340- if ( param . nullable ) paramArray . push ( 'nullable' )
351+ // Supports backwards compatibility for OpenAPI 3.0
352+ // In 3.1 a nullable type is part of the param.type array and
353+ // the property param.nullable does not exist.
354+ if ( param . nullable ) paramArray . push ( 'null' )
341355
342356 param . type = paramArray . flat ( ) . join ( ' or ' )
343357 param . description = param . description || ''
0 commit comments