Skip to content

Commit 4278bdf

Browse files
committed
[add] parameters list display
1 parent f427332 commit 4278bdf

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/Simplify.Web.Swagger/ControllerAction.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using Microsoft.OpenApi.Models;
4+
using Simplify.Web.Routing;
45

56
namespace 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>

src/Simplify.Web.Swagger/SimplifyWebDocumentFilter.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Generic;
22
using System.Linq;
33
using Microsoft.OpenApi.Models;
4+
using Simplify.Web.Routing;
45
using Swashbuckle.AspNetCore.SwaggerGen;
56

67
namespace 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
}

0 commit comments

Comments
 (0)