From d9d8441b6e31d46914c960305c37fea47c1a6a24 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 26 Mar 2024 15:12:28 +0100 Subject: [PATCH] compiletime checking of all map calls --- ProjectPlugins/CodexPlugin/ApiChecker.cs | 2 +- ProjectPlugins/CodexPlugin/CodexAccess.cs | 17 ++++++----------- ProjectPlugins/CodexPlugin/openapi.yaml | 5 ++--- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/ProjectPlugins/CodexPlugin/ApiChecker.cs b/ProjectPlugins/CodexPlugin/ApiChecker.cs index 5d71ad0..39fb22a 100644 --- a/ProjectPlugins/CodexPlugin/ApiChecker.cs +++ b/ProjectPlugins/CodexPlugin/ApiChecker.cs @@ -9,7 +9,7 @@ namespace CodexPlugin public class ApiChecker { // - private const string OpenApiYamlHash = "5E-B8-2A-E3-61-0C-D6-11-F7-F6-19-4C-F9-35-CA-8B-D1-FF-51-52-1E-E7-A3-7A-5D-0C-2A-3D-50-93-5E-55"; + private const string OpenApiYamlHash = "EB-31-10-0C-A5-B9-D2-4A-AD-2C-A7-BF-FD-70-BD-92-32-29-D7-FF-06-B0-52-46-8E-54-D5-EB-17-C8-DB-E3"; private const string OpenApiFilePath = "/codex/openapi.yaml"; private const string DisableEnvironmentVariable = "CODEXPLUGIN_DISABLE_APICHECK"; diff --git a/ProjectPlugins/CodexPlugin/CodexAccess.cs b/ProjectPlugins/CodexPlugin/CodexAccess.cs index 3759ae9..bd2582e 100644 --- a/ProjectPlugins/CodexPlugin/CodexAccess.cs +++ b/ProjectPlugins/CodexPlugin/CodexAccess.cs @@ -27,7 +27,7 @@ namespace CodexPlugin public DebugInfo GetDebugInfo() { - return Map(OnCodex(api => api.GetDebugInfoAsync())); + return mapper.Map(OnCodex(api => api.GetDebugInfoAsync())); } public DebugPeer GetDebugPeer(string peerId) @@ -72,25 +72,25 @@ namespace CodexPlugin public LocalDatasetList LocalFiles() { - return Map(OnCodex(api => api.ListDataAsync())); + return mapper.Map(OnCodex(api => api.ListDataAsync())); } public StorageAvailability SalesAvailability(StorageAvailability request) { - var body = Map(request); + var body = mapper.Map(request); var read = OnCodex(api => api.OfferStorageAsync(body)); - return Map(read); + return mapper.Map(read); } public string RequestStorage(StoragePurchaseRequest request) { - var body = Map(request); + var body = mapper.Map(request); return OnCodex(api => api.CreateStorageRequestAsync(request.ContentId.Id, body)); } public StoragePurchase GetPurchaseStatus(string purchaseId) { - return Map(OnCodex(api => api.GetPurchaseAsync(purchaseId))); + return mapper.Map(OnCodex(api => api.GetPurchaseAsync(purchaseId))); } public string GetName() @@ -104,11 +104,6 @@ namespace CodexPlugin return workflow.GetPodInfo(Container); } - private dynamic Map(dynamic input) - { - return mapper.Map(input); - } - private T OnCodex(Func> action) { var address = GetAddress(); diff --git a/ProjectPlugins/CodexPlugin/openapi.yaml b/ProjectPlugins/CodexPlugin/openapi.yaml index cfbc800..3a1ad70 100644 --- a/ProjectPlugins/CodexPlugin/openapi.yaml +++ b/ProjectPlugins/CodexPlugin/openapi.yaml @@ -357,9 +357,8 @@ paths: content: application/json: schema: - type: array - items: - $ref: "#/components/schemas/DataList" + $ref: "#/components/schemas/DataList" + "400": description: Invalid CID is specified "404":