File tree Expand file tree Collapse file tree 7 files changed +85
-15
lines changed Expand file tree Collapse file tree 7 files changed +85
-15
lines changed Original file line number Diff line number Diff line change 33namespace 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}
Original file line number Diff line number Diff line change 22
33namespace 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}
Original file line number Diff line number Diff line change 66namespace 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 }
Original file line number Diff line number Diff line change 22
33namespace 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}
Original file line number Diff line number Diff line change 22
33namespace 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}
Original file line number Diff line number Diff line change 33
44namespace 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}
Original file line number Diff line number Diff line change 1- using System . Linq ;
1+ using System . Collections . Generic ;
22using Simplify . Web . Meta ;
33using Simplify . Web . Postman . Models ;
44
55namespace 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}
You can’t perform that action at this time.
0 commit comments