Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
sabudilovskiy committed Oct 17, 2023
1 parent 6614d06 commit 97aecbe
Show file tree
Hide file tree
Showing 47 changed files with 195 additions and 147 deletions.
10 changes: 10 additions & 0 deletions .gen/objs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ src/views/test-openapi-view/declarations.hpp
src/utils/type_holder.hpp
src/utils/tests_macros.hpp
src/utils/shared_transaction.hpp
src/utils/serialize/uuid/string.hpp
src/utils/serialize/uuid/string.cpp
src/utils/postgres_helper.hpp
src/utils/perform_common_errors.hpp
src/utils/perform_common_errors.cpp
Expand Down Expand Up @@ -32,6 +34,7 @@ src/utils/constexpr_optional.hpp
src/utils/component_list_fwd.hpp
src/utils/compilers_macros.hpp
src/utils/common_errors.hpp
src/openapi/types/uuid_type.hpp
src/openapi/types/string_type.hpp
src/openapi/types/optional_type.hpp
src/openapi/types/object_type.hpp
Expand All @@ -48,12 +51,14 @@ src/openapi/json/serialize/string_property.hpp
src/openapi/json/serialize/reflective.hpp
src/openapi/json/serialize/optional_property.hpp
src/openapi/json/serialize/object_property.hpp
src/openapi/json/serialize/base_property.hpp
src/openapi/json/serialize/array_property.hpp
src/openapi/json/serialize/all.hpp
src/openapi/json/parse/string_property.hpp
src/openapi/json/parse/reflective.hpp
src/openapi/json/parse/optional_property.hpp
src/openapi/json/parse/object_property.hpp
src/openapi/json/parse/base_property.hpp
src/openapi/json/parse/array_property.hpp
src/openapi/json/parse/all.hpp
src/openapi/json/all.hpp
Expand Down Expand Up @@ -83,6 +88,7 @@ src/openapi/from_tuple/property.hpp
src/openapi/from_tuple/optional.hpp
src/openapi/from_tuple/default.hpp
src/openapi/from_tuple/all.hpp
src/openapi/doc/serialize/uuid.hpp
src/openapi/doc/serialize/response.hpp
src/openapi/doc/serialize/request.hpp
src/openapi/doc/serialize/remove_requests.hpp
Expand All @@ -94,8 +100,11 @@ src/openapi/doc/serialize/body.hpp
src/openapi/doc/serialize/base.hpp
src/openapi/doc/serialize/array.hpp
src/openapi/doc/serialize/all.hpp
src/openapi/base/uuid_traits.hpp
src/openapi/base/uuid_property.hpp
src/openapi/base/string_traits.hpp
src/openapi/base/string_property.hpp
src/openapi/base/reflective_uuid_fix.hpp
src/openapi/base/reflective_utils.hpp
src/openapi/base/reflective_preferences.hpp
src/openapi/base/reflective_checks.hpp
Expand All @@ -108,6 +117,7 @@ src/openapi/base/object_property.hpp
src/openapi/base/object_field_names.hpp
src/openapi/base/named_traits.hpp
src/openapi/base/is_optional_property.hpp
src/openapi/base/holder.hpp
src/openapi/base/doc.hpp
src/openapi/base/array_traits.hpp
src/openapi/base/array_property.hpp
Expand Down
4 changes: 4 additions & 0 deletions .gen/unittest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ utests/remove_namespace.cpp
utests/openapi/raw/to_tuple.cpp
utests/openapi/raw/from_tuple.cpp
utests/openapi/raw/as_tuple.cpp
utests/openapi/json/serialize/uuid.cpp
utests/openapi/json/serialize/basic_string.cpp
utests/openapi/json/serialize/basic_optional.cpp
utests/openapi/json/serialize/basic_object.cpp
utests/openapi/json/serialize/basic_array.cpp
utests/openapi/json/parse/uuid.cpp
utests/openapi/json/parse/basic_string.cpp
utests/openapi/json/parse/basic_object.cpp
utests/openapi/json/parse/basic_array.cpp
utests/openapi/http/uuid_response.cpp
utests/openapi/http/uuid_request.cpp
utests/openapi/http/basic_http_response.cpp
utests/openapi/http/basic_http_request.cpp
utests/openapi/doc/serialize/basic_response.cpp
Expand Down
2 changes: 1 addition & 1 deletion service/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#include "legacy/views/teacher/request/approve/link/view.hpp"
#include "legacy/views/teacher/request/approve/new/view.hpp"
#include "legacy/views/teacher/request/list/view.hpp"
#include "views/test-openapi-view/view.hpp"
#include "legacy/views/timetable/get/view.hpp"
#include "views/test-openapi-view/view.hpp"

void AppendPgControllers(userver::components::ComponentList& component_list)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ std::vector<legacy::models::AdminAccount> Controller::GetByFilter(
::utils::FillSharedTransaction(transaction, pg_cluster_);
auto pg_result =
utils::PgExecute(transaction, sql::qGetAdminsByFilter, filter);
return utils::ConvertPgResultToArray<legacy::models::AdminAccount>(pg_result);
return utils::ConvertPgResultToArray<legacy::models::AdminAccount>(
pg_result);
}

} // namespace legacy::components::controllers::postgres::admin
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ std::vector<legacy::models::RequestPrivileges> Controller::GetAllRequests(
{
utils::FillSharedTransaction(transaction, pg_cluster_);
auto pg_result = utils::PgExecute(transaction, sql::qGetAllRequests);
return utils::ConvertPgResultToArray<legacy::models::RequestPrivileges>(pg_result);
return utils::ConvertPgResultToArray<legacy::models::RequestPrivileges>(
pg_result);
}

std::optional<boost::uuids::uuid> Controller::DropRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
#include <utils/postgres_helper.hpp>
#include <utils/shared_transaction.hpp>

#include "legacy/components/controllers/postgres/user/sql_queries.hpp"
#include "config_schema.hpp"
#include "legacy/components/controllers/postgres/user/sql_queries.hpp"
#include "legacy/models/user/postgre.hpp"
#include "legacy/models/user/type.hpp"
#include "legacy/models/user_credentials/postgre.hpp"
Expand Down Expand Up @@ -59,7 +59,8 @@ utils::SharedTransaction Controller::CreateTransaction()
}

void Controller::InternalForceCreateUser(
const boost::uuids::uuid&, const legacy::models::UserCredentials& user_credentials,
const boost::uuids::uuid&,
const legacy::models::UserCredentials& user_credentials,
utils::SharedTransaction transaction)
{
utils::FillSharedTransaction(transaction, pg_cluster_);
Expand Down
3 changes: 2 additions & 1 deletion src/legacy/models/register_request/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace legacy::models
using namespace utils::convert;
struct RegisterRequest
{
Property<legacy::models::UserCredentials, "user_credentials"> user_credentials;
Property<legacy::models::UserCredentials, "user_credentials">
user_credentials;
OptionalProperty<std::string, "description"> description;
OptionalProperty<UserType, "desired_type"> desired_type;
static constexpr TypeOfBody kTypeOfBody =
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/views/admin/create/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

#include "Request.hpp"
#include "Responses.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/components/controllers/postgres/admin/controller.hpp"
#include "legacy/components/controllers/postgres/user/controller.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/models/auth_token/serialize.hpp"
#include "legacy/models/user/serialize.hpp"
#include "legacy/models/user_type/serialize.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/views/admin/list/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

#include "Request.hpp"
#include "Responses.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/components/controllers/postgres/admin/controller.hpp"
#include "legacy/components/controllers/postgres/user/controller.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/models/auth_token/serialize.hpp"
#include "legacy/models/user/serialize.hpp"
#include "legacy/models/user_type/serialize.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/views/faculty/list/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

#include "Request.hpp"
#include "Responses.hpp"
#include "legacy/components/controllers/postgres/faculty/controller.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/components/controllers/postgres/faculty/controller.hpp"
#include "legacy/models/auth_token/serialize.hpp"
#include "legacy/models/user/serialize.hpp"
#include "legacy/models/user_type/serialize.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/views/group-stage/list/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

#include "Request.hpp"
#include "Responses.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/components/controllers/postgres/faculty/controller.hpp"
#include "legacy/components/controllers/postgres/group_stage/controller.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/models/auth_token/serialize.hpp"
#include "legacy/models/education_type/all.hpp"
#include "legacy/models/user/serialize.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/views/login/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

#include "Request.hpp"
#include "Responses.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/components/controllers/postgres/token/controller.hpp"
#include "legacy/components/controllers/postgres/user/controller.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/models/auth_token/serialize.hpp"
#include "legacy/models/user/serialize.hpp"
#include "legacy/models/user_type/serialize.hpp"
Expand Down
6 changes: 3 additions & 3 deletions src/legacy/views/register/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include <utils/shared_transaction.hpp>

#include "Request.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/components/controllers/postgres/token/controller.hpp"
#include "legacy/components/controllers/postgres/user/controller.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/models/auth_token/serialize.hpp"
#include "legacy/models/user/serialize.hpp"
#include "legacy/models/user_type/parse.hpp"
Expand Down Expand Up @@ -97,8 +97,8 @@ class Handler final
HandleDesiredType(transaction, request, user_id.value());
Response200 resp;
resp.id() = *id;
resp.user() =
legacy::models::User{.id = {*user_id}, .type = {legacy::models::UserType::kUser}};
resp.user() = legacy::models::User{
.id = {*user_id}, .type = {legacy::models::UserType::kUser}};
return resp;
}

Expand Down
2 changes: 1 addition & 1 deletion src/legacy/views/teacher/create/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

#include "Request.hpp"
#include "Responses.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/components/controllers/postgres/teacher/controller.hpp"
#include "legacy/components/controllers/postgres/user/controller.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/models/auth_token/serialize.hpp"
#include "legacy/models/user/serialize.hpp"
#include "legacy/models/user_type/serialize.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/views/teacher/list/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

#include "Request.hpp"
#include "Responses.hpp"
#include "legacy/components/controllers/postgres/teacher/controller.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/components/controllers/postgres/teacher/controller.hpp"
#include "legacy/models/auth_token/serialize.hpp"
#include "legacy/models/user/serialize.hpp"
#include "legacy/models/user_type/serialize.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/views/teacher/request/approve/link/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

#include "Request.hpp"
#include "Responses.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/components/controllers/postgres/teacher/controller.hpp"
#include "legacy/components/controllers/postgres/user/controller.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/models/auth_token/serialize.hpp"
#include "legacy/models/user/serialize.hpp"
#include "legacy/models/user_type/serialize.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/views/teacher/request/approve/new/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

#include "Request.hpp"
#include "Responses.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/components/controllers/postgres/teacher/controller.hpp"
#include "legacy/components/controllers/postgres/user/controller.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/models/auth_token/serialize.hpp"
#include "legacy/models/user/serialize.hpp"
#include "legacy/models/user_type/serialize.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/views/teacher/request/list/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

#include "Request.hpp"
#include "Responses.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/components/controllers/postgres/teacher/controller.hpp"
#include "legacy/components/controllers/postgres/user/controller.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/models/auth_token/serialize.hpp"
#include "legacy/models/user/serialize.hpp"
#include "legacy/models/user_type/serialize.hpp"
Expand Down
5 changes: 3 additions & 2 deletions src/legacy/views/timetable/get/Responses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ struct Response200

static_assert(userver::formats::common::impl::kHasSerialize<
userver::formats::json::Value, legacy::models::LessonV1>);
static_assert(userver::formats::common::impl::kHasSerialize<
userver::formats::json::Value, std::vector<legacy::models::LessonV1>>);
static_assert(
userver::formats::common::impl::kHasSerialize<
userver::formats::json::Value, std::vector<legacy::models::LessonV1>>);

} // namespace legacy::views::timetable::get
2 changes: 1 addition & 1 deletion src/legacy/views/timetable/get/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#include "Request.hpp"
#include "Responses.hpp"
#include "legacy/components/controllers/postgres/lesson/controller.hpp"
#include "http/handler_parsed.hpp"
#include "legacy/components/controllers/postgres/lesson/controller.hpp"
#include "legacy/models/day/all.hpp"
#include "legacy/models/education_type/all.hpp"
#include "legacy/models/lesson_v1/parse.hpp"
Expand Down
5 changes: 2 additions & 3 deletions src/openapi/as_tuple/reflective.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
#include <openapi/base/object_property.hpp>
#include <type_traits>
#include <utility>

namespace openapi::raw
{
template <checks::IsReflective T>
class AsTuple<T>
template <typename T>
requires checks::is_reflective_v<T> class AsTuple<T>
{
private:
using Type = T;
Expand Down
3 changes: 3 additions & 0 deletions src/openapi/base/all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <openapi/base/array_property.hpp>
#include <openapi/base/array_traits.hpp>
#include <openapi/base/doc.hpp>
#include <openapi/base/holder.hpp>
#include <openapi/base/is_optional_property.hpp>
#include <openapi/base/named_traits.hpp>
#include <openapi/base/object_field_names.hpp>
Expand All @@ -13,5 +14,7 @@
#include <openapi/base/property_base.hpp>
#include <openapi/base/reflective_preferences.hpp>
#include <openapi/base/reflective_utils.hpp>
#include <openapi/base/reflective_uuid_fix.hpp>
#include <openapi/base/string_property.hpp>
#include <openapi/base/string_traits.hpp>
#include <openapi/base/uuid_property.hpp>
10 changes: 6 additions & 4 deletions src/openapi/base/object_property.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

namespace openapi
{
template <checks::IsReflective T, typename Traits = EmptyTraits>
struct ObjectProperty : public PropertyBase<T, Traits>
template <typename T, typename Traits = EmptyTraits>
requires checks::is_reflective_v<T> struct ObjectProperty
: public PropertyBase<T, Traits>
{
};

template <checks::IsReflective T, typename Traits>
struct Property<T, Traits> : public ObjectProperty<T, Traits>
template <typename T, typename Traits>
requires checks::is_reflective_v<T> struct Property<T, Traits>
: public ObjectProperty<T, Traits>
{
};

Expand Down
4 changes: 2 additions & 2 deletions src/openapi/base/property_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ struct PropertyBase
{
}

auto operator<=>(const PropertyBase<T, Traits>& r) const = default;
auto operator<=>(const T& r) const
auto operator<=>(const PropertyBase<value_type, Traits>& r) const = default;
auto operator<=>(const value_type& r) const
{
return value <=> r;
}
Expand Down
22 changes: 14 additions & 8 deletions src/openapi/base/reflective_checks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@ concept IsReflectiveHelper = requires
};

template <typename T>
concept IsReflective = requires
{
requires std::is_class_v<T>;
requires std::is_aggregate_v<T>;
concept IsReflective =
std::is_class_v<T>&& std::is_aggregate_v<T> && !IsProperty<T>;

requires !IsProperty<T>;
};
template <typename T>
constexpr bool is_reflective_v = IsReflective<T>;

template <typename T>
concept IsReflectiveProperty =
IsProperty<T>&& IsReflective<typename T::value_type>;

template <typename T>
constexpr bool is_reflective_property_v = IsReflectiveProperty<T>;

template <typename T>
concept IsReflectiveProperty = IsProperty<T> && IsReflective<typename T::value_type>;
concept IsNotReflectiveProperty =
IsProperty<T> && !IsReflective<typename T::value_type>;

template <typename T>
concept IsNotReflectiveProperty = IsProperty<T> && !IsReflective<typename T::value_type>;
constexpr bool is_not_reflective_property_v = IsNotReflectiveProperty<T>;

} // namespace checks
} // namespace openapi
Loading

0 comments on commit 97aecbe

Please sign in to comment.