openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[C++][Restbed-server] Compilation error from missing header "ByteArray.h"

Open vbs96 opened this issue 8 years ago • 9 comments

Description

The Restbed server generated code includes a header file that does not exists (ByteArray.h):

From Frame.h:

#ifndef Frame_H_
#define Frame_H_

#include <string>
#include "ByteArray.h"
#include "Event.h"
#include <map>
#include <vector>
#include <memory>
openapi-generator version

3.2.1 (cloned the master branch)

OpenAPI declaration file content or url

https://raw.githubusercontent.com/deepviss/deepviss-server-example/master/src/main/resources/deep-viss.json

Command line used for generation

Inside cloned repository, after mvn clean package command: java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate / -i deep-viss.json / -g cpp-restbed-server / -o ../openapi-restbed-server

Steps to reproduce

I used the following cmake file:

cmake_minimum_required(VERSION 3.10)
project(restbed_ex)

set(CMAKE_CXX_STANDARD 11)

file(GLOB_RECURSE src_files mode/*.cpp api/*.cpp)

add_executable(restbed_ex main.cpp ${src_files})
target_include_directories(restbed_ex PRIVATE /restbed/include/)
target_include_directories(restbed_ex PRIVATE model/)
target_include_directories(restbed_ex PRIVATE api/)
target_link_libraries(restbed_ex restbed)

Note: Assuming restbed/include is the folder with restbed include files (https://github.com/Corvusoft/restbed) and that you copied the json.hpp file from https://github.com/nlohmann/json to model folder

The content of main.cpp file is redundant as the compilation won't pass the line where "ByteArray.h" is included (that is model/Frame.cpp)

vbs96 avatar Aug 06 '18 15:08 vbs96

There is no remapping for ByteArray in RestBed yet. So we have to implement this.

etherealjoy avatar Aug 06 '18 17:08 etherealjoy

@etherealjoy Can you suggest any work-around until this is implemented?

bocse avatar Aug 06 '18 17:08 bocse

Sadly there is no workaround. I made an implementation for Pistache and REST SDK in this PR #497. We need to do something like this for Restbed

etherealjoy avatar Aug 06 '18 17:08 etherealjoy

Could you please advise on how to make this work on Pistache? (We have no preference between Restbed and Pistache)

bocse avatar Aug 06 '18 17:08 bocse

On Pistache it is already working. A defect was raised for it previously and was fixed. https://github.com/OpenAPITools/openapi-generator/issues/407

etherealjoy avatar Aug 06 '18 17:08 etherealjoy

Restbed Generated code doesnt use the json.hpp file from nlohmann. It uses the boost library for the json handling.

stkrwork avatar Aug 06 '18 23:08 stkrwork

Added the fix from pistache to restbed in #752, can you try with that version?

stkrwork avatar Aug 07 '18 00:08 stkrwork

Ok, it looks like the ByteArray problem is gone but the compilation is not passing. The following error occurs: api/FrameApi.cpp:70:91: error: expected primary-expression before ‘)’ token const bool includePictureBase64 = request->get_query_parameter("includePictureBase64", ); As you can see the second parameter is missing from the function call. Shall I open a new Issue or just keep it here? Thanks for fixing the bug and for the quickness you responded :)

vbs96 avatar Aug 07 '18 14:08 vbs96

Make a new issue for it, it seems to be not connected to this issue

stkrwork avatar Aug 07 '18 14:08 stkrwork