File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
33using Microsoft . OpenApi . Models ;
4+ using Simplify . Web . Routing ;
45
56namespace Simplify . Web . Swagger
67{
@@ -31,6 +32,11 @@ public string Path
3132 set => _path = value ;
3233 }
3334
35+ /// <summary>
36+ /// Controller parsed path
37+ /// </summary>
38+ public IControllerPath ParsedPath => new ControllerPathParser ( ) . Parse ( Path ) ;
39+
3440 /// <summary>
3541 /// Controller names
3642 /// </summary>
Original file line number Diff line number Diff line change 11using System . Collections . Generic ;
22using System . Linq ;
33using Microsoft . OpenApi . Models ;
4+ using Simplify . Web . Routing ;
45using Swashbuckle . AspNetCore . SwaggerGen ;
56
67namespace Simplify . Web . Swagger
@@ -52,6 +53,8 @@ private static OpenApiOperation CreateOperation(ControllerAction item)
5253 if ( item . IsAuthorizationRequired )
5354 AddSecurity ( operation ) ;
5455
56+ operation . Parameters = CreateParameters ( item . ParsedPath ) ;
57+
5558 return operation ;
5659 }
5760
@@ -68,5 +71,16 @@ private static void AddSecurity(OpenApiOperation operation) =>
6871 } , new List < string > ( )
6972 }
7073 } ) ;
74+
75+ private static IList < OpenApiParameter > CreateParameters ( IControllerPath path ) =>
76+ path . Items
77+ . Where ( x => x is PathParameter )
78+ . Cast < PathParameter > ( )
79+ . Select ( x => new OpenApiParameter
80+ {
81+ Name = x . Name ,
82+ In = ParameterLocation . Path ,
83+ AllowEmptyValue = false
84+ } ) . ToList ( ) ;
7185 }
7286}
You can’t perform that action at this time.
0 commit comments