Skip to content

Commit 639a219

Browse files
committed
Fixed swagger docs
1 parent 1ed0d36 commit 639a219

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/Exceptionless.Api/Extensions/SwaggerExtensions.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,25 @@ public void Apply(SwaggerDocument doc, DocumentFilterContext context) {
4444
var key = item.Key.Replace("v{apiVersion}", doc.Info.Version);
4545
var toAdd = item.Value;
4646

47+
var operations = typeof(PathItem)
48+
.GetProperties()
49+
.Where(p => p.PropertyType == typeof(Operation))
50+
.ToDictionary(p => p, p => (Operation)p.GetValue(toAdd))
51+
.Where(kvp => kvp.Value != null)
52+
.ToList();
53+
54+
operations.ForEach(o => o.Value.OperationId = o.Value.OperationId.Replace("V{apiVersion", doc.Info.Version.ToUpper()));
55+
4756
if (!doc.Paths.ContainsKey(key)) {
4857
doc.Paths[key] = toAdd;
4958
continue;
5059
}
5160

52-
Operation UpsertOperation(string v, Operation existingOp, Operation newOp) {
53-
if (existingOp != null && newOp != null)
61+
Operation UpsertOperation(string v, Operation existing, Operation current) {
62+
if (existing != null && current != null)
5463
throw new InvalidOperationException($"Two operations with the same path ({key}) and verb ({v}) is not supported.");
55-
return existingOp ?? newOp;
64+
65+
return existing ?? current;
5666
}
5767

5868
var toUpdate = doc.Paths[key];

0 commit comments

Comments
 (0)