diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java index fc4e37066f8..a82430bb4a4 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCppCodegen.java @@ -418,13 +418,10 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg if( !childPropertyType.equals(childModel.classname) || childPropertyType.equals(parentModel.classname) || !childModel.hasVars ){ continue; } - for(CodegenProperty p : childModel.vars) { - if(((p.isModel && p.dataType.equals(parentModel.classname)) || (p.isContainer && p.mostInnerItems.baseType.equals(parentModel.classname)))) { - String forwardDecl = "class " + childModel.classname + ";"; - if(!forwardDeclarations.contains(forwardDecl)) { - forwardDeclarations.add(forwardDecl); - } - } + + String forwardDecl = "class " + childPropertyType + ";"; + if(!forwardDeclarations.contains(forwardDecl)) { + forwardDeclarations.add(forwardDecl); } } } diff --git a/samples/client/petstore/cpp-qt/client/PFXPet.h b/samples/client/petstore/cpp-qt/client/PFXPet.h index b84bfc6d93e..3a5617940e1 100644 --- a/samples/client/petstore/cpp-qt/client/PFXPet.h +++ b/samples/client/petstore/cpp-qt/client/PFXPet.h @@ -29,6 +29,8 @@ #include "PFXObject.h" namespace test_namespace { +class PFXCategory; +class PFXTag; class PFXPet : public PFXObject { public: diff --git a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet.h index 05cd7c31c27..8a329064374 100644 --- a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet.h +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet.h @@ -31,6 +31,8 @@ namespace openapitools { namespace client { namespace model { +class Category; +class Tag; /// /// A pet for sale in the pet store