Skip to content

Commit

Permalink
Add rest interface 1.4 to supported list (#2853)
Browse files Browse the repository at this point in the history
  • Loading branch information
yao-msft authored Jan 14, 2023
1 parent 7858b00 commit 76332f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/AppInstallerCLITests/RestClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
7 changes: 6 additions & 1 deletion src/AppInstallerRepositoryCore/Rest/RestClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 76332f8

Please sign in to comment.