Skip to content

Commit 3b759f2

Browse files
committed
fix(generator): update with new generator
1 parent 96121b7 commit 3b759f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+259
-139
lines changed

src/CSharpSDK/DragonflySchema.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFrameworks>netstandard2.0</TargetFrameworks>
55
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
6-
<Version>1.1501.0</Version>
6+
<Version>1.1501.3</Version>
77
<Authors>Ladybug Tools</Authors>
88
<Description>This is the .Net version of Dragonfly Schema</Description>
99
<Copyright>Copyright © 2025 Ladybug Tools LLC</Copyright>

src/CSharpSDK/Model/OpenAPIGenBaseModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace DragonflySchema
2424
[Summary(@"")]
2525
[System.Serializable]
2626
[DataContract(Name = "_OpenAPIGenBaseModel")]
27-
public partial class OpenAPIGenBaseModel : System.IEquatable<OpenAPIGenBaseModel>
27+
public abstract partial class OpenAPIGenBaseModel : System.IEquatable<OpenAPIGenBaseModel>
2828
{
2929
/// <summary>
3030
/// Initializes a new instance of the <see cref="OpenAPIGenBaseModel" /> class.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { plainToInstance } from "class-transformer";
2+
3+
export function deepTransform<T extends object>(cls: new () => T, plain: any): T {
4+
// Use a try-catch block for abstract classes
5+
let instance: T;
6+
try {
7+
instance = plainToInstance(cls, plain, { enableImplicitConversion: true, exposeUnsetFields: false, exposeDefaultValues: true });
8+
} catch (e) {
9+
// If cls is abstract, create a plain object with the same properties
10+
instance = plain as T;
11+
}
12+
13+
for (const key of Object.keys(instance)) {
14+
const value = (instance as any)[key];
15+
16+
// If the value is a plain object and the class has a type hint
17+
const metadataType = Reflect.getMetadata('design:type', instance, key);
18+
19+
if (
20+
value &&
21+
typeof value === 'object' &&
22+
metadataType &&
23+
typeof metadataType === 'function' &&
24+
metadataType !== Object &&
25+
!(value instanceof metadataType)
26+
) {
27+
(instance as any)[key] = deepTransform(metadataType, value);
28+
}
29+
}
30+
31+
return instance;
32+
}

src/TypeScriptSDK/src/models/Building.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { IsInstance, ValidateNested, IsDefined, IsString, IsOptional, Matches, IsArray, validate, ValidationError as TsValidationError } from 'class-validator';
2-
import { Type, plainToClass, instanceToPlain, Expose, Transform } from 'class-transformer';
2+
import { Type, instanceToPlain, Expose, Transform } from 'class-transformer';
3+
import { deepTransform } from '../deepTransform';
34
import { BuildingPropertiesAbridged } from "./BuildingPropertiesAbridged";
45
import { IDdBaseModel } from "honeybee-schema";
56
import { RoofSpecification } from "./RoofSpecification";
@@ -57,14 +58,17 @@ export class Building extends IDdBaseModel {
5758

5859

5960
override init(_data?: any) {
60-
super.init(_data);
61+
6162
if (_data) {
62-
const obj = plainToClass(Building, _data, { enableImplicitConversion: true, exposeUnsetFields: false, exposeDefaultValues: true });
63+
const obj = deepTransform(Building, _data);
6364
this.properties = obj.properties;
6465
this.type = obj.type ?? "Building";
6566
this.uniqueStories = obj.uniqueStories;
6667
this.room3ds = obj.room3ds;
6768
this.roof = obj.roof;
69+
this.identifier = obj.identifier;
70+
this.displayName = obj.displayName;
71+
this.userData = obj.userData;
6872
}
6973
}
7074

src/TypeScriptSDK/src/models/BuildingEnergyPropertiesAbridged.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { IsString, IsOptional, Matches, MinLength, MaxLength, validate, ValidationError as TsValidationError } from 'class-validator';
2-
import { Type, plainToClass, instanceToPlain, Expose, Transform } from 'class-transformer';
2+
import { Type, instanceToPlain, Expose, Transform } from 'class-transformer';
3+
import { deepTransform } from '../deepTransform';
34
import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
45

56
/** Base class for all objects that are not extensible with additional keys.\n\nThis effectively includes all objects except for the Properties classes\nthat are assigned to geometry objects. */
@@ -43,9 +44,9 @@ export class BuildingEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
4344

4445

4546
override init(_data?: any) {
46-
super.init(_data);
47+
4748
if (_data) {
48-
const obj = plainToClass(BuildingEnergyPropertiesAbridged, _data, { enableImplicitConversion: true, exposeUnsetFields: false, exposeDefaultValues: true });
49+
const obj = deepTransform(BuildingEnergyPropertiesAbridged, _data);
4950
this.type = obj.type ?? "BuildingEnergyPropertiesAbridged";
5051
this.constructionSet = obj.constructionSet;
5152
this.ceilingPlenumConstruction = obj.ceilingPlenumConstruction;

src/TypeScriptSDK/src/models/BuildingPropertiesAbridged.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { IsString, IsOptional, Matches, IsInstance, ValidateNested, validate, ValidationError as TsValidationError } from 'class-validator';
2-
import { Type, plainToClass, instanceToPlain, Expose, Transform } from 'class-transformer';
2+
import { Type, instanceToPlain, Expose, Transform } from 'class-transformer';
3+
import { deepTransform } from '../deepTransform';
34
import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
45
import { BuildingEnergyPropertiesAbridged } from "./BuildingEnergyPropertiesAbridged";
56
import { BuildingRadiancePropertiesAbridged } from "./BuildingRadiancePropertiesAbridged";
@@ -36,9 +37,9 @@ export class BuildingPropertiesAbridged extends _OpenAPIGenBaseModel {
3637

3738

3839
override init(_data?: any) {
39-
super.init(_data);
40+
4041
if (_data) {
41-
const obj = plainToClass(BuildingPropertiesAbridged, _data, { enableImplicitConversion: true, exposeUnsetFields: false, exposeDefaultValues: true });
42+
const obj = deepTransform(BuildingPropertiesAbridged, _data);
4243
this.type = obj.type ?? "BuildingPropertiesAbridged";
4344
this.energy = obj.energy;
4445
this.radiance = obj.radiance;

src/TypeScriptSDK/src/models/BuildingRadiancePropertiesAbridged.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { IsString, IsOptional, Matches, validate, ValidationError as TsValidationError } from 'class-validator';
2-
import { Type, plainToClass, instanceToPlain, Expose, Transform } from 'class-transformer';
2+
import { Type, instanceToPlain, Expose, Transform } from 'class-transformer';
3+
import { deepTransform } from '../deepTransform';
34
import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
45

56
/** Base class for all objects that are not extensible with additional keys.\n\nThis effectively includes all objects except for the Properties classes\nthat are assigned to geometry objects. */
@@ -25,9 +26,9 @@ export class BuildingRadiancePropertiesAbridged extends _OpenAPIGenBaseModel {
2526

2627

2728
override init(_data?: any) {
28-
super.init(_data);
29+
2930
if (_data) {
30-
const obj = plainToClass(BuildingRadiancePropertiesAbridged, _data, { enableImplicitConversion: true, exposeUnsetFields: false, exposeDefaultValues: true });
31+
const obj = deepTransform(BuildingRadiancePropertiesAbridged, _data);
3132
this.type = obj.type ?? "BuildingRadiancePropertiesAbridged";
3233
this.modifierSet = obj.modifierSet;
3334
}

src/TypeScriptSDK/src/models/ContextShade.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { IsArray, IsDefined, IsInstance, ValidateNested, IsString, IsOptional, Matches, IsBoolean, validate, ValidationError as TsValidationError } from 'class-validator';
2-
import { Type, plainToClass, instanceToPlain, Expose, Transform } from 'class-transformer';
2+
import { Type, instanceToPlain, Expose, Transform } from 'class-transformer';
3+
import { deepTransform } from '../deepTransform';
34
import { ContextShadePropertiesAbridged } from "./ContextShadePropertiesAbridged";
45
import { Face3D } from "honeybee-schema";
56
import { IDdBaseModel } from "honeybee-schema";
@@ -48,13 +49,16 @@ export class ContextShade extends IDdBaseModel {
4849

4950

5051
override init(_data?: any) {
51-
super.init(_data);
52+
5253
if (_data) {
53-
const obj = plainToClass(ContextShade, _data, { enableImplicitConversion: true, exposeUnsetFields: false, exposeDefaultValues: true });
54+
const obj = deepTransform(ContextShade, _data);
5455
this.geometry = obj.geometry;
5556
this.properties = obj.properties;
5657
this.type = obj.type ?? "ContextShade";
5758
this.isDetached = obj.isDetached ?? true;
59+
this.identifier = obj.identifier;
60+
this.displayName = obj.displayName;
61+
this.userData = obj.userData;
5862
}
5963
}
6064

src/TypeScriptSDK/src/models/ContextShadeEnergyPropertiesAbridged.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { IsString, IsOptional, Matches, MinLength, MaxLength, validate, ValidationError as TsValidationError } from 'class-validator';
2-
import { Type, plainToClass, instanceToPlain, Expose, Transform } from 'class-transformer';
2+
import { Type, instanceToPlain, Expose, Transform } from 'class-transformer';
3+
import { deepTransform } from '../deepTransform';
34
import { _OpenAPIGenBaseModel } from "./_OpenAPIGenBaseModel";
45

56
/** Base class for all objects that are not extensible with additional keys.\n\nThis effectively includes all objects except for the Properties classes\nthat are assigned to geometry objects. */
@@ -35,9 +36,9 @@ export class ContextShadeEnergyPropertiesAbridged extends _OpenAPIGenBaseModel {
3536

3637

3738
override init(_data?: any) {
38-
super.init(_data);
39+
3940
if (_data) {
40-
const obj = plainToClass(ContextShadeEnergyPropertiesAbridged, _data, { enableImplicitConversion: true, exposeUnsetFields: false, exposeDefaultValues: true });
41+
const obj = deepTransform(ContextShadeEnergyPropertiesAbridged, _data);
4142
this.type = obj.type ?? "ContextShadeEnergyPropertiesAbridged";
4243
this.construction = obj.construction;
4344
this.transmittanceSchedule = obj.transmittanceSchedule;

0 commit comments

Comments
 (0)