Skip to content

Commit c18b0fd

Browse files
authored
Merge pull request #39 from Aleksandr-Khvalov/master
Fix exception when generating Postman collection for request bodies containing a property of type IList<string>
2 parents 6624b05 + 6be34dd commit c18b0fd

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
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

src/Simplify.Web.Postman/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [2.1] - Unreleased
4+
5+
### Fixed
6+
7+
- Exception when generating Postman collections for controller request bodies containing `IList<string>` properties.
8+
39
## [2.0] - 2024-06-05
410

511
### Dependencies

src/Simplify.Web.Postman/Simplify.Web.Postman.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
99
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1010

11-
<Version>2.0</Version>
11+
<Version>2.1-pre01</Version>
1212

1313
<Description>Postman collection and environment generation extension for Simplify.Web</Description>
1414
<Product>Simplify</Product>

0 commit comments

Comments
 (0)