Skip to content

Commit a2e1190

Browse files
committed
add support for swagger
1 parent 1c04b1a commit a2e1190

18 files changed

Lines changed: 415 additions & 294 deletions

CMakeLists.txt

100755100644
Lines changed: 49 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ option(BUILD_EXAMPLES "Build examples" ${BUILD_PROGRAMS})
1717
option(BUILD_ORM "Build orm" ON)
1818
option(COZ_PROFILING "Use coz for profiling" OFF)
1919
option(BUILD_DROGON_SHARED "Build drogon as a shared lib" OFF)
20-
option(BUILD_DOC "Build Doxygen documentation" OFF)
2120

2221
include(CMakeDependentOption)
2322
CMAKE_DEPENDENT_OPTION(BUILD_POSTGRESQL "Build with postgresql support" ON "BUILD_ORM" OFF)
@@ -240,50 +239,11 @@ set(DROGON_SOURCES
240239
lib/src/WebSocketClientImpl.cc
241240
lib/src/WebSocketConnectionImpl.cc
242241
lib/src/WebsocketControllersRouter.cc)
243-
set(private_headers
244-
lib/src/AOPAdvice.h
245-
lib/src/CacheFile.h
246-
lib/src/ConfigLoader.h
247-
lib/src/filesystem.h
248-
lib/src/FiltersFunction.h
249-
lib/src/HttpAppFrameworkImpl.h
250-
lib/src/HttpClientImpl.h
251-
lib/src/HttpControllersRouter.h
252-
lib/src/HttpFileImpl.h
253-
lib/src/HttpFileUploadRequest.h
254-
lib/src/HttpMessageBody.h
255-
lib/src/HttpRequestImpl.h
256-
lib/src/HttpRequestParser.h
257-
lib/src/HttpResponseImpl.h
258-
lib/src/HttpResponseParser.h
259-
lib/src/HttpServer.h
260-
lib/src/HttpSimpleControllersRouter.h
261-
lib/src/HttpUtils.h
262-
lib/src/impl_forwards.h
263-
lib/src/ListenerManager.h
264-
lib/src/PluginsManager.h
265-
lib/src/SessionManager.h
266-
lib/src/SpinLock.h
267-
lib/src/StaticFileRouter.h
268-
lib/src/TaskTimeoutFlag.h
269-
lib/src/WebSocketClientImpl.h
270-
lib/src/WebSocketConnectionImpl.h
271-
lib/src/WebsocketControllersRouter.h)
272242

273243
if (NOT WIN32)
274-
set(DROGON_SOURCES
275-
${DROGON_SOURCES}
276-
lib/src/SharedLibManager.cc)
277-
set(private_headers
278-
${private_headers}
279-
lib/src/SharedLibManager.h)
244+
set(DROGON_SOURCES ${DROGON_SOURCES} lib/src/SharedLibManager.cc)
280245
else (NOT WIN32)
281-
set(DROGON_SOURCES
282-
${DROGON_SOURCES}
283-
third_party/mman-win32/mman.c)
284-
set(private_headers
285-
${private_headers}
286-
third_party/mman-win32/mman.h)
246+
set(DROGON_SOURCES ${DROGON_SOURCES} third_party/mman-win32/mman.c)
287247
endif (NOT WIN32)
288248

289249
if (BUILD_POSTGRESQL)
@@ -293,12 +253,8 @@ if (BUILD_POSTGRESQL)
293253
message(STATUS "libpq inc path:" ${PG_INCLUDE_DIRS})
294254
message(STATUS "libpq lib:" ${PG_LIBRARIES})
295255
target_link_libraries(${PROJECT_NAME} PRIVATE pg_lib)
296-
set(DROGON_SOURCES
297-
${DROGON_SOURCES}
256+
set(DROGON_SOURCES ${DROGON_SOURCES}
298257
orm_lib/src/postgresql_impl/PostgreSQLResultImpl.cc)
299-
set(private_headers
300-
${private_headers}
301-
orm_lib/src/postgresql_impl/PostgreSQLResultImpl.h)
302258
if (LIBPQ_BATCH_MODE)
303259
try_compile(libpq_supports_batch ${CMAKE_BINARY_DIR}/cmaketest
304260
${PROJECT_SOURCE_DIR}/cmake/tests/test_libpq_batch_mode.cc
@@ -308,17 +264,12 @@ if (BUILD_POSTGRESQL)
308264
if (libpq_supports_batch)
309265
message(STATUS "The libpq supports batch mode")
310266
option(LIBPQ_SUPPORTS_BATCH_MODE "libpq batch mode" ON)
311-
set(DROGON_SOURCES
312-
${DROGON_SOURCES}
267+
set(DROGON_SOURCES ${DROGON_SOURCES}
313268
orm_lib/src/postgresql_impl/PgBatchConnection.cc)
314269
else (libpq_supports_batch)
315270
option(LIBPQ_SUPPORTS_BATCH_MODE "libpq batch mode" OFF)
316-
set(DROGON_SOURCES
317-
${DROGON_SOURCES}
271+
set(DROGON_SOURCES ${DROGON_SOURCES}
318272
orm_lib/src/postgresql_impl/PgConnection.cc)
319-
set(private_headers
320-
${private_headers}
321-
orm_lib/src/postgresql_impl/PgConnection.h)
322273
endif (libpq_supports_batch)
323274
endif (pg_FOUND)
324275
endif (BUILD_POSTGRESQL)
@@ -329,14 +280,9 @@ if (BUILD_MYSQL)
329280
if (MySQL_FOUND)
330281
message(STATUS "Ok! We find the mariadb!")
331282
target_link_libraries(${PROJECT_NAME} PRIVATE MySQL_lib)
332-
set(DROGON_SOURCES
333-
${DROGON_SOURCES}
283+
set(DROGON_SOURCES ${DROGON_SOURCES}
334284
orm_lib/src/mysql_impl/MysqlConnection.cc
335285
orm_lib/src/mysql_impl/MysqlResultImpl.cc)
336-
set(private_headers
337-
${private_headers}
338-
orm_lib/src/mysql_impl/MysqlConnection.h
339-
orm_lib/src/mysql_impl/MysqlResultImpl.h)
340286
endif (MySQL_FOUND)
341287
endif (BUILD_MYSQL)
342288

@@ -345,14 +291,9 @@ if (BUILD_SQLITE)
345291
find_package(SQLite3)
346292
if (SQLite3_FOUND)
347293
target_link_libraries(${PROJECT_NAME} PRIVATE SQLite3_lib)
348-
set(DROGON_SOURCES
349-
${DROGON_SOURCES}
294+
set(DROGON_SOURCES ${DROGON_SOURCES}
350295
orm_lib/src/sqlite3_impl/Sqlite3Connection.cc
351296
orm_lib/src/sqlite3_impl/Sqlite3ResultImpl.cc)
352-
set(private_headers
353-
${private_headers}
354-
orm_lib/src/sqlite3_impl/Sqlite3Connection.h
355-
orm_lib/src/sqlite3_impl/Sqlite3ResultImpl.h)
356297
endif (SQLite3_FOUND)
357298
endif (BUILD_SQLITE)
358299

@@ -364,17 +305,11 @@ if (BUILD_REDIS)
364305
set(DROGON_SOURCES
365306
${DROGON_SOURCES}
366307
nosql_lib/redis/src/RedisClientImpl.cc
367-
nosql_lib/redis/src/RedisClientLockFree.cc
368-
nosql_lib/redis/src/RedisClientManager.cc
369308
nosql_lib/redis/src/RedisConnection.cc
370309
nosql_lib/redis/src/RedisResult.cc
310+
nosql_lib/redis/src/RedisClientLockFree.cc
311+
nosql_lib/redis/src/RedisClientManager.cc
371312
nosql_lib/redis/src/RedisTransactionImpl.cc)
372-
set(private_headers
373-
${private_headers}
374-
nosql_lib/redis/src/RedisClientImpl.h
375-
nosql_lib/redis/src/RedisClientLockFree.h
376-
nosql_lib/redis/src/RedisConnection.h
377-
nosql_lib/redis/src/RedisTransactionImpl.h)
378313

379314
endif (Hiredis_FOUND)
380315
endif (BUILD_REDIS)
@@ -385,9 +320,6 @@ if (NOT Hiredis_FOUND)
385320
lib/src/RedisClientSkipped.cc
386321
lib/src/RedisResultSkipped.cc
387322
lib/src/RedisClientManagerSkipped.cc)
388-
set(private_headers
389-
${private_headers}
390-
lib/src/RedisClientManager.h)
391323
endif (NOT Hiredis_FOUND)
392324

393325
if (BUILD_TESTING)
@@ -401,14 +333,8 @@ find_package(OpenSSL)
401333
if (OpenSSL_FOUND)
402334
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
403335
else (OpenSSL_FOUND)
404-
set(DROGON_SOURCES
405-
${DROGON_SOURCES}
406-
lib/src/ssl_funcs/Md5.cc
336+
set(DROGON_SOURCES ${DROGON_SOURCES} lib/src/ssl_funcs/Md5.cc
407337
lib/src/ssl_funcs/Sha1.cc)
408-
set(private_headers
409-
${private_headers}
410-
lib/src/ssl_funcs/Md5.h
411-
lib/src/ssl_funcs/Sha1.h)
412338
endif (OpenSSL_FOUND)
413339

414340
execute_process(COMMAND "git" rev-parse HEAD
@@ -457,57 +383,16 @@ set(DROGON_SOURCES
457383
orm_lib/src/SqlBinder.cc
458384
orm_lib/src/TransactionImpl.cc
459385
orm_lib/src/RestfulController.cc)
460-
set(DROGON_HEADERS
461-
lib/inc/drogon/Attribute.h
462-
lib/inc/drogon/CacheMap.h
463-
lib/inc/drogon/Cookie.h
464-
lib/inc/drogon/DrClassMap.h
465-
lib/inc/drogon/DrObject.h
466-
lib/inc/drogon/DrTemplate.h
467-
lib/inc/drogon/DrTemplateBase.h
468-
lib/inc/drogon/HttpAppFramework.h
469-
lib/inc/drogon/HttpBinder.h
470-
lib/inc/drogon/HttpClient.h
471-
lib/inc/drogon/HttpController.h
472-
lib/inc/drogon/HttpFilter.h
473-
lib/inc/drogon/HttpRequest.h
474-
lib/inc/drogon/HttpResponse.h
475-
lib/inc/drogon/HttpSimpleController.h
476-
lib/inc/drogon/HttpTypes.h
477-
lib/inc/drogon/HttpViewData.h
478-
lib/inc/drogon/IntranetIpFilter.h
479-
lib/inc/drogon/IOThreadStorage.h
480-
lib/inc/drogon/LocalHostFilter.h
481-
lib/inc/drogon/MultiPart.h
482-
lib/inc/drogon/NotFound.h
483-
lib/inc/drogon/Session.h
484-
lib/inc/drogon/UploadFile.h
485-
lib/inc/drogon/WebSocketClient.h
486-
lib/inc/drogon/WebSocketConnection.h
487-
lib/inc/drogon/WebSocketController.h
488-
lib/inc/drogon/drogon.h
489-
lib/inc/drogon/version.h
490-
lib/inc/drogon/drogon_callbacks.h
491-
lib/inc/drogon/PubSubService.h
492-
lib/inc/drogon/drogon_test.h
493-
${CMAKE_CURRENT_BINARY_DIR}/exports/drogon/exports.h)
494-
set(private_headers
495-
${private_headers}
496-
lib/src/DbClientManager.h
497-
orm_lib/src/DbClientImpl.h
498-
orm_lib/src/DbConnection.h
499-
orm_lib/src/ResultImpl.h
500-
orm_lib/src/TransactionImpl.h)
501386
if (pg_FOUND OR MySQL_FOUND OR SQLite3_FOUND)
502387
set(DROGON_SOURCES
503388
${DROGON_SOURCES}
504389
orm_lib/src/DbClientManager.cc)
505390
else (pg_FOUND OR MySQL_FOUND OR SQLite3_FOUND)
506-
set(DROGON_SOURCES
507-
${DROGON_SOURCES}
508-
lib/src/DbClientManagerSkipped.cc)
391+
set(DROGON_SOURCES ${DROGON_SOURCES} lib/src/DbClientManagerSkipped.cc)
509392
endif (pg_FOUND OR MySQL_FOUND OR SQLite3_FOUND)
510393

394+
target_sources(${PROJECT_NAME} PRIVATE ${DROGON_SOURCES})
395+
511396
set_target_properties(${PROJECT_NAME}
512397
PROPERTIES CXX_STANDARD ${DROGON_CXX_STANDARD})
513398
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD_REQUIRED ON)
@@ -587,6 +472,40 @@ install(TARGETS ${PROJECT_NAME}
587472
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
588473
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib)
589474

475+
set(DROGON_HEADERS
476+
lib/inc/drogon/Attribute.h
477+
lib/inc/drogon/CacheMap.h
478+
lib/inc/drogon/Cookie.h
479+
lib/inc/drogon/DrClassMap.h
480+
lib/inc/drogon/DrObject.h
481+
lib/inc/drogon/DrTemplate.h
482+
lib/inc/drogon/DrTemplateBase.h
483+
lib/inc/drogon/HttpAppFramework.h
484+
lib/inc/drogon/HttpBinder.h
485+
lib/inc/drogon/HttpClient.h
486+
lib/inc/drogon/HttpController.h
487+
lib/inc/drogon/HttpFilter.h
488+
lib/inc/drogon/HttpRequest.h
489+
lib/inc/drogon/HttpResponse.h
490+
lib/inc/drogon/HttpSimpleController.h
491+
lib/inc/drogon/HttpTypes.h
492+
lib/inc/drogon/HttpViewData.h
493+
lib/inc/drogon/IntranetIpFilter.h
494+
lib/inc/drogon/IOThreadStorage.h
495+
lib/inc/drogon/LocalHostFilter.h
496+
lib/inc/drogon/MultiPart.h
497+
lib/inc/drogon/NotFound.h
498+
lib/inc/drogon/Session.h
499+
lib/inc/drogon/UploadFile.h
500+
lib/inc/drogon/WebSocketClient.h
501+
lib/inc/drogon/WebSocketConnection.h
502+
lib/inc/drogon/WebSocketController.h
503+
lib/inc/drogon/drogon.h
504+
lib/inc/drogon/version.h
505+
lib/inc/drogon/drogon_callbacks.h
506+
lib/inc/drogon/PubSubService.h
507+
lib/inc/drogon/drogon_test.h
508+
${CMAKE_CURRENT_BINARY_DIR}/exports/drogon/exports.h)
590509
install(FILES ${DROGON_HEADERS} DESTINATION ${INSTALL_INCLUDE_DIR}/drogon)
591510

592511
set(ORM_HEADERS
@@ -607,8 +526,7 @@ set(ORM_HEADERS
607526
orm_lib/inc/drogon/orm/RestfulController.h)
608527
install(FILES ${ORM_HEADERS} DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/orm)
609528

610-
set(NOSQL_HEADERS
611-
nosql_lib/redis/inc/drogon/nosql/RedisClient.h
529+
set(NOSQL_HEADERS nosql_lib/redis/inc/drogon/nosql/RedisClient.h
612530
nosql_lib/redis/inc/drogon/nosql/RedisResult.h
613531
nosql_lib/redis/inc/drogon/nosql/RedisException.h)
614532
install(FILES ${NOSQL_HEADERS} DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/nosql)
@@ -625,32 +543,19 @@ set(DROGON_UTIL_HEADERS
625543
install(FILES ${DROGON_UTIL_HEADERS}
626544
DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/utils)
627545

628-
set(DROGON_PLUGIN_HEADERS
629-
lib/inc/drogon/plugins/Plugin.h
546+
set(DROGON_PLUGIN_HEADERS lib/inc/drogon/plugins/Plugin.h
630547
lib/inc/drogon/plugins/SecureSSLRedirector.h
631548
lib/inc/drogon/plugins/AccessLogger.h)
632549
install(FILES ${DROGON_PLUGIN_HEADERS}
633550
DESTINATION ${INSTALL_INCLUDE_DIR}/drogon/plugins)
634551

635-
target_sources(${PROJECT_NAME} PRIVATE
636-
${DROGON_SOURCES}
637-
${private_headers}
638-
${DROGON_HEADERS}
639-
${ORM_HEADERS}
640-
${DROGON_UTIL_HEADERS}
641-
${DROGON_PLUGIN_HEADERS}
642-
${NOSQL_HEADERS})
643-
644552
source_group("Public API"
645553
FILES
646554
${DROGON_HEADERS}
647555
${ORM_HEADERS}
648556
${DROGON_UTIL_HEADERS}
649557
${DROGON_PLUGIN_HEADERS}
650558
${NOSQL_HEADERS})
651-
source_group("Private Headers"
652-
FILES
653-
${private_headers})
654559

655560
# Export the package for use from the build-tree (this registers the build-tree
656561
# with a global cmake-registry) export(PACKAGE Drogon)
@@ -692,42 +597,3 @@ install(EXPORT DrogonTargets
692597
NAMESPACE Drogon::
693598
COMPONENT dev)
694599

695-
# Doxygen documentation
696-
find_package(Doxygen OPTIONAL_COMPONENTS dot dia)
697-
if(DOXYGEN_FOUND)
698-
set(DOXYGEN_PROJECT_BRIEF "C++14/17-based HTTP application framework")
699-
set(DOXYGEN_OUTPUT_DIRECTORY docs/${PROJECT_NAME})
700-
set(DOXYGEN_GENERATE_LATEX NO)
701-
set(DOXYGEN_BUILTIN_STL_SUPPORT YES)
702-
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE README.md)
703-
set(DOXYGEN_STRIP_FROM_INC_PATH ${PROJECT_SOURCE_DIR}/lib/inc
704-
${PROJECT_SOURCE_DIR}/orm_lib/inc
705-
${CMAKE_CURRENT_BINARY_DIR}/exports)
706-
set(DOXYGEN_EXAMPLE_PATTERNS *)
707-
if(WIN32)
708-
set(DOXYGEN_PREDEFINED _WIN32)
709-
endif(WIN32)
710-
doxygen_add_docs(doc_${PROJECT_NAME}
711-
README.md
712-
README.zh-CN.md
713-
README.zh-TW.md
714-
ChangeLog.md
715-
CONTRIBUTING.md
716-
${DROGON_HEADERS}
717-
${DROGON_UTIL_HEADERS}
718-
${DROGON_PLUGIN_HEADERS}
719-
${ORM_HEADERS}
720-
COMMENT "Generate documentation")
721-
if(NOT TARGET doc)
722-
add_custom_target(doc)
723-
endif()
724-
add_dependencies(doc doc_${PROJECT_NAME})
725-
if (BUILD_DOC)
726-
add_dependencies(${PROJECT_NAME} doc_${PROJECT_NAME})
727-
# Don't install twice, so limit to Debug (assume developer)
728-
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs/${PROJECT_NAME}
729-
TYPE DOC
730-
CONFIGURATIONS Debug)
731-
endif(BUILD_DOC)
732-
endif(DOXYGEN_FOUND)
733-

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![Build Status](https://travis-ci.com/an-tao/drogon.svg?branch=master)](https://travis-ci.com/an-tao/drogon)
44
![Build Status](https://github.com/an-tao/drogon/workflows/Build%20Drogon/badge.svg?branch=master)
5+
[![Build status](https://ci.appveyor.com/api/projects/status/12ffuf6j5vankgyb/branch/master?svg=true)](https://ci.appveyor.com/project/an-tao/drogon/branch/master)
56
[![Total alerts](https://img.shields.io/lgtm/alerts/g/an-tao/drogon.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/an-tao/drogon/alerts/)
67
[![Join the chat at https://gitter.im/drogon-web/community](https://badges.gitter.im/drogon-web/community.svg)](https://gitter.im/drogon-web/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
78
[![Join the telegram group at https://t.me/joinchat/_mMNGv0748ZkMDAx](https://img.shields.io/badge/Telegram-2CA5E0?style=flat&logo=telegram&logoColor=white)](https://t.me/joinchat/_mMNGv0748ZkMDAx)

README.zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![Build Status](https://travis-ci.com/an-tao/drogon.svg?branch=master)](https://travis-ci.com/an-tao/drogon)
44
![Build Status](https://github.com/an-tao/drogon/workflows/Build%20Drogon/badge.svg?branch=master)
5+
[![Build status](https://ci.appveyor.com/api/projects/status/12ffuf6j5vankgyb/branch/master?svg=true)](https://ci.appveyor.com/project/an-tao/drogon/branch/master)
56
[![Total alerts](https://img.shields.io/lgtm/alerts/g/an-tao/drogon.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/an-tao/drogon/alerts/)
67
[![Join the chat at https://gitter.im/drogon-web/community](https://badges.gitter.im/drogon-web/community.svg)](https://gitter.im/drogon-web/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
78
[![Join the telegram group at https://t.me/joinchat/_mMNGv0748ZkMDAx](https://img.shields.io/badge/Telegram-2CA5E0?style=flat&logo=telegram&logoColor=white)](https://t.me/joinchat/_mMNGv0748ZkMDAx)

README.zh-TW.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![Build Status](https://travis-ci.com/an-tao/drogon.svg?branch=master)](https://travis-ci.com/an-tao/drogon)
44
![Build Status](https://github.com/an-tao/drogon/workflows/Build%20Drogon/badge.svg?branch=master)
5+
[![Build status](https://ci.appveyor.com/api/projects/status/12ffuf6j5vankgyb/branch/master?svg=true)](https://ci.appveyor.com/project/an-tao/drogon/branch/master)
56
[![Total alerts](https://img.shields.io/lgtm/alerts/g/an-tao/drogon.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/an-tao/drogon/alerts/)
67
[![Join the chat at https://gitter.im/drogon-web/community](https://badges.gitter.im/drogon-web/community.svg)](https://gitter.im/drogon-web/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
78
[![Join the telegram group at https://t.me/joinchat/_mMNGv0748ZkMDAx](https://img.shields.io/badge/Telegram-2CA5E0?style=flat&logo=telegram&logoColor=white)](https://t.me/joinchat/_mMNGv0748ZkMDAx)

cmake/templates/DrogonConfig.cmake.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ get_filename_component(DROGON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
5050
if(NOT TARGET Drogon::Drogon)
5151
include("${DROGON_CMAKE_DIR}/DrogonTargets.cmake")
5252
include("${DROGON_CMAKE_DIR}/DrogonUtilities.cmake")
53-
include("${DROGON_CMAKE_DIR}/ParseAndAddDrogonTests.cmake")
5453
endif()
5554

5655
get_target_property(DROGON_INCLUDE_DIRS Drogon::Drogon INTERFACE_INCLUDE_DIRECTORIES)

0 commit comments

Comments
 (0)