Skip to content

Commit 145fa4a

Browse files
committed
Fix: Omit Nullable in JSON when undefined; preserve undefined in propertyValueToBoolean
1 parent 4098e84 commit 145fa4a

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

projects/angular-odata/schematics/apigen/metadata/csdl/csdl-structural-property.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ export abstract class CsdlStructuralProperty extends CsdlAnnotable {
2929
}
3030

3131
override toJson() {
32-
return {
32+
const json: { [key: string]: any } = {
3333
...super.toJson(),
3434
Name: this.Name,
3535
Type: this.Collection ? `Collection(${this.Type})` : this.Type,
3636
Nullable: this.Nullable,
37-
} as { [key: string]: any };
37+
};
38+
if (this.Nullable !== undefined) {
39+
json['Nullable'] = this.Nullable;
40+
}
41+
return json;
3842
}
3943

4044
isEdmType(): boolean {

projects/angular-odata/schematics/apigen/metadata/parser.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,9 @@ export class ODataMetadataParser {
592592
}
593593

594594
protected propertyValueToBoolean(attributeValue?: string) {
595-
return attributeValue !== undefined ? attributeValue === 'true' : false;
595+
return attributeValue !== undefined && attributeValue === 'true' ? true :
596+
attributeValue !== undefined && attributeValue === 'false' ? false :
597+
undefined;
596598
}
597599

598600
protected propertyValueToDate(attributeValue?: string) {

0 commit comments

Comments
 (0)