Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improve array handling not fully functional (misses item type) #215 #216

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading