Skip to content

Commit b867b0a

Browse files
authored
Merge pull request #390 from stephen-moyer/master
Fix imports when type is an array with 'array' type
2 parents ee7f654 + 334e7e1 commit b867b0a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/openapi-typings.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,20 @@ export function isReferenceObject(obj: any): obj is ReferenceObject {
3535
* Type guard to check if a schema is an ArraySchemaObject
3636
*/
3737
export function isArraySchemaObject(obj: SchemaObject): obj is ArraySchemaObject {
38-
return 'type' in obj && obj.type === 'array' && 'items' in obj;
38+
if (!('type' in obj)) {
39+
return false;
40+
}
41+
if (!('items' in obj)) {
42+
return false;
43+
}
44+
if (obj.type === 'array') {
45+
return true;
46+
}
47+
// OpenAPI 3.1 allows 'type' to be an array of types, so we need to check if it includes 'array'
48+
if (Array.isArray(obj.type) && obj.type.includes('array')) {
49+
return true;
50+
}
51+
return false;
3952
}
4053

4154
/**

0 commit comments

Comments
 (0)