Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema support for std::unordered_set #6634

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added

- Added a `ccf::any_cert_auth_policy` (C++), or `any_cert` (JS/TS), implementing TLS client certificate authentication, but without checking for the presence of the certificate in the governance user or member tables. This enables applications wanting to do so to perform user management in application space, using application tables (#6608).
- Added OpenAPI support for `std::unordered_set`.

## [6.0.0-dev5]

Expand Down
8 changes: 6 additions & 2 deletions include/ccf/ds/json_schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <fmt/format.h>
#include <nlohmann/json.hpp>
#include <set>
#include <unordered_set>

namespace ccf::ds
{
Expand Down Expand Up @@ -113,7 +114,9 @@ namespace ccf::ds
return fmt::format("{}_array", schema_name<typename T::value_type>());
}
}
else if constexpr (ccf::nonstd::is_specialization<T, std::set>::value)
else if constexpr (
ccf::nonstd::is_specialization<T, std::set>::value ||
ccf::nonstd::is_specialization<T, std::unordered_set>::value)
{
return fmt::format("{}_set", schema_name<typename T::value_type>());
}
Expand Down Expand Up @@ -204,7 +207,8 @@ namespace ccf::ds
}
else if constexpr (
ccf::nonstd::is_specialization<T, std::vector>::value ||
ccf::nonstd::is_specialization<T, std::set>::value)
ccf::nonstd::is_specialization<T, std::set>::value ||
ccf::nonstd::is_specialization<T, std::unordered_set>::value)
{
if constexpr (std::is_same<T, std::vector<uint8_t>>::value)
{
Expand Down
4 changes: 3 additions & 1 deletion include/ccf/ds/openapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <regex>
#include <set>
#include <string_view>
#include <unordered_set>

namespace ccf::ds
{
Expand Down Expand Up @@ -281,7 +282,8 @@ namespace ccf::ds
}
else if constexpr (
ccf::nonstd::is_specialization<T, std::vector>::value ||
ccf::nonstd::is_specialization<T, std::set>::value)
ccf::nonstd::is_specialization<T, std::set>::value ||
ccf::nonstd::is_specialization<T, std::unordered_set>::value)
{
if constexpr (std::is_same<T, std::vector<uint8_t>>::value)
{
Expand Down
2 changes: 2 additions & 0 deletions src/ds/test/openapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ TEST_CASE("Complex custom types")
doc, "/app/complex", HTTP_POST);
openapi::add_response_schema<std::map<Baz, std::vector<Buzz>>>(
doc, "/app/complex", HTTP_POST, HTTP_STATUS_OK);
openapi::add_response_schema<std::unordered_set<Baz>>(
doc, "/app/complex", HTTP_POST, HTTP_STATUS_OK);

required_doc_elements(doc);
}
Expand Down