Skip to content

Commit

Permalink
fix: nullable array elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael M committed Oct 27, 2023
1 parent d48c23a commit fa02a49
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/ng-openapi-gen/src/lib/utils/open-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ export function tsTypeVal(

// An array
if (type === 'array' || schema.items) {
return `Array<${tsTypeVal(schema.items || {}, openApi, options, imports, container)}>`;
const items = schema.items || {};
let itemsType = tsTypeVal(items, openApi, options, imports, container);
if ((items as unknown)['nullable'] && !itemsType.includes(' | null')) {
itemsType += ' | null';
}
return `Array<${itemsType}>`;
}

// All the types
Expand Down

0 comments on commit fa02a49

Please sign in to comment.