commit 76332f851ec57d9fda0b7c690639c7be786f922a
parent 7858b006876bb6e3dd36fdd48effbe2612bf84ca
Author: yao-msft <50888816+yao-msft@users.noreply.github.com>
Date: Fri, 13 Jan 2023 17:58:07 -0800
Add rest interface 1.4 to supported list (#2853)
Diffstat:
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/AppInstallerCLITests/RestClient.cpp b/src/AppInstallerCLITests/RestClient.cpp
@@ -49,7 +49,8 @@ TEST_CASE("GetSupportedInterface", "[RestSource]")
Version version{ "1.0.0" };
REQUIRE(RestClient::GetSupportedInterface(utility::conversions::to_utf8string(TestRestUri), {}, info, version)->GetVersion() == version);
- Version invalid{ "1.2.0" };
+ // Update this test to next version so that we don't forget to add to supported versions before rest e2e tests are available.
+ Version invalid{ "1.5.0" };
REQUIRE_THROWS(RestClient::GetSupportedInterface(utility::conversions::to_utf8string(TestRestUri), {}, info, invalid));
}
diff --git a/src/AppInstallerRepositoryCore/Rest/RestClient.cpp b/src/AppInstallerRepositoryCore/Rest/RestClient.cpp
@@ -4,6 +4,7 @@
#include "RestClient.h"
#include "Rest/Schema/1_0/Interface.h"
#include "Rest/Schema/1_1/Interface.h"
+#include "Rest/Schema/1_4/Interface.h"
#include "Rest/Schema/HttpClientHelper.h"
#include <winget/JsonUtil.h>
#include "Rest/Schema/InformationResponseDeserializer.h"
@@ -17,7 +18,7 @@ using namespace AppInstaller::Utility;
namespace AppInstaller::Repository::Rest
{
// Supported versions
- std::set<Version> WingetSupportedContracts = { Version_1_0_0, Version_1_1_0 };
+ std::set<Version> WingetSupportedContracts = { Version_1_0_0, Version_1_1_0, Version_1_4_0 };
constexpr std::string_view WindowsPackageManagerHeader = "Windows-Package-Manager"sv;
constexpr size_t WindowsPackageManagerHeaderMaxLength = 1024;
@@ -130,6 +131,10 @@ namespace AppInstaller::Repository::Rest
{
return std::make_unique<Schema::V1_1::Interface>(api, information, additionalHeaders);
}
+ else if (version == Version_1_4_0)
+ {
+ return std::make_unique<Schema::V1_4::Interface>(api, information, additionalHeaders);
+ }
THROW_HR(APPINSTALLER_CLI_ERROR_RESTSOURCE_INVALID_VERSION);
}