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

New openapi #17

Open
wants to merge 67 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
a1f8f77
-
sabudilovskiy Jul 28, 2023
458f048
-
sabudilovskiy Aug 1, 2023
b434b32
-
sabudilovskiy Aug 1, 2023
cc873ee
-
sabudilovskiy Sep 8, 2023
2121b2f
-
sabudilovskiy Sep 8, 2023
0759fc6
-
sabudilovskiy Sep 8, 2023
aae6829
-
sabudilovskiy Sep 8, 2023
0602e26
-
sabudilovskiy Sep 9, 2023
228e43f
add format includes
sabudilovskiy Sep 9, 2023
03c0190
add format includes
sabudilovskiy Sep 9, 2023
30d9366
fix makefile
sabudilovskiy Sep 9, 2023
0c959ef
format includes
sabudilovskiy Sep 9, 2023
2a5e20f
-
sabudilovskiy Sep 9, 2023
138f3d6
-
sabudilovskiy Sep 9, 2023
b3a1c13
-
sabudilovskiy Sep 28, 2023
ff837d0
-
sabudilovskiy Sep 30, 2023
15aacbb
-
sabudilovskiy Sep 30, 2023
c700525
-
sabudilovskiy Oct 2, 2023
ddc9bdb
-
sabudilovskiy Oct 2, 2023
54990c2
-
sabudilovskiy Oct 4, 2023
f26b74c
-
sabudilovskiy Oct 4, 2023
5327c61
-
sabudilovskiy Oct 6, 2023
9b27df8
-
sabudilovskiy Oct 6, 2023
92036c7
-
sabudilovskiy Oct 7, 2023
8cc2ecb
-
sabudilovskiy Oct 7, 2023
1b7ddcd
-
sabudilovskiy Oct 12, 2023
aca9c71
-
sabudilovskiy Oct 12, 2023
52c7381
fix min and max
sabudilovskiy Oct 12, 2023
6614d06
move legacy models, components and views
sabudilovskiy Oct 16, 2023
97aecbe
-
sabudilovskiy Oct 17, 2023
d795a55
-
sabudilovskiy Oct 17, 2023
afbc373
-
sabudilovskiy Oct 20, 2023
43ff626
-
sabudilovskiy Oct 20, 2023
90428ca
-
sabudilovskiy Oct 21, 2023
c733287
-
sabudilovskiy Oct 21, 2023
6034d0e
-
sabudilovskiy Oct 21, 2023
02bcc7e
-
sabudilovskiy Oct 21, 2023
0a68c2a
-
sabudilovskiy Oct 21, 2023
bfd645f
-
sabudilovskiy Oct 21, 2023
19cc2ed
-
sabudilovskiy Oct 24, 2023
fddbfc9
-
sabudilovskiy Oct 24, 2023
1c56a56
-
sabudilovskiy Oct 24, 2023
a7b6486
-
sabudilovskiy Oct 25, 2023
72f8814
-
sabudilovskiy Oct 25, 2023
74820eb
-
sabudilovskiy Oct 25, 2023
c18a357
-
sabudilovskiy Oct 26, 2023
6dc7b31
-
sabudilovskiy Oct 27, 2023
d187c5e
-
sabudilovskiy Oct 27, 2023
b5d424e
-
sabudilovskiy Nov 16, 2023
7a904e8
-
sabudilovskiy Nov 27, 2023
ea5e28e
-
sabudilovskiy Nov 27, 2023
1d1f1fb
-
sabudilovskiy Nov 27, 2023
cba2e1f
-
sabudilovskiy Nov 27, 2023
4664c03
-
sabudilovskiy Nov 27, 2023
d93607a
-
sabudilovskiy Nov 27, 2023
b9976cd
-
sabudilovskiy Nov 27, 2023
384aede
-
sabudilovskiy Nov 27, 2023
fe9251f
-
sabudilovskiy Nov 27, 2023
c9437cd
-
sabudilovskiy Nov 27, 2023
682bca2
-
sabudilovskiy Nov 30, 2023
4a8c312
-
sabudilovskiy Nov 30, 2023
b35eaa1
-
sabudilovskiy Nov 30, 2023
3c98245
-
sabudilovskiy Nov 30, 2023
b63af1d
-
sabudilovskiy Nov 30, 2023
6d44e61
-
sabudilovskiy Nov 30, 2023
458e349
-
sabudilovskiy Nov 30, 2023
400324d
-
sabudilovskiy Nov 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
486 changes: 305 additions & 181 deletions .gen/objs.txt

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions .gen/unittest.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
utests/test_ct.cpp
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/datetime.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/datetime.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
utests/openapi/doc/serialize/basic_request.cpp
utests/openapi/doc/serialize/basic_path.cpp
utests/openapi/doc/serialize/basic_enum.cpp
utests/openapi/doc/serialize/basic.cpp
utests/hello_test.cpp
utests/dropper_additional.cpp
utests/dropper.cpp
Expand Down
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,20 @@ jobs:
run: |
sudo apt update
sudo apt install --allow-downgrades -y pep8 $(cat dependencies/${{matrix.os}}.md | tr '\n' ' ')
sudo apt install clang-format-11
- name: Install python packages
run: |
sudo pip install $(cat dependencies/python.md) | tr '\n' ' '
- name: install g++11
run: |
sudo apt install g++-11
export CXX=/usr/bin/g++-11
- name: Gen list of source and format all
run: |
make gen
make format-all
- name: Check format sources
run: |
make check-format
- name: Gen list of source and check diffs with commit
run: |
make gen
make unite-api
make check-git-status
- name: Reuse ccache directory
uses: actions/cache@v2
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ configs/static_config.yaml
Makefile.local
merged_api.yaml
tests/results
Makefile.local
log_build.txt
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Используйте IntelliSense, чтобы узнать о возможных атрибутах.
// Наведите указатель мыши, чтобы просмотреть описания существующих атрибутов.
// Для получения дополнительной информации посетите: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug",
"program": "${workspaceFolder}/<executable file>",
"args": [],
"cwd": "${workspaceFolder}"
}
]
}
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 3.12)
set(CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(USERVER_FEATURE_GRPC OFF)
project(timetable_vsu_backend CXX)
message("Compiler version: ${CMAKE_CXX_COMPILER_VERSION}")

Expand All @@ -19,8 +22,11 @@ file(STRINGS ${PROJECT_SOURCE_DIR}/.gen/unittest.txt unittest_src)
add_library(${PROJECT_NAME}_objs OBJECT
${objs_src}
)
target_compile_options(${PROJECT_NAME}_objs PRIVATE -Wno-missing-field-initializers
)
target_include_directories(${PROJECT_NAME}_objs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_link_libraries(${PROJECT_NAME}_objs PUBLIC userver-core userver-postgresql)
# target_compile_options(${PROJECT_NAME}_objs PRIVATE -Wfatal-errors)


# The Service
Expand Down
40 changes: 37 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ CMAKE_COMMON_FLAGS ?= -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
CMAKE_DEBUG_FLAGS ?= -DUSERVER_SANITIZE='addr ub'
CMAKE_RELEASE_FLAGS ?=
CMAKE_OS_FLAGS ?= -DUSERVER_FEATURE_CRYPTOPP_BLAKE2=0 -DUSERVER_FEATURE_REDIS_HI_MALLOC=1
FORMAT_INCLUDES_FLAGS ?= userver boost gtest openapi utils codegen
GENERATE_SQL_QUERIES_FLAGS ?= src/sql src/codegen sql sql
GENERATE_ALL_HEADERS_FLAGS ?= src/openapi openapi
NPROCS ?= $(shell nproc)
CLANG_FORMAT ?= clang-format-11

Expand Down Expand Up @@ -50,6 +53,12 @@ testsuite-debug testsuite-release: testsuite-%: build-%
@rm -rf tests/results
@cd build_$* && ((test -t 1 && GTEST_COLOR=1 PYTEST_ADDOPTS="--color=yes $(if $(F),-k $(F))" ctest -V -R "testsuite"))

.PHONY: utest-debug utest-release
utest-debug utest-release: utest-%: build-%
@rm -rf tests/results
@cmake --build build_$* -j $(NPROCS) --target timetable_vsu_backend_unittest
@cd build_$* && ((test -t 1 && GTEST_COLOR=1 ctest -V -R "unittest"))

# Start the service (via testsuite service runner)
.PHONY: service-start-debug service-start-release
service-start-debug service-start-release: service-start-%: build-%
Expand Down Expand Up @@ -98,8 +107,14 @@ run-debug run-release: run-%: nothing-%
install-run-debug install-run-release: install-run-%: install-%
$(MAKE) run-$*

.PHONY: format-includes
format-includes:
@python3 scripts/format_includes.py src $(FORMAT_INCLUDES_FLAGS)
@python3 scripts/format_includes.py utests $(FORMAT_INCLUDES_FLAGS)
@python3 scripts/format_includes.py service $(FORMAT_INCLUDES_FLAGS)

.PHONY: format-cpp
format-cpp:
format-cpp: format-includes
@find benchs -name '*pp' -type f | xargs $(CLANG_FORMAT) -i
@find service -name '*pp' -type f | xargs $(CLANG_FORMAT) -i
@find src -name '*pp' -type f | xargs $(CLANG_FORMAT) -i
Expand Down Expand Up @@ -148,8 +163,9 @@ check-format-cpp:
@find service -name '*pp' -type f | xargs $(CLANG_FORMAT) -i --dry-run --Werror
@find src -name '*pp' -type f | xargs $(CLANG_FORMAT) -i --dry-run --Werror
@find utests -name '*pp' -type f | xargs $(CLANG_FORMAT) -i --dry-run --Werror
.PHONY: gen
gen:

.PHONY: gen-sources
gen-sources:
@rm -rf .gen
@mkdir -p .gen

Expand All @@ -170,6 +186,24 @@ gen:
unite-api:
@python3 scripts/merge_yaml.py api/api.yaml united_api.yaml

.PHONY: gen-queries
gen-queries:
@python3 scripts/generate_sql_queries.py $(GENERATE_SQL_QUERIES_FLAGS)

.PHONY: gen-all-headers
gen-all-headers:
@python3 scripts/generate_all_headers.py $(GENERATE_ALL_HEADERS_FLAGS)

.PHONY: gen
gen:
$(MAKE) gen-queries
$(MAKE) gen-sources
$(MAKE) gen-all-headers

.PHONY: log-build
log-build:
$(MAKE) -s test-debug > log_build.txt 2>&1

# # Internal hidden targets that are used only in docker environment
# --in-docker-start-debug --in-docker-start-release: --in-docker-start-%: install-%
# @sed -i 's/config_vars.yaml/config_vars.docker.yaml/g' /home/user/.local/etc/timetable_vsu_backend/static_config.yaml
Expand Down
2 changes: 1 addition & 1 deletion Makefile.local
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CMAKE_COMMON_FLAGS += -DUSERVER_FEATURE_CRYPTOPP_BLAKE=0 -DUSERVER_FEATURE_GRPC_CHANNELZ=0
CMAKE_COMMON_FLAGS += -DUSERVER_FEATURE_CRYPTOPP_BLAKE=0 -DUSERVER_FEATURE_GRPC_CHANNELZ=0 -DCMAKE_CXX_COMPILER=g++
2 changes: 1 addition & 1 deletion benchs/hello_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <string_view>
#include <userver/engine/run_standalone.hpp>

#include "views/hello/view.hpp"
#include "legacy/views/hello/view.hpp"

void HelloBenchmark(benchmark::State& state)
{
Expand Down
11 changes: 11 additions & 0 deletions configs/dynamic_config_fallback.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,24 @@
}
},
"POSTGRES_CONNECTION_PIPELINE_ENABLED": false,
"POSTGRES_CONNECTION_PIPELINE_EXPERIMENT": 10,
"POSTGRES_CONNLIMIT_MODE_AUTO_ENABLED": false,
"POSTGRES_CONNECTION_POOL_SETTINGS": {
"postgres-db-1": {
"max_pool_size": 15,
"max_queue_size": 200,
"min_pool_size": 8
}
},
"POSTGRES_CONGESTION_CONTROL_SETTINGS": {

},
"POSTGRES_DEADLINE_PROPAGATION_VERSION": 1,
"USERVER_BAGGAGE_ENABLED": true,
"BAGGAGE_SETTINGS": {
"allowed_keys": []
},
"USERVER_DEADLINE_PROPAGATION_ENABLED" : false,
"POSTGRES_DEFAULT_COMMAND_CONTROL": {
"network_timeout_ms": 750,
"statement_timeout_ms": 500
Expand Down
45 changes: 33 additions & 12 deletions configs/static_config.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,6 @@ components_manager:
path: /tests/{action}
method: POST
task_processor: main-task-processor
handler-login:
path: /login
method: POST
task_processor: main-task-processor
handler-register:
path: /register
method: POST
task_processor: main-task-processor
handler-timetable-get:
path: /timetable/get
method: POST
task_processor: main-task-processor
handler-admin-create:
path: /admin/create
method: POST
Expand Down Expand Up @@ -100,6 +88,28 @@ components_manager:
handler-group-stage-list:
path: /group-stage/list
method: POST
task_processor: main-task-processor
login-view:
path: /login
method: POST
task_processor: main-task-processor
register-view:
path: /register
method: POST
task_processor: main-task-processor
openapi-descriptor:
servers:
- description: dev
url: http://158.160.44.177:8080
- description: stable
url: http://51.250.86.220
load-enabled: true
path: /openapi
info:
title: Some Server Doc
description: Some server
version: 1.0.0
method: GET,POST
task_processor: main-task-processor
postgres-db-1:
dbconnection: $dbconnection
Expand All @@ -115,8 +125,19 @@ components_manager:
password: $root_password
id: $root_id
token_controller: {}
new-token-controller: {}
new-user-controller:
root:
login: $root_login
password: $root_password
id: $root_id
lesson_details_controller : {}
teacher_controller : {}
new-lesson-controller: {}
timetable-view:
path: /timetable/get
method: POST
task_processor: main-task-processor
handler-ping:
path: /ping
method: GET
Expand Down
2 changes: 2 additions & 0 deletions dependencies/python.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
psycopg2
autopep8
websocket
2 changes: 2 additions & 0 deletions dependencies/ubuntu-22.04.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ ccache
git
postgresql-15
redis-server
libnghttp2-dev
clang-format-11
56 changes: 56 additions & 0 deletions scripts/format_includes.py
Original file line number Diff line number Diff line change
@@ -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 <directory> start_words...')
return

input_path = sys.argv[1]
words = sys.argv[2:]
format_directory(input_path, words)


if __name__ == '__main__':
main()
46 changes: 46 additions & 0 deletions scripts/generate_all_headers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import sys


def path(prefix, root_directory, path):
relative = os.path.relpath(path, root_directory)
return prefix + '/' + relative

# Функция для создания файла all.hpp
def create_all_hpp(prefix_path, folder_path, root):
hpp_files = [f for f in os.listdir(folder_path) if (f.endswith(".hpp") and f != "all.hpp")]

with open(os.path.join(folder_path, "all.hpp"), "w") as all_hpp_file:
all_hpp_file.write('#pragma once\n')
for hpp_file in hpp_files:
path_hpp_file = path(prefix_path, root, os.path.join(folder_path, hpp_file))
all_hpp_file.write(f'#include <{path_hpp_file}>\n')

# Поиск вложенных папок
sub_folders = [f for f in os.listdir(folder_path) if os.path.isdir(os.path.join(folder_path, f))]

for sub_folder in sub_folders:
path_sub_folder = path(prefix_path, root, os.path.join(folder_path, sub_folder))
all_hpp_file.write(f'#include <{path_sub_folder}/all.hpp>\n')


def create_all_hpp_in_directory(prefix_path, root):
for folder_name, sub_folders, filenames in os.walk(root):
create_all_hpp(prefix_path, folder_name, root)

def main():
if len(sys.argv) < 2:
print('Usage: python3 generate_sql.py <directory> <prefix_path>')
return

directory = sys.argv[1]
if len(sys.argv) >= 3:
prefix_path = sys.argv[2]
else:
prefix_path = ''

create_all_hpp_in_directory(prefix_path, directory)


if __name__ == '__main__':
main()
Loading
Loading