forked from loafle/openapi-generator-original
Simplify forward declaration detection (#11490)
This makes sure all model classes are added to the forward declarations which makes it possible to create templates without any model includes which helps to resolve circular inclusion issues.
This commit is contained in:
parent
4d6b733d91
commit
e35a1270a3
@ -418,16 +418,13 @@ 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 + ";";
|
||||
|
||||
String forwardDecl = "class " + childPropertyType + ";";
|
||||
if(!forwardDeclarations.contains(forwardDecl)) {
|
||||
forwardDeclarations.add(forwardDecl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!forwardDeclarations.isEmpty()){
|
||||
parentModel.vendorExtensions.put("x-has-forward-declarations", true);
|
||||
parentModel.vendorExtensions.put("x-forward-declarations", forwardDeclarations);
|
||||
|
@ -29,6 +29,8 @@
|
||||
#include "PFXObject.h"
|
||||
|
||||
namespace test_namespace {
|
||||
class PFXCategory;
|
||||
class PFXTag;
|
||||
|
||||
class PFXPet : public PFXObject {
|
||||
public:
|
||||
|
@ -31,6 +31,8 @@ namespace openapitools {
|
||||
namespace client {
|
||||
namespace model {
|
||||
|
||||
class Category;
|
||||
class Tag;
|
||||
|
||||
/// <summary>
|
||||
/// A pet for sale in the pet store
|
||||
|
Loading…
x
Reference in New Issue
Block a user