You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am using OpenAPI generator to generate Restbed C++ API server. Here is what I've noticed in the generated GET handler: for some reason resultObject never gets parsed, and the result is empty. Here is this handler from the OpenAPI Generator repository, line 483,:
void PetApiPetFindByStatusResource::handler_GET_internal(const std::shared_ptr<restbed::Session> session)
{
const auto request = session->get_request();
// Getting the query params
int status_code = 500;
std::vector<std::shared_ptr<Pet>> resultObject = std::vector<std::shared_ptr<Pet>>();
std::string result = "";
try {
std::tie(status_code, resultObject) =
handler_GET(status);
}
catch(const PetApiException& e) {
std::tie(status_code, result) = handlePetApiException(e);
}
catch(const std::exception& e) {
std::tie(status_code, result) = handleStdException(e);
}
catch(...) {
std::tie(status_code, result) = handleUnspecifiedException();
}
if (status_code == 200) {
const constexpr auto contentType = "application/json";
//I want to return the result here
returnResponse(session, 200, result.empty() ? "successful operation" : result, contentType);
return;
}
if (status_code == 400) {
const constexpr auto contentType = "text/plain";
returnResponse(session, 400, result.empty() ? "Invalid status value" : result, contentType);
return;
}
defaultSessionClose(session, status_code, result);
}
I can observe the same results for my project while using Restbed generator. I think the only way to fix it is to add some sort of result = resultObject.to_json_string() every time API is re-generated but this is not how it should work. Is there any workaround?
Could it be the wrong .json usage? The .json file I use for this code is this:
Hi, I am using OpenAPI generator to generate Restbed C++ API server. Here is what I've noticed in the generated GET handler: for some reason
resultObject
never gets parsed, and theresult
is empty. Here is this handler from the OpenAPI Generator repository, line 483,:I can observe the same results for my project while using Restbed generator. I think the only way to fix it is to add some sort of
result = resultObject.to_json_string()
every time API is re-generated but this is not how it should work. Is there any workaround?Could it be the wrong .json usage? The .json file I use for this code is this:
{ "openapi": "3.0.0", "info": { "version": "1.0.0", "title": "My API" }, "paths": { "/myobject": { "get": { "responses": { "200": { "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/MyObject" } } } } }, "default": { "description": "unexpected error" } } } } }, "components": { "schemas": { "MyObject": { "type": "object", "properties": { "prop1": { "type": "string" }, "prop2": { "type": "number" } } } } } }
The text was updated successfully, but these errors were encountered: