Skip to content

Commit

Permalink
Merge pull request #3169 from nestjs/fix/expose-self-required-3163
Browse files Browse the repository at this point in the history
fix: expose self required attribute for objects
  • Loading branch information
kamilmysliwiec authored Nov 15, 2024
2 parents eadd76b + 353f5fd commit bbd3380
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions e2e/api-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,7 @@
"createdAt",
"urls",
"_options",
"rawDefinition",
"enum",
"enumArr",
"enumWithRef",
Expand Down
3 changes: 2 additions & 1 deletion e2e/src/cats/classes/cat.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export class Cat {
example: 400
}
},
required: ['name', 'status']
required: ['name', 'status'],
selfRequired: true
})
rawDefinition?: Record<string, any>;

Expand Down
10 changes: 9 additions & 1 deletion lib/interfaces/schema-object-metadata.interface.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Type } from '@nestjs/common';
import { EnumSchemaAttributes } from './enum-schema-attributes.interface';
import { SchemaObject } from './open-api-spec.interface';
import { ReferenceObject, SchemaObject } from './open-api-spec.interface';

export type EnumAllowedTypes =
| any[]
Expand Down Expand Up @@ -38,4 +38,12 @@ export type SchemaObjectMetadata =
type: 'object';
properties: Record<string, SchemaObjectMetadata>;
required?: string[];
selfRequired?: boolean;
} & SchemaObjectCommonMetadata)
| ({
type: 'object';
properties?: Record<string, SchemaObjectMetadata>;
additionalProperties: SchemaObject | ReferenceObject | boolean;
required?: string[];
selfRequired?: boolean;
} & SchemaObjectCommonMetadata);

0 comments on commit bbd3380

Please sign in to comment.