Skip to content

Commit

Permalink
Update anyof swagger extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Groxan committed Jul 11, 2022
1 parent a46d5ef commit 3b3da66
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions Tzkt.Api/Swagger/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using NSwag;
using NSwag.Generation.Processors;
using NSwag.Generation.Processors.Contexts;

Expand All @@ -17,18 +16,9 @@ public bool Process(OperationProcessorContext context)
var extensionData = param.Schema.OneOf.First().Reference.ExtensionData;
if (extensionData != null)
{
if (param.ExtensionData == null)
{
param.ExtensionData = new Dictionary<string, object>();
}

param.ExtensionData ??= new Dictionary<string, object>();
foreach (var item in extensionData)
{
if (!param.ExtensionData.ContainsKey(item.Key))
{
param.ExtensionData.Add(item.Key, item.Value);
}
}
param.ExtensionData.TryAdd(item.Key, item.Value);
}
}
}
Expand All @@ -40,9 +30,7 @@ public class AnyOfExtensionProcessor : IOperationProcessor
{
private string OperationId { get; }
private string AnyOfValues { get; }
private const string ExtensionKey = "x-tzkt-extension";
private const string AnyOfName = "anyof";
private const string AnyOfExtension = "anyof-parameter";
private const string AnyOfExtensionKey = "x-tzkt-anyof-parameter";

public AnyOfExtensionProcessor(string operationId, string anyOfValues)
Expand All @@ -59,12 +47,7 @@ public bool Process(OperationProcessorContext context)
{
if (param.Name == AnyOfName)
{
if (param.ExtensionData == null)
{
param.ExtensionData = new Dictionary<string, object>();
}

param.ExtensionData.Add(ExtensionKey, AnyOfExtension);
param.ExtensionData ??= new Dictionary<string, object>();
param.ExtensionData.Add(AnyOfExtensionKey, AnyOfValues);
}
}
Expand Down

0 comments on commit 3b3da66

Please sign in to comment.