Skip to content

Commit 7ffcfb1

Browse files
committed
Make cpp-boost-beast work after bitrot.
* Fixed names of the approval files for ApiTests. * Silence warnings due to boost/property_tree/json_parser.hpp * ApprovalTests only works when not using header-only boost::test * More clean shutdown of imposter when test(s) fail * Update petstore-config.yaml test config to add explicit values for all tested enpoints, rather than relying on imposter-provided default values. As of v4.5.2, imposter's defaults have changed. * Fixed CppBoostBeastClientCodegen compilation error triggered by refactoring of getAdditionalProperties(Schema) -> ModelUtils.
1 parent ca89a97 commit 7ffcfb1

20 files changed

Lines changed: 113 additions & 18 deletions

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppBoostBeastClientCodegen.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public String getTypeDeclaration(Schema p) {
294294
Schema inner = ap.getItems();
295295
return getSchemaType(p) + "<" + getTypeDeclaration(inner) + ">";
296296
} else if (ModelUtils.isMapSchema(p)) {
297-
Schema inner = getAdditionalProperties(p);
297+
Schema inner = ModelUtils.getAdditionalProperties(p);
298298
return getSchemaType(p) + "<std::string, " + getTypeDeclaration(inner) + ">";
299299
} else if (ModelUtils.isByteArraySchema(p)) {
300300
return "std::string";
@@ -369,7 +369,7 @@ public String toDefaultValue(Schema p) {
369369
return "\"\"";
370370
}
371371
} else if (ModelUtils.isMapSchema(p)) {
372-
String inner = getSchemaType(getAdditionalProperties(p));
372+
String inner = getSchemaType(ModelUtils.getAdditionalProperties(p));
373373
return "std::map<std::string, " + inner + ">()";
374374
} else if (ModelUtils.isArraySchema(p)) {
375375
ArraySchema ap = (ArraySchema) p;

modules/openapi-generator/src/main/resources/cpp-boost-beast-client/CMakeLists.txt.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,7 @@ target_link_libraries(${LIBRARY_NAME} PUBLIC boost_system ssl crypto)
4242

4343
target_include_directories(${LIBRARY_NAME} PUBLIC model api ${CMAKE_CURRENT_LIST_DIR})
4444

45+
# silence warnings from boost/property_tree/json_parser.hpp
46+
target_compile_definitions(${LIBRARY_NAME} PRIVATE BOOST_BIND_GLOBAL_PLACEHOLDERS)
4547

4648
install(TARGETS ${LIBRARY_NAME} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)

samples/client/petstore/cpp-boost-beast/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ set(CMAKE_CXX_STANDARD 17)
66
set(CMAKE_CXX_STANDARD_REQUIRED ON)
77
set(CMAKE_CXX_EXTENSIONS OFF)
88

9-
find_package(Boost 1.66.0 REQUIRED)
9+
find_package(Boost 1.66 REQUIRED COMPONENTS unit_test_framework)
10+
if (NOT Boost_FOUND)
11+
message(FATAL_ERROR "Cannot find Boost libraries")
12+
endif ()
1013

14+
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
1115

1216
# Coverage
1317
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

samples/client/petstore/cpp-boost-beast/generated/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,7 @@ target_link_libraries(${LIBRARY_NAME} PUBLIC boost_system ssl crypto)
3939

4040
target_include_directories(${LIBRARY_NAME} PUBLIC model api ${CMAKE_CURRENT_LIST_DIR})
4141

42+
# silence warnings from boost/property_tree/json_parser.hpp
43+
target_compile_definitions(${LIBRARY_NAME} PRIVATE BOOST_BIND_GLOBAL_PLACEHOLDERS)
4244

4345
install(TARGETS ${LIBRARY_NAME} RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)

samples/client/petstore/cpp-boost-beast/tests/api/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ target_link_libraries(api_tests
2121
client
2222
${Boost_LIBRARIES})
2323

24+
target_compile_definitions(api_tests
25+
PUBLIC
26+
BOOST_TEST_DYN_LINK)
2427

2528
add_test(NAME api_tests
2629
COMMAND_EXPAND_LISTS
2730
COMMAND
28-
${CMAKE_CURRENT_LIST_DIR}/run_imposter_for_tests.sh ${CMAKE_CURRENT_BINARY_DIR}/api_tests)
31+
${CMAKE_CURRENT_LIST_DIR}/run_imposter_for_tests.sh ${CMAKE_CURRENT_BINARY_DIR}/api_tests)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.received.txt

samples/client/petstore/cpp-boost-beast/tests/api/approval_files/pet_api_test.ModelTests.PetApiTest.findPetsByStatus.approved.txt renamed to samples/client/petstore/cpp-boost-beast/tests/api/approval_files/pet_api_test.ApiTests.PetApiTest.findPetsByStatus.approved.txt

File renamed without changes.

samples/client/petstore/cpp-boost-beast/tests/api/approval_files/pet_api_test.ModelTests.PetApiTest.findPetsByStatus_list.approved.txt renamed to samples/client/petstore/cpp-boost-beast/tests/api/approval_files/pet_api_test.ApiTests.PetApiTest.findPetsByStatus_list.approved.txt

File renamed without changes.

samples/client/petstore/cpp-boost-beast/tests/api/approval_files/pet_api_test.ModelTests.PetApiTest.findPetsByTags.approved.txt renamed to samples/client/petstore/cpp-boost-beast/tests/api/approval_files/pet_api_test.ApiTests.PetApiTest.findPetsByTags.approved.txt

File renamed without changes.

samples/client/petstore/cpp-boost-beast/tests/api/approval_files/pet_api_test.ModelTests.PetApiTest.getPetById_success.approved.txt renamed to samples/client/petstore/cpp-boost-beast/tests/api/approval_files/pet_api_test.ApiTests.PetApiTest.getPetById_success.approved.txt

File renamed without changes.

0 commit comments

Comments
 (0)