Skip to content

Commit 5a08ed0

Browse files
committed
XML comments added
Schema set Any page controllers exclude
1 parent 978bf65 commit 5a08ed0

File tree

7 files changed

+85
-15
lines changed

7 files changed

+85
-15
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Simplify.Web.Postman.Models
44
{
55
/// <summary>
6-
/// Provides postman collection header
6+
/// Provides Postman collection header model
77
/// </summary>
88
public class CollectionHeader
99
{
@@ -14,5 +14,13 @@ public class CollectionHeader
1414
/// The name.
1515
/// </value>
1616
public string Name { get; set; }
17+
18+
/// <summary>
19+
/// Gets or sets the schema.
20+
/// </summary>
21+
/// <value>
22+
/// The schema.
23+
/// </value>
24+
public string Schema { get; set; } = "https://schema.getpostman.com/json/collection/v2.1.0/collection.json";
1725
}
1826
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,25 @@
22

33
namespace Simplify.Web.Postman.Models
44
{
5+
/// <summary>
6+
/// Provides Postman collection item model
7+
/// </summary>
58
public class CollectionItem
69
{
10+
/// <summary>
11+
/// Gets or sets the name.
12+
/// </summary>
13+
/// <value>
14+
/// The name.
15+
/// </value>
716
public string Name { get; set; }
817

18+
/// <summary>
19+
/// Gets or sets the request.
20+
/// </summary>
21+
/// <value>
22+
/// The request.
23+
/// </value>
924
public Request Request { get; set; }
1025
}
1126
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Simplify.Web.Postman.Models
77
{
88
/// <summary>
9-
/// Provides postman collection model
9+
/// Provides Postman collection model
1010
/// </summary>
1111
public class CollectionModel
1212
{
@@ -19,6 +19,12 @@ public class CollectionModel
1919
[JsonPropertyName("info")]
2020
public CollectionHeader Header { get; set; }
2121

22+
/// <summary>
23+
/// Gets or sets the items.
24+
/// </summary>
25+
/// <value>
26+
/// The items.
27+
/// </value>
2228
[JsonPropertyName("item")]
2329
public IList<CollectionItem> Items { get; set; } = new List<CollectionItem>();
2430
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,25 @@
22

33
namespace Simplify.Web.Postman.Models
44
{
5+
/// <summary>
6+
/// Provides request model
7+
/// </summary>
58
public class Request
69
{
10+
/// <summary>
11+
/// Gets or sets the method.
12+
/// </summary>
13+
/// <value>
14+
/// The method.
15+
/// </value>
716
public string Method { get; set; }
817

18+
/// <summary>
19+
/// Gets or sets the URL.
20+
/// </summary>
21+
/// <value>
22+
/// The URL.
23+
/// </value>
924
public Url Url { get; set; }
1025
}
1126
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22

33
namespace Simplify.Web.Postman.Models
44
{
5+
/// <summary>
6+
/// Provides URL model
7+
/// </summary>
58
public class Url
69
{
10+
/// <summary>
11+
/// Gets or sets the raw.
12+
/// </summary>
13+
/// <value>
14+
/// The raw.
15+
/// </value>
716
public string Raw { get; set; }
817
}
918
}

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,31 @@
33

44
namespace Simplify.Web.Postman.PartBuilders
55
{
6+
/// <summary>
7+
/// Provides CollectionHeader builder
8+
/// </summary>
9+
/// <seealso cref="ICollectionPartBuilder" />
610
public class CollectionHeaderBuilder : ICollectionPartBuilder
711
{
812
private readonly IPostmanGenerationSettings _settings;
913

14+
/// <summary>
15+
/// Initializes a new instance of the <see cref="CollectionHeaderBuilder"/> class.
16+
/// </summary>
17+
/// <param name="settings">The settings.</param>
1018
public CollectionHeaderBuilder(IPostmanGenerationSettings settings)
1119
{
1220
_settings = settings;
1321
}
1422

15-
public void Build(CollectionModel model)
16-
{
23+
/// <summary>
24+
/// Builds the specified model part.
25+
/// </summary>
26+
/// <param name="model">The model.</param>
27+
public void Build(CollectionModel model) =>
1728
model.Header = new CollectionHeader
1829
{
1930
Name = _settings.CollectionName
2031
};
21-
}
2232
}
2333
}
Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1-
using System.Linq;
1+
using System.Collections.Generic;
22
using Simplify.Web.Meta;
33
using Simplify.Web.Postman.Models;
44

55
namespace Simplify.Web.Postman.PartBuilders
66
{
7+
/// <summary>
8+
/// Provides CollectionItems builder
9+
/// </summary>
10+
/// <seealso cref="ICollectionPartBuilder" />
711
public class CollectionItemsBuilder : ICollectionPartBuilder
812
{
13+
/// <summary>
14+
/// Builds the specified model part.
15+
/// </summary>
16+
/// <param name="model">The model.</param>
917
public void Build(CollectionModel model)
1018
{
1119
foreach (var item in ControllersMetaStore.Current.ControllersMetaData)
1220
{
13-
model.Items.Add(BuildCollectionItem(item));
21+
// Skip any route controllers
22+
if (item.ExecParameters == null)
23+
continue;
24+
25+
foreach (var route in item.ExecParameters!.Routes)
26+
model.Items.Add(BuildCollectionItem(item, route));
1427
}
1528
}
1629

17-
private static CollectionItem BuildCollectionItem(IControllerMetaData metaData)
18-
{
19-
var route = metaData.ExecParameters.Routes.FirstOrDefault();
20-
21-
var item = new CollectionItem
30+
private static CollectionItem BuildCollectionItem(IControllerMetaData metaData, KeyValuePair<HttpMethod, string> route) =>
31+
new()
2232
{
2333
Name = metaData.ControllerType.Name,
2434
Request = new Request
@@ -30,8 +40,5 @@ private static CollectionItem BuildCollectionItem(IControllerMetaData metaData)
3040
Method = route.Key.ToString().ToUpper()
3141
}
3242
};
33-
34-
return item;
35-
}
3643
}
3744
}

0 commit comments

Comments
 (0)