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

I must be missing something ... #4

Open
ehallander9591 opened this issue Apr 23, 2022 · 1 comment
Open

I must be missing something ... #4

ehallander9591 opened this issue Apr 23, 2022 · 1 comment

Comments

@ehallander9591
Copy link

My interpretation using this was that I only needed to use the oatpp::protobuf::Object instead of the oatpp::Object template as in

ENDPOINT_INFO(hasPointToPointLOS) {
info->summary = "Given two instances of a location and height on a map determine if the two points have a LOS vector between them withing the fidelity of the number_of_steps to examine the LOS vector.";

info->addConsumes<oatpp::protobuf::Object<HasLineOfSightRequest>>("application/json");

info->addResponse<oatpp::protobuf::Object<HasLineOfSightResponse>>(Status::CODE_200, "application/json");

}
ENDPOINT("POST", "hasPointToPointLOS", hasPointToPointLOS,
BODY_DTO(oatpp::protobuf::Object, requestDto))
{
return createDtoResponse(Status::CODE_200, m_terrainService.hasPointToPointLineOfSight(requestDto));
}

however the swagger shows

"Unknown Type: oatpp::protobuf::AbstractObject"

as my payload json, and if push through and type in a valid json object for my request object, say such as

{
"locationFrom": {
"latitude": 0.0,
"longitude": 0.0
},
"locationTo": {
"latitude": 0.0,
"longitude": 0.0
},
"numberOfSteps": 10
}

That leads to deserialization error

{
"status": "ERROR",
"code": 500,
"message": "[oatpp::parser::json::mapping::Deserializer::deserialize()]: Error. No deserialize method for type 'oatpp::protobuf::AbstractObject'"
}

So, I must be missing something, and am ready to move onto a different C++ Rest framework.

There is some plumbing concerning getting the oatpp::protobuf::Object to get all that toInterpretation fromInterpretation working, but I don't see it yet.

FYI, I have this built against 1.2.5 oatpp on Windows 10 using VS 2017 Pro.

@darkpursuer
Copy link

After some investigation, you need to specify the protobuf when creating the object_mapper:

auto serializer_config =
      oatpp::parser::json::mapping::Serializer::Config::createShared();
serializer_config->enabledInterpretations.push_back("protobuf");
auto deserializer_config =
    oatpp::parser::json::mapping::Deserializer::Config::createShared();
deserializer_config->enabledInterpretations.push_back("protobuf");
auto objectMapper = oatpp::parser::json::mapping::ObjectMapper::createShared(
    serializer_config, deserializer_config);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants