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

C++ generated code includes exceptions.hpp directly #5

Closed
Wandows95 opened this issue Jul 12, 2021 · 3 comments
Closed

C++ generated code includes exceptions.hpp directly #5

Wandows95 opened this issue Jul 12, 2021 · 3 comments

Comments

@Wandows95
Copy link

Hello, I've currently generated a C++ api from an api spec but the inclusion of

#include "/exceptions.hpp"

and

#include "rapidjson/document.h"

requires me to package my code and rapidjson inside of the boost library and is blocking compilation. Is that line referring to <boost/property_tree/exceptions.hpp>? Is there a way to only generate code that uses path list includes?

@pearmaster
Copy link
Owner

Hi @Wandows95 ,

I don't have time right at this moment to look into this, but thought I would point you in the right direction in case you're in a hurry.

The exceptions.hpp file comes from https://github.com/pearmaster/json-schema-codegen/blob/master/jsonschemacodegen/templates/cpp/exceptions.hpp.jinja2

While it looks like a template file, it is mostly static, and includes exception classes which are thrown when on a JSON-Schema validation error. The attempt here was to capture more information about where the validation error occurred.

@Wandows95
Copy link
Author

@pearmaster

Thank you very much for the info and quick response, it was really helpful. I managed to grab that header and add it to my project, but unfortunately the forward slash prefix on

#include "/exceptions.hpp"

also prevents me from including the file properly when placed in the project

Thank you for your time.

@pearmaster
Copy link
Owner

You should be able to "patch" that pretty quickly. There is the source.cpp.jinja2 file:
https://github.com/pearmaster/asyncapi-codegen/blob/master/asyncapicodegen/templates/cpp/source.cpp.jinja2

On line 15 you'll see the include statement, and you can change it (hard code it) to be whatever you need it to be for you.

I've also quickly fixed the source to only include the slash when needed, but I don't have time right now to republish the package. But you should be able to find and edit source.cpp.jinja2 wherever you have it installed and it will work for you.

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