diff --git a/CMakeLists.txt b/CMakeLists.txt index 29c2e1a..7ca8641 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,11 +4,16 @@ set(CMAKE_CXX_STANDARD 20) set(openapi-extension-userver_BUILD_UNIT_TESTS false) set(openapi-extension-userver_BUILD_TEST_SERVICES false) -set(USERVER_LTO OFF) - -add_subdirectory(uopenapi) - -include(uopenapi/CMake/CreatePart.cmake) +set(USERVER_FEATURE_POSTGRESQL ON) + +enable_testing() +include(FetchContent) +FetchContent_Declare( + uopenapi + GIT_REPOSITORY https://github.com/sabudilovskiy/userver-openapi-extension + GIT_TAG "26b3160c9a3317fe15b7c569de70f1e3fbc70592" +) +FetchContent_MakeAvailable(uopenapi) CreateTrivialPart( name "src" @@ -16,13 +21,10 @@ CreateTrivialPart( ) target_link_libraries(${src_module} PUBLIC openapi-extension-userver_library) -target_link_libraries(${src_module} PUBLIC userver-postgresql) -target_compile_options(${src_module} PUBLIC "-Wno-missing-field-initializers") add_executable(service service/main.cpp) target_link_libraries(service PUBLIC ${src_module}) -include(uopenapi/userver/cmake/UserverTestsuite.cmake) SET(USERVER_PYTHON "python3") userver_testsuite_add_simple() diff --git a/Makefile b/Makefile index 4a5d5db..750d2d1 100644 --- a/Makefile +++ b/Makefile @@ -65,8 +65,7 @@ find-c-compiler: .PHONY: format format: - python3.10 uopenapi/scripts/generate_all_headers.py library/uopenapi uopenapi - python3.10 uopenapi/scripts/format_includes.py library boost uopenapi checks + python3.10 scripts/format_includes.py library boost uopenapi checks find checks -name '*pp' -type f | xargs clang-format-17 -i find library -name '*pp' -type f | xargs clang-format-17 -i make add-eol P=tests diff --git a/scripts/format_includes.py b/scripts/format_includes.py new file mode 100644 index 0000000..aca80a6 --- /dev/null +++ b/scripts/format_includes.py @@ -0,0 +1,56 @@ +import os +import sys + +def check_line(line: str, words): + index_include: int = line.find("#include") + if index_include == -1: + return False + index_include += len('#include') + line_after_include = line[index_include:] + index: int = line_after_include.find("\"") + 1 + if (index == 0): + return False + file = line_after_include[index:] + for word in words: + if (file.startswith(word)): + return True + return False + + +def format_line(line: str): + return line.replace("\"", "<", 1).replace("\"", ">", 1) + + + +def format_file(input_path, words): + with open(input_path, 'r') as file: + content = file.readlines() + + formatted_content = [] + for line in content: + if check_line(line, words): + formatted_content.append(format_line(line)) + else: + formatted_content.append(line) + + with open(input_path, 'w') as file: + file.writelines(formatted_content) + +def format_directory(directory, words): + for root, _, files in os.walk(directory): + for file_name in files: + if file_name.endswith(('.hpp', '.cpp')): + file_path = os.path.join(root, file_name) + format_file(file_path, words) +def main(): + if len(sys.argv) < 3: + print('Usage: python3 format_includes.py start_words...') + return + + input_path = sys.argv[1] + words = sys.argv[2:] + format_directory(input_path, words) + + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/service/main.cpp b/service/main.cpp index f49f8df..122f762 100644 --- a/service/main.cpp +++ b/service/main.cpp @@ -7,7 +7,8 @@ #include #include #include -#include +#include +#include #include int main(int argc, char* argv[]) { @@ -17,7 +18,8 @@ int main(int argc, char* argv[]) { .Append() .Append() .Append(); - component_list.Append(); + component_list.Append(); + component_list.Append(); component_list.Append("todo_db"); views::login::Append(component_list); views::Register::Append(component_list); diff --git a/src/models/error_response.hpp b/src/models/error_response.hpp index 0cac3b9..7174c29 100644 --- a/src/models/error_response.hpp +++ b/src/models/error_response.hpp @@ -1,6 +1,6 @@ #pragma once #include -#include +#include namespace models{ UOPENAPI_DECLARE_ENUM(ErrorCode, diff --git a/src/views/login/handler.hpp b/src/views/login/handler.hpp index 28b7750..c556f93 100644 --- a/src/views/login/handler.hpp +++ b/src/views/login/handler.hpp @@ -8,7 +8,7 @@ #include namespace views::login{ - using base = uopenapi::http::openapi_handler; + using base = uopenapi::components::openapi_handler; struct handler : base{ static constexpr std::string_view kName = "login_handler"; handler(const userver::components::ComponentConfig& cfg, diff --git a/src/views/register/handler.hpp b/src/views/register/handler.hpp index a4800a8..89f64db 100644 --- a/src/views/register/handler.hpp +++ b/src/views/register/handler.hpp @@ -10,7 +10,7 @@ #include namespace views::Register{ - using base = uopenapi::http::openapi_handler; + using base = uopenapi::components::openapi_handler; struct handler : base{ static constexpr std::string_view kName = "register_handler"; handler(const userver::components::ComponentConfig& cfg, diff --git a/uopenapi b/uopenapi deleted file mode 160000 index 87b98f5..0000000 --- a/uopenapi +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 87b98f589842d60371439d90a6ef228dc9f1de3c