-
-
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
[C++][Pistache-server] Object containing an Array - model file (.h) is not included and generated code is wrong - Compilation failed #1572
Comments
Something remarkable is that I got the exact same issues (lack of include and wrong code) when using the generator cpp-restsdk |
This OpenAPI declaration: {
"swagger": "2.0",
"info": {
"description": "Test API.",
"title": "Test",
"version": "1"
},
"paths": {
"/demo": {
"get": {
"tags": [
"demo"
],
"operationId": "demo",
"summary": "Test C++ code gen",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "Successful operation",
"schema": {
"$ref": "#/definitions/DemoArray"
}
}
}
}
}
},
"definitions": {
"DemoArray": {
"description": "A list of data",
"type": "array",
"items": {
"type": "string",
"example": "142aee4a50c03168ffb2d957b158229a"
}
}
}
} has major problems with cpp-restsdk (uncompilable code generated) as well as appearing to generate the same invalid code as the initial bug report. For C++, the model header contains this: class DemoArray
: public null<utility::string_t> which is syntatically invalid. It appears to be related to this mustache code: class {{declspec}} {{classname}}
: public {{#parent}}{{{parent}}}{{/parent}}{{^parent}}ModelBase{{/parent}} which apparently evaluates EDIT: Fixed code quoting. |
Further investigation: It appears that the cpp-restsdk does not support at all:
The attached diff includes these fixes, plus support for binary ("string"/'binary") and byte array ("string"/"byte") body data. |
@grmcdorman @CyrilleBenard |
Will do when I get appropriate details from my manager. Have also made very extensive changes to the C++ code generation:
|
@CyrilleBenard This workaround #1050 (comment) should work. |
@CyrilleBenard I tested both your specs again on master and everything is fine. Please open a new issue when there are additional bugs. |
Description
When the YAML file describes the use of an array inside an object there are two issues :
One model file is not included (whereas it as been well generated)
In the current example see the lack of #include "EpsBearerId.h" inside the file AssignEbi.h
The generated code below is wrong because the ::push_back method can't handle an json object
It should generate something like this :
openapi-generator version
Current master 3.3.4-SNAPSHOT
OpenAPI declaration file content or url
Command line used for generation
Generate :
Compile :
Steps to reproduce
Generate & compile
Related issues/PRs
N/A
Suggest a fix/enhancement
I wrote a proposal of generated code above.
The text was updated successfully, but these errors were encountered: