diff --git a/packages/openapi-ts/src/compiler/typedef.ts b/packages/openapi-ts/src/compiler/typedef.ts index 20fd4131c..5a8cc88b0 100644 --- a/packages/openapi-ts/src/compiler/typedef.ts +++ b/packages/openapi-ts/src/compiler/typedef.ts @@ -170,10 +170,11 @@ export const createTypeRecordNode = ( export const createTypeArrayNode = ( types: (any | ts.TypeNode)[], isNullable: boolean = false, + isUnique: boolean = false, ) => { const node = createTypeReferenceNode({ typeArguments: [createTypeUnionNode({ types })], - typeName: 'Array', + typeName: isUnique ? 'Set' : 'Array', }); return maybeNullable({ isNullable, node }); }; diff --git a/packages/openapi-ts/src/utils/type.ts b/packages/openapi-ts/src/utils/type.ts index 74fc159e1..3a4985858 100644 --- a/packages/openapi-ts/src/utils/type.ts +++ b/packages/openapi-ts/src/utils/type.ts @@ -79,10 +79,18 @@ const typeArray = (model: Model) => { return tuple; } - return compiler.typeArrayNode([toType(model.link)], model.isNullable); + return compiler.typeArrayNode( + [toType(model.link)], + model.isNullable, + model.uniqueItems, + ); } - return compiler.typeArrayNode([base(model)], model.isNullable); + return compiler.typeArrayNode( + [base(model)], + model.isNullable, + model.uniqueItems, + ); }; const typeEnum = (model: Model) => {