Skip to content

Commit

Permalink
fix: Improve array handling not fully functional (misses item type) a…
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsharvey committed Aug 4, 2024
1 parent 9d03494 commit deecf7b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/zod-nestjs/src/lib/create-zod-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export type ZodDtoStatic<T extends CompatibleZodType = CompatibleZodType> = {
// Used for transforming the SchemaObject in _OPENAPI_METADATA_FACTORY
type SchemaObjectForMetadataFactory = Omit<SchemaObject30, 'required'> & {
required: boolean | string[];
isArray?: boolean;
};

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

0 comments on commit deecf7b

Please sign in to comment.