-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[BUG] [C++][Pistache] cpp-pistache-server generating API include undefined "Object.h" #2769
Comments
👍 Thanks for opening this issue! The team will review the labels and make any necessary changes. |
Duplicate of #1827 |
|
Hello, Is this issue only a configuration file problem? I'm trying to work on this issue that also affects some others generators, but not all of them. I did few changes to make a test showing the problem on veterinarianVisit:
type: object
description: last veterinarian visit advice Debugging things, it looks that But
Is it only a configuration issue? |
Object for C++ pistache looks working correctly with: master...mlebihan:openapi-generator:any_type change (my test isn't accurate and working, but the generation looks to be) |
…fined "Object.h" (OpenAPITools#2769) Should handle Object.h, AnyType.h correctly. Set.h also tested. - #include Object.h removed and replaced by a typeMapping.put(object, nlohmann::json) like suggested in other issues - object had an invalid syntax: ':' instead of '::' in types with namespace - extra include of #include nlohmann/json.h removed when there's already #include <nlohmann/json.hpp> - nlohmann::json is excluded from model namespace Tested with custom petstore played, with suggested openapi specs coming from issues OpenAPITools#2769, OpenAPITools#10266, OpenAPITools#14234 ```bash rm -rf samples/server/petstore/cpp-pistache-everything/ && ./bin/generate-samples.sh ./bin/configs/cpp-pistache-server-cpp-pistache-everything.yaml && cd samples/server/petstore/cpp-pistache-everything/ && mkdir build && cd build && cmake .. && cmake --build . --parallel ```
…fined "Object.h" (OpenAPITools#2769) Should handle Object.h, AnyType.h correctly. Set.h also tested. - #include Object.h removed and replaced by a typeMapping.put(object, nlohmann::json) like suggested in other issues - object had an invalid syntax: ':' instead of '::' in types with namespace - extra include of #include nlohmann/json.h removed when there's already #include <nlohmann/json.hpp> - nlohmann::json is excluded from model namespace Tested with custom petstore played, with suggested openapi specs coming from issues OpenAPITools#2769, OpenAPITools#10266, OpenAPITools#14234 ```bash rm -rf samples/server/petstore/cpp-pistache-everything/ && ./bin/generate-samples.sh ./bin/configs/cpp-pistache-server-cpp-pistache-everything.yaml && cd samples/server/petstore/cpp-pistache-everything/ && mkdir build && cd build && cmake .. && cmake --build . --parallel ```
#18553) * [BUG] [C++][Pistache] cpp-pistache-server generating API include undefined "Object.h" (#2769) Should handle Object.h, AnyType.h correctly. Set.h also tested. - #include Object.h removed and replaced by a typeMapping.put(object, nlohmann::json) like suggested in other issues - object had an invalid syntax: ':' instead of '::' in types with namespace - extra include of #include nlohmann/json.h removed when there's already #include <nlohmann/json.hpp> - nlohmann::json is excluded from model namespace Tested with custom petstore played, with suggested openapi specs coming from issues #2769, #10266, #14234 ```bash rm -rf samples/server/petstore/cpp-pistache-everything/ && ./bin/generate-samples.sh ./bin/configs/cpp-pistache-server-cpp-pistache-everything.yaml && cd samples/server/petstore/cpp-pistache-everything/ && mkdir build && cd build && cmake .. && cmake --build . --parallel ``` * - Adding to samples/server/petstore cpp-pistache-everything * - .md and FILES missing
There's currently no tests available under pistache server. I've implemented a small server responding to get id, after having pulled master as the PR is merged. #include "PetApiImpl.h"
namespace org {
namespace openapitools {
namespace server {
namespace api {
using namespace org::openapitools::server::model;
/** A gifted dog */
Pet giftedDog;
/** Mammals category. */
Category mammals;
PetApiImpl::PetApiImpl(const std::shared_ptr<Pistache::Rest::Router>& rtr)
: PetApi(rtr)
{
// Mammals category
mammals.setId(879875);
mammals.setName("Mammals");
// Tags: domestic, noisy
Tag domestic;
domestic.setId(15);
domestic.setName("domestic");
Tag noisy;
noisy.setId(16);
noisy.setName("noisy");
// Photos
std::vector<std::string> photosUrls = {"https://1.com", "https://2.com"};
// Dog friends
Pet_bestFriends bestFriends;
bestFriends.setBestFriends({"Dizzie", "Dragonfly"});
// The dog
giftedDog.setId(1578923L);
giftedDog.setBestFriends(bestFriends);
giftedDog.setCategory(mammals);
giftedDog.setGoodies({"dog bowl", "comb"});
giftedDog.setName("Hercule");
giftedDog.setPhotoUrls(photosUrls);
giftedDog.setStatus("Asleep");
std::vector<Tag> tags = { domestic, noisy };
giftedDog.setTags(tags);
time_t now = time(0);
giftedDog.setVeterinarianVisit(now);
giftedDog.getCategory();
}
void PetApiImpl::add_pet(const Pet &pet, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void PetApiImpl::delete_pet(const int64_t &petId, const std::optional<Pistache::Http::Header::Raw> &apiKey, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void PetApiImpl::find_pets_by_status(const std::optional<std::vector<std::string>> &status, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void PetApiImpl::find_pets_by_tags(const std::optional<std::vector<std::string>> &tags, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void PetApiImpl::get_pet_by_id(const int64_t &petId, Pistache::Http::ResponseWriter &response) {
response.headers().add<Pistache::Http::Header::ContentType>(MIME(Application, Json));
nlohmann::json jsonParser;
nlohmann::to_json(jsonParser, giftedDog);
std::string json = to_string(jsonParser);
response.send(Pistache::Http::Code::Ok, json);
}
void PetApiImpl::update_pet(const Pet &pet, Pistache::Http::ResponseWriter &response) {
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void PetApiImpl::update_pet_with_form(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response){
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
void PetApiImpl::upload_file(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response){
response.send(Pistache::Http::Code::Ok, "Do some magic\n");
}
}
}
}
}
{
"bestFriends": {
"bestFriends": [
"Dizzie",
"Dragonfly"
]
},
"category": {
"id": 879875,
"name": "Mammals"
},
"goodies": [
"dog bowl",
"comb"
],
"id": 1578923,
"name": "Hercule",
"photoUrls": [
"https://1.com",
"https://2.com"
],
"status": "Asleep",
"tags": [
{
"id": 15,
"name": "domestic"
},
{
"id": 16,
"name": "noisy"
}
],
"veterinarianVisit": 1714881239
} |
Bug Report Checklist
Description
The generated Api.h file include "Obejct.h" which was not exist
The Obejct.h was not generated and used :
openapi-generator version
4.0.0-SNAPSHOT
OpenAPI declaration file content or url
swagger 2.0 but not openapi 3.0.0
Command line used for generation
Steps to reproduce
Generate the code then check the DefaultApi.h file.
Related issues/PRs
#2338 for C but not for C++
Suggest a fix
Remove the "Object.h" from DefaultApi.h file, maybe i don't know the reason why adding this, could someone point out?
The text was updated successfully, but these errors were encountered: