Skip to content

Commit 0498c7c

Browse files
[#38] [fix] handle string type instantiation
1 parent e8e16ef commit 0498c7c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Simplify.Web.Postman/Assembly/Collection/PartBuilders/RequestBuilder.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ private static string BuildRequestJsonData(Type modelType)
8383

8484
private static object CreateObject(Type modelType)
8585
{
86+
if (modelType == typeof(string))
87+
return string.Empty;
88+
8689
if (IsGenericList(modelType))
8790
modelType = ConstructGenericListTypeFromGenericIList(modelType);
8891

@@ -113,7 +116,7 @@ private static void InitializeListsSingleEmptyValues(object model)
113116
var emptyListType = ConstructGenericListTypeFromGenericIList(propertyInfo.PropertyType);
114117

115118
var emptyList = Activator.CreateInstance(emptyListType);
116-
var emptyItem = Activator.CreateInstance(listObjectType);
119+
var emptyItem = CreateObject(listObjectType);
117120

118121
emptyListType.GetMethod("Add")!.Invoke(emptyList, [emptyItem]);
119122

0 commit comments

Comments
 (0)