2
0
mirror of synced 2025-02-13 08:56:30 +00:00

compiletime checking of all map calls

This commit is contained in:
Ben 2024-03-26 15:12:28 +01:00
parent e72c1b037c
commit d9d8441b6e
No known key found for this signature in database
GPG Key ID: 541B9D8C9F1426A1
3 changed files with 9 additions and 15 deletions

View File

@ -9,7 +9,7 @@ namespace CodexPlugin
public class ApiChecker public class ApiChecker
{ {
// <INSERT-OPENAPI-YAML-HASH> // <INSERT-OPENAPI-YAML-HASH>
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 OpenApiFilePath = "/codex/openapi.yaml";
private const string DisableEnvironmentVariable = "CODEXPLUGIN_DISABLE_APICHECK"; private const string DisableEnvironmentVariable = "CODEXPLUGIN_DISABLE_APICHECK";

View File

@ -27,7 +27,7 @@ namespace CodexPlugin
public DebugInfo GetDebugInfo() public DebugInfo GetDebugInfo()
{ {
return Map(OnCodex(api => api.GetDebugInfoAsync())); return mapper.Map(OnCodex(api => api.GetDebugInfoAsync()));
} }
public DebugPeer GetDebugPeer(string peerId) public DebugPeer GetDebugPeer(string peerId)
@ -72,25 +72,25 @@ namespace CodexPlugin
public LocalDatasetList LocalFiles() public LocalDatasetList LocalFiles()
{ {
return Map(OnCodex(api => api.ListDataAsync())); return mapper.Map(OnCodex(api => api.ListDataAsync()));
} }
public StorageAvailability SalesAvailability(StorageAvailability request) public StorageAvailability SalesAvailability(StorageAvailability request)
{ {
var body = Map(request); var body = mapper.Map(request);
var read = OnCodex<SalesAvailabilityREAD>(api => api.OfferStorageAsync(body)); var read = OnCodex<SalesAvailabilityREAD>(api => api.OfferStorageAsync(body));
return Map(read); return mapper.Map(read);
} }
public string RequestStorage(StoragePurchaseRequest request) public string RequestStorage(StoragePurchaseRequest request)
{ {
var body = Map(request); var body = mapper.Map(request);
return OnCodex<string>(api => api.CreateStorageRequestAsync(request.ContentId.Id, body)); return OnCodex<string>(api => api.CreateStorageRequestAsync(request.ContentId.Id, body));
} }
public StoragePurchase GetPurchaseStatus(string purchaseId) public StoragePurchase GetPurchaseStatus(string purchaseId)
{ {
return Map(OnCodex(api => api.GetPurchaseAsync(purchaseId))); return mapper.Map(OnCodex(api => api.GetPurchaseAsync(purchaseId)));
} }
public string GetName() public string GetName()
@ -104,11 +104,6 @@ namespace CodexPlugin
return workflow.GetPodInfo(Container); return workflow.GetPodInfo(Container);
} }
private dynamic Map(dynamic input)
{
return mapper.Map(input);
}
private T OnCodex<T>(Func<CodexApi, Task<T>> action) private T OnCodex<T>(Func<CodexApi, Task<T>> action)
{ {
var address = GetAddress(); var address = GetAddress();

View File

@ -357,9 +357,8 @@ paths:
content: content:
application/json: application/json:
schema: schema:
type: array
items:
$ref: "#/components/schemas/DataList" $ref: "#/components/schemas/DataList"
"400": "400":
description: Invalid CID is specified description: Invalid CID is specified
"404": "404":