Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
sabudilovskiy committed Nov 30, 2023
1 parent 4a8c312 commit b35eaa1
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 144 deletions.
2 changes: 1 addition & 1 deletion src/legacy/models/day/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace userver::storages::postgres::io
{
template <>
struct CppToUserPg<::legacy::models::Day>
: openapi::PgMapper<::legacy::models::Day, "timetable_vsu.day">
: openapi::PgMapperFixed<::legacy::models::Day, "timetable_vsu", "day">
{
};
} // namespace userver::storages::postgres::io
54 changes: 27 additions & 27 deletions src/legacy/models/day/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@

namespace legacy::models
{
// enum struct Day : int
// {
// monday,
// tuesday,
// wednesday,
// thursday,
// friday,
// saturday
// };
// struct enum_introspector_Day;
// consteval enum_introspector_Day* get_enum_introspector(std
// ::type_identity<Day>)
// {
// return nullptr;
// }
// struct enum_introspector_Day
// {
// using enum Day;
// static constexpr std::array<std::string_view, 6> names = {
// "monday", "tuesday", "wednesday", "thursday", "friday", "saturday"};
// static constexpr std::array<Day, 6> values = {monday, tuesday,
// wednesday,
// thursday, friday,
// saturday};
// };
DECLARE_OPENAPI_ENUM(Day, int, monday, tuesday, wednesday, thursday, friday,
saturday);
enum struct Day : int
{
monday,
tuesday,
wednesday,
thursday,
friday,
saturday
};
struct enum_introspector_Day;
consteval enum_introspector_Day* get_enum_introspector(std
::type_identity<Day>)
{
return nullptr;
}
struct enum_introspector_Day
{
using enum Day;
static constexpr std::array<std::string_view, 6> names = {
"monday", "tuesday", "wednesday", "thursday", "friday", "saturday"};
static constexpr std::array<Day, 6> values = {monday, tuesday,
wednesday,
thursday, friday,
saturday};
};
// DECLARE_OPENAPI_ENUM(Day, int, monday, tuesday, wednesday, thursday, friday,
// saturday);
} // namespace legacy::models
4 changes: 2 additions & 2 deletions src/legacy/models/education_type/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace userver::storages::postgres::io
{
template <>
struct CppToUserPg<::legacy::models::EducationType>
: openapi::PgMapper<::legacy::models::EducationType,
"timetable_vsu.grouptype">
: openapi::PgMapperFixed<::legacy::models::EducationType,
"timetable_vsu" , "grouptype">
{
};
} // namespace userver::storages::postgres::io
46 changes: 23 additions & 23 deletions src/legacy/models/education_type/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@

namespace legacy::models
{
// enum struct EducationType : int
// {
// undergraduate,
// magistracy,
// postgraduate,
// specialty
// };
// struct enum_introspector_EducationType;
// consteval enum_introspector_EducationType* get_enum_introspector(
// std ::type_identity<EducationType>)
// {
// return nullptr;
// }
// struct enum_introspector_EducationType
// {
// using enum EducationType;
// static constexpr std::array<std::string_view, 4> names = {
// "undergraduate", "magistracy", "postgraduate", "specialty"};
// static constexpr std::array<EducationType, 4> values = {
// undergraduate, magistracy, postgraduate, specialty};
// };
DECLARE_OPENAPI_ENUM(EducationType, int, undergraduate, magistracy,
postgraduate, specialty);
enum struct EducationType : int
{
undergraduate,
magistracy,
postgraduate,
specialty
};
struct enum_introspector_EducationType;
consteval enum_introspector_EducationType* get_enum_introspector(
std ::type_identity<EducationType>)
{
return nullptr;
}
struct enum_introspector_EducationType
{
using enum EducationType;
static constexpr std::array<std::string_view, 4> names = {
"undergraduate", "magistracy", "postgraduate", "specialty"};
static constexpr std::array<EducationType, 4> values = {
undergraduate, magistracy, postgraduate, specialty};
};
// DECLARE_OPENAPI_ENUM(EducationType, int, undergraduate, magistracy,
// postgraduate, specialty);
} // namespace legacy::models
44 changes: 22 additions & 22 deletions src/legacy/models/lesson_type/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
#include <openapi/enum/declare.hpp>
namespace legacy::models
{
DECLARE_OPENAPI_ENUM(LessonType, int, labaratory, lection, practice, some_test,
some_test2, some_test3);
// enum struct LessonType : int
// {
// labaratory,
// lection,
// practice
// };
// struct enum_introspector_LessonType;
// consteval enum_introspector_LessonType* get_enum_introspector(
// std ::type_identity<LessonType>)
// {
// return nullptr;
// }
// struct enum_introspector_LessonType
// {
// using enum LessonType;
// static constexpr std::array<std::string_view, 3> names = {
// "labaratory", "lection", "practice"};
// static constexpr std::array<LessonType, 3> values = {labaratory, lection,
// practice};
// };
// DECLARE_OPENAPI_ENUM(LessonType, int, labaratory, lection, practice, some_test,
// some_test2, some_test3);
enum struct LessonType : int
{
labaratory,
lection,
practice
};
struct enum_introspector_LessonType;
consteval enum_introspector_LessonType* get_enum_introspector(
std ::type_identity<LessonType>)
{
return nullptr;
}
struct enum_introspector_LessonType
{
using enum LessonType;
static constexpr std::array<std::string_view, 3> names = {
"labaratory", "lection", "practice"};
static constexpr std::array<LessonType, 3> values = {labaratory, lection,
practice};
};
} // namespace legacy::models
40 changes: 20 additions & 20 deletions src/legacy/models/lesson_week_type/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@

namespace legacy::models
{
DECLARE_OPENAPI_ENUM(LessonWeekType, int, all, even, odd);
// enum struct LessonWeekType : int
// {
// all,
// even,
// odd
// };
// struct enum_introspector_LessonWeekType;
// consteval enum_introspector_LessonWeekType* get_enum_introspector(
// std ::type_identity<LessonWeekType>)
// {
// return nullptr;
// }
// struct enum_introspector_LessonWeekType
// {
// using enum LessonWeekType;
// static constexpr std::array<std::string_view, 3> names = {"all", "even",
// "odd"};
// static constexpr std::array<LessonWeekType, 3> values = {all, even, odd};
// };
// DECLARE_OPENAPI_ENUM(LessonWeekType, int, all, even, odd);
enum struct LessonWeekType : int
{
all,
even,
odd
};
struct enum_introspector_LessonWeekType;
consteval enum_introspector_LessonWeekType* get_enum_introspector(
std ::type_identity<LessonWeekType>)
{
return nullptr;
}
struct enum_introspector_LessonWeekType
{
using enum LessonWeekType;
static constexpr std::array<std::string_view, 3> names = {"all", "even",
"odd"};
static constexpr std::array<LessonWeekType, 3> values = {all, even, odd};
};
} // namespace legacy::models
2 changes: 1 addition & 1 deletion src/legacy/models/subgroup/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace userver::storages::postgres::io
{
template <>
struct CppToUserPg<::legacy::models::Subgroup>
: openapi::PgMapper<::legacy::models::Subgroup, "timetable_vsu.subgroup">
: openapi::PgMapperFixed<::legacy::models::Subgroup, "timetable_vsu", "subgroup">
{
};

Expand Down
40 changes: 20 additions & 20 deletions src/legacy/models/subgroup/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
#include <openapi/enum/declare.hpp>
namespace legacy::models
{
// enum struct Subgroup : int
// {
// all,
// first,
// second
// };
// struct enum_introspector_Subgroup;
// consteval enum_introspector_Subgroup* get_enum_introspector(
// std ::type_identity<Subgroup>)
// {
// return nullptr;
// }
// struct enum_introspector_Subgroup
// {
// using enum Subgroup;
// static constexpr std::array<std::string_view, 3> names = {"all", "first",
// "second"};
// static constexpr std::array<Subgroup, 3> values = {all, first, second};
// };
enum struct Subgroup : int
{
all,
first,
second
};
struct enum_introspector_Subgroup;
consteval enum_introspector_Subgroup* get_enum_introspector(
std ::type_identity<Subgroup>)
{
return nullptr;
}
struct enum_introspector_Subgroup
{
using enum Subgroup;
static constexpr std::array<std::string_view, 3> names = {"all", "first",
"second"};
static constexpr std::array<Subgroup, 3> values = {all, first, second};
};

DECLARE_OPENAPI_ENUM(Subgroup, int, all, even, odd);
// DECLARE_OPENAPI_ENUM(Subgroup, int, all, even, odd);
} // namespace legacy::models
2 changes: 1 addition & 1 deletion src/legacy/models/user_type/postgre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace userver::storages::postgres::io
{
template <>
struct CppToUserPg<legacy::models::UserType>
: openapi::PgMapper<legacy::models::UserType, "timetable_vsu.user_type">
: openapi::PgMapperFixed<legacy::models::UserType, "timetable_vsu", "user_type">
{
};
} // namespace userver::storages::postgres::io
52 changes: 26 additions & 26 deletions src/legacy/models/user_type/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
namespace legacy::models
{
// clang-format off
DECLARE_OPENAPI_ENUM(UserType, int,
user,
admin,
root,
teacher);
// DECLARE_OPENAPI_ENUM(UserType, int,
// user,
// admin,
// root,
// teacher);
// clang-format on

// enum struct UserType : int
// {
// user,
// admin,
// root,
// teacher
// };
// struct enum_introspector_UserType;
// consteval enum_introspector_UserType* get_enum_introspector(
// std ::type_identity<UserType>)
// {
// return nullptr;
// }
// struct enum_introspector_UserType
// {
// using enum UserType;
// static constexpr std::array<std::string_view, 4> names = {
// "user", "admin", "root", "teacher"};
// static constexpr std::array<UserType, 4> values = {user, admin, root,
// teacher};
// };
enum struct UserType : int
{
user,
admin,
root,
teacher
};
struct enum_introspector_UserType;
consteval enum_introspector_UserType* get_enum_introspector(
std ::type_identity<UserType>)
{
return nullptr;
}
struct enum_introspector_UserType
{
using enum UserType;
static constexpr std::array<std::string_view, 4> names = {
"user", "admin", "root", "teacher"};
static constexpr std::array<UserType, 4> values = {user, admin, root,
teacher};
};
} // namespace legacy::models
22 changes: 21 additions & 1 deletion utests/openapi/doc/serialize/basic_enum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,27 @@

namespace test_models
{
DECLARE_OPENAPI_ENUM(UserType, int, root, teacher, user, admin, tester);
//DECLARE_OPENAPI_ENUM(UserType, int, root, teacher, user, admin, tester);
enum struct UserType : int
{
root,
teacher,
user,
admin,
tester
};
struct enum_introspector_UserType;
consteval enum_introspector_UserType* get_enum_introspector(
std ::type_identity<UserType>)
{
return nullptr;
}
struct enum_introspector_UserType
{
using enum UserType;
static constexpr std::array<std::string_view, 5> names = {"root", "teacher", "user", "admin", "tester"};
static constexpr std::array<UserType, 5> values = {root, teacher, user, admin, tester};
};

} // namespace test_models

Expand Down

0 comments on commit b35eaa1

Please sign in to comment.