Skip to content

Commit

Permalink
fix: nullable array elements (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael M authored Oct 27, 2023
2 parents 2f52a86 + fa02a49 commit 16b2491
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 16b2491

Please sign in to comment.