example-crud icon indicating copy to clipboard operation
example-crud copied to clipboard

undefined `SWAGGER_ROOT_PATH`

Open zeyuanxy opened this issue 2 years ago • 4 comments

Hi, when I was trying to build this example project. I got this error:

[2/3] Building CXX object CMakeFiles/crud-exe.dir/src/App.cpp.o
FAILED: CMakeFiles/crud-exe.dir/src/App.cpp.o 
/Library/Developer/CommandLineTools/usr/bin/c++ -DDATABASE_FILE=\"/Users/zeyuan.shang/Coding/web/example-crud/db.sqlite\" -DDATABASE_MIGRATIONS=\"/Users/zeyuan.shang/Coding/web/example-crud/sql\" -DOATPP_SWAGGER_RES_PATH=\"/usr/local/include/oatpp-1.3.0/oatpp-swagger//../bin/oatpp-swagger/res\" -DTESTDATABASE_FILE=\"/Users/zeyuan.shang/Coding/web/example-crud/test-db.sqlite\" -I/Users/zeyuan.shang/Coding/web/example-crud/src -isystem /usr/local/include/oatpp-1.3.0/oatpp -isystem /usr/local/include/oatpp-1.3.0/oatpp-swagger -isystem /usr/local/include/oatpp-1.3.0/oatpp-sqlite -isystem /usr/local/include/oatpp-1.3.0/oatpp-sqlite/sqlite -g -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -std=gnu++11 -MD -MT CMakeFiles/crud-exe.dir/src/App.cpp.o -MF CMakeFiles/crud-exe.dir/src/App.cpp.o.d -o CMakeFiles/crud-exe.dir/src/App.cpp.o -c /Users/zeyuan.shang/Coding/web/example-crud/src/App.cpp
In file included from /Users/zeyuan.shang/Coding/web/example-crud/src/App.cpp:7:
/usr/local/include/oatpp-1.3.0/oatpp-swagger/oatpp-swagger/Controller.hpp:104:37: error: expected ':'
  ENDPOINT("GET", SWAGGER_ROOT_PATH SWAGGER_UI_PATH, getUIRoot) {

It seems that SWAGGER_ROOT_PATH is undefined? Any idea on how to fix this would be appreciated, thanks!

zeyuanxy avatar Apr 27 '22 20:04 zeyuanxy

This seems to be a regression introduced by https://github.com/oatpp/oatpp-swagger/commit/652f95c6fbc31d8bc17f94fd7820fba01399e8ec

Those variables were not introduced to the module-cmake. We'll fix it asap. Please use the previous commit in the meantime.

bamkrs avatar Apr 28 '22 06:04 bamkrs

set(SWAGGER_ROOT_PATH "/swagger" CACHE STRING "Default root path to the Swagger") set(SWAGGER_UI_PATH "/ui" CACHE STRING "Default path suffix to the Swagger UI") add_compile_definitions( SWAGGER_ROOT_PATH="${SWAGGER_ROOT_PATH}" SWAGGER_UI_PATH="${SWAGGER_UI_PATH}" )

quick fix in cmake ^

roqerxz avatar May 10 '22 05:05 roqerxz

set(SWAGGER_ROOT_PATH "/swagger" CACHE STRING "Default root path to the Swagger") set(SWAGGER_UI_PATH "/ui" CACHE STRING "Default path suffix to the Swagger UI") add_compile_definitions( SWAGGER_ROOT_PATH="${SWAGGER_ROOT_PATH}" SWAGGER_UI_PATH="${SWAGGER_UI_PATH}" )

quick fix in cmake ^

Same Problem, Can you show me the specific path? I am new to C++,should me write the path as follows(CMakeLists.txt of oatpp-swagger)? this not work.

set(SWAGGER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "Default root path to the Swagger")
set(SWAGGER_UI_PATH "/res" CACHE STRING "Default path suffix to the Swagger UI")

Here are some information about my PC:

apples-Mac-mini:oatpp-swagger apple$ pwd
/usr/local/include/oatpp-1.3.0/oatpp-swagger
apples-Mac-mini:oatpp-swagger apple$ tree -L 3
.
└── oatpp-swagger
    ├── AsyncController.hpp
    ├── Controller.hpp
    ├── Generator.hpp
    ├── Model.hpp
    ├── Resources.hpp
    ├── Types.hpp
    └── oas3
        └── Model.hpp

2 directories, 7 files


apples-Mac-mini:example-crud apple$ pwd
/Users/apple/Documents/Repositories/Oatpp/examples/example-crud
apples-Mac-mini:example-crud apple$ tree -L 2
.
├── CMakeLists.txt
├── Dockerfile
├── LICENSE
├── README.md
├── azure-pipelines.yml
├── build
│   ├── CMakeCache.txt
│   ├── CMakeFiles
│   ├── CTestTestfile.cmake
│   ├── Makefile
│   ├── cmake_install.cmake
│   ├── crud-test
│   └── libcrud-lib.a
├── cmake-build-debug
│   ├── CMakeCache.txt
│   ├── CMakeFiles
│   ├── CTestTestfile.cmake
│   ├── Makefile
│   ├── cmake_install.cmake
│   └── crud.cbp
├── oatpp-sqlite
│   ├── CMakeLists.txt
│   ├── LICENSE
│   ├── README.md
│   ├── azure-pipelines.yml
│   ├── build
│   ├── cmake
│   ├── src
│   └── test
├── oatpp-swagger
│   ├── CMakeLists.txt
│   ├── LICENSE
│   ├── README.md
│   ├── azure-pipelines.yml
│   ├── build
│   ├── cmake
│   ├── res
│   ├── src
│   ├── test
│   └── utility
├── sql
│   └── 001_init.sql
├── src
│   ├── App.cpp
│   ├── AppComponent.hpp
│   ├── DatabaseComponent.hpp
│   ├── ErrorHandler.cpp
│   ├── ErrorHandler.hpp
│   ├── SwaggerComponent.hpp
│   ├── controller
│   ├── db
│   ├── dto
│   └── service
├── test
│   ├── UserControllerTest.cpp
│   ├── UserControllerTest.hpp
│   ├── app
│   └── tests.cpp
├── tmp
│   └── build
└── utility
    └── install-oatpp-modules.sh

9 directories, 5 files

LShuXin avatar May 15 '22 17:05 LShuXin

here solved the problem https://github.com/oatpp/example-crud/pull/23

LShuXin avatar May 22 '22 11:05 LShuXin