Skip to content

Commit 33337ae

Browse files
committed
[add] Host path generation
[add] Request path generation
1 parent af729bc commit 33337ae

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/Simplify.Web.Postman/Models/Url.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
#nullable disable
1+
using System.Collections.Generic;
2+
3+
#nullable disable
24

35
namespace Simplify.Web.Postman.Models
46
{
@@ -13,6 +15,14 @@ public class Url
1315
/// <value>
1416
/// The raw.
1517
/// </value>
16-
public string Raw { get; set; }
18+
public string Host { get; set; }
19+
20+
/// <summary>
21+
/// Gets or sets the path.
22+
/// </summary>
23+
/// <value>
24+
/// The path.
25+
/// </value>
26+
public IList<string> Path { get; set; }
1727
}
1828
}

src/Simplify.Web.Postman/PartBuilders/CollectionItemsBuilder.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System.Collections.Generic;
1+
using System.Collections;
2+
using System;
3+
using System.Linq;
4+
using System.Collections.Generic;
25
using Simplify.Web.Meta;
36
using Simplify.Web.Postman.Models;
47

@@ -10,6 +13,11 @@ namespace Simplify.Web.Postman.PartBuilders
1013
/// <seealso cref="ICollectionPartBuilder" />
1114
public class CollectionItemsBuilder : ICollectionPartBuilder
1215
{
16+
/// <summary>
17+
/// The base URL path.
18+
/// </summary>
19+
public const string BaseUrlPath = "{{BaseUrl}}";
20+
1321
/// <summary>
1422
/// Builds the specified model part.
1523
/// </summary>
@@ -35,10 +43,13 @@ private static CollectionItem BuildCollectionItem(IControllerMetaData metaData,
3543
{
3644
Url = new Url
3745
{
38-
Raw = route.Value
46+
Host = BaseUrlPath,
47+
Path = BuildPathItems(route.Value)
3948
},
4049
Method = route.Key.ToString().ToUpper()
4150
}
4251
};
52+
53+
private static IList<string> BuildPathItems(string controllerRoute) => controllerRoute.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).ToList();
4354
}
4455
}

0 commit comments

Comments
 (0)