Skip to content

Commit 913d1ae

Browse files
Merge pull request #216 from danielsharvey/bugfix/nestjs-array-handling
fix: Improve array handling not fully functional (misses item type) #215
2 parents 8d4fa35 + deecf7b commit 913d1ae

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/zod-nestjs/src/lib/create-zod-dto.ts

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export type ZodDtoStatic<T extends CompatibleZodType = CompatibleZodType> = {
6161
// Used for transforming the SchemaObject in _OPENAPI_METADATA_FACTORY
6262
type SchemaObjectForMetadataFactory = Omit<SchemaObject30, 'required'> & {
6363
required: boolean | string[];
64+
isArray?: boolean;
6465
};
6566

6667
export const createZodDto = <T extends OpenApiZodAny>(
@@ -148,6 +149,10 @@ export const createZodDto = <T extends OpenApiZodAny>(
148149
convertedSchemaObject.type = 'string'; // There ist no explicit null value in OpenAPI 3.0
149150
convertedSchemaObject.nullable = true;
150151
}
152+
// Array handling (NestJS references 'isArray' boolean)
153+
if (convertedSchemaObject.type === 'array') {
154+
convertedSchemaObject.isArray = true;
155+
}
151156
// Exclusive minimum and maximum
152157
const { exclusiveMinimum, exclusiveMaximum } = schemaObject;
153158
if (exclusiveMinimum !== undefined) {

0 commit comments

Comments
 (0)