diff --git a/src/Generator/CSharp.php b/src/Generator/CSharp.php index 8aab315d..07bb537d 100644 --- a/src/Generator/CSharp.php +++ b/src/Generator/CSharp.php @@ -98,7 +98,7 @@ protected function writeReference(Code\Name $name, string $type, ReferenceType $ return $code; } - protected function writeHeader(TypeAbstract $origin): string + protected function writeHeader(TypeAbstract $origin, Code\Name $className): string { $code = ''; @@ -125,11 +125,6 @@ protected function writeHeader(TypeAbstract $origin): string return $code; } - protected function writeFooter(TypeAbstract $origin): string - { - return ''; - } - private function getImports(TypeAbstract $origin): array { $imports = []; diff --git a/src/Generator/CodeGeneratorAbstract.php b/src/Generator/CodeGeneratorAbstract.php index def3b945..edafd811 100644 --- a/src/Generator/CodeGeneratorAbstract.php +++ b/src/Generator/CodeGeneratorAbstract.php @@ -121,7 +121,7 @@ private function generateDefinition(string $name, TypeInterface $type) } } - private function generateStruct(string $className, StructType $type) + private function generateStruct(string $className, StructType $type): void { $properties = []; @@ -195,57 +195,57 @@ private function generateStruct(string $className, StructType $type) $code = $this->writeStruct($className, $props, $extends, $generics, $type); if (!empty($code)) { - $this->chunks->append($className->getFile(), $this->wrap($code, $type)); + $this->chunks->append($className->getFile(), $this->wrap($code, $type, $className)); } } - private function generateMap(string $className, MapType $type) + private function generateMap(string $className, MapType $type): void { $className = new Code\Name($className, $className, $this->normalizer); $code = $this->writeMap($className, $this->generator->getType($type), $type); if (!empty($code)) { - $this->chunks->append($className->getFile(), $this->wrap($code, $type)); + $this->chunks->append($className->getFile(), $this->wrap($code, $type, $className)); } } - private function generateArray(string $className, ArrayType $type) + private function generateArray(string $className, ArrayType $type): void { $className = new Code\Name($className, $className, $this->normalizer); $code = $this->writeArray($className, $this->generator->getType($type), $type); if (!empty($code)) { - $this->chunks->append($className->getFile(), $this->wrap($code, $type)); + $this->chunks->append($className->getFile(), $this->wrap($code, $type, $className)); } } - private function generateUnion(string $className, UnionType $type) + private function generateUnion(string $className, UnionType $type): void { $className = new Code\Name($className, $className, $this->normalizer); $code = $this->writeUnion($className, $this->generator->getType($type), $type); if (!empty($code)) { - $this->chunks->append($className->getFile(), $this->wrap($code, $type)); + $this->chunks->append($className->getFile(), $this->wrap($code, $type, $className)); } } - private function generateIntersection(string $className, IntersectionType $type) + private function generateIntersection(string $className, IntersectionType $type): void { $className = new Code\Name($className, $className, $this->normalizer); $code = $this->writeIntersection($className, $this->generator->getType($type), $type); if (!empty($code)) { - $this->chunks->append($className->getFile(), $this->wrap($code, $type)); + $this->chunks->append($className->getFile(), $this->wrap($code, $type, $className)); } } - private function generateReference(string $className, ReferenceType $type) + private function generateReference(string $className, ReferenceType $type): void { $className = new Code\Name($className, $className, $this->normalizer); $code = $this->writeReference($className, $this->generator->getType($type), $type); if (!empty($code)) { - $this->chunks->append($className->getFile(), $this->wrap($code, $type)); + $this->chunks->append($className->getFile(), $this->wrap($code, $type, $className)); } } @@ -284,12 +284,12 @@ private function getGeneric(TypeInterface $type): ?GenericType } } - private function wrap(string $code, TypeAbstract $type): string + private function wrap(string $code, TypeAbstract $type, Code\Name $className): string { return implode("\n", array_filter(array_map('trim', [ - $this->writeHeader($type), + $this->writeHeader($type, $className), $code, - $this->writeFooter($type) + $this->writeFooter($type, $className) ]))) . "\n"; } @@ -337,12 +337,12 @@ protected function writeReference(Code\Name $name, string $type, ReferenceType $ return ''; } - protected function writeHeader(TypeAbstract $origin): string + protected function writeHeader(TypeAbstract $origin, Code\Name $className): string { return ''; } - protected function writeFooter(TypeAbstract $origin): string + protected function writeFooter(TypeAbstract $origin, Code\Name $className): string { return ''; } diff --git a/src/Generator/Go.php b/src/Generator/Go.php index d3d1daea..d38ada3e 100644 --- a/src/Generator/Go.php +++ b/src/Generator/Go.php @@ -99,7 +99,7 @@ protected function writeReference(Code\Name $name, string $type, ReferenceType $ return 'type ' . $name->getClass() . ' = ' . $type . "\n"; } - protected function writeHeader(TypeAbstract $origin): string + protected function writeHeader(TypeAbstract $origin, Code\Name $className): string { $code = "\n"; diff --git a/src/Generator/Java.php b/src/Generator/Java.php index a8c8ff3e..1c0b69f9 100644 --- a/src/Generator/Java.php +++ b/src/Generator/Java.php @@ -109,7 +109,7 @@ protected function writeReference(Code\Name $name, string $type, ReferenceType $ return $code; } - protected function writeHeader(TypeAbstract $origin): string + protected function writeHeader(TypeAbstract $origin, Code\Name $className): string { $code = ''; diff --git a/src/Generator/Kotlin.php b/src/Generator/Kotlin.php index cdd7b220..1a093959 100644 --- a/src/Generator/Kotlin.php +++ b/src/Generator/Kotlin.php @@ -87,7 +87,7 @@ protected function writeReference(Code\Name $name, string $type, ReferenceType $ return 'typealias ' . $name->getClass() . ' = ' . $type . "\n"; } - protected function writeHeader(TypeAbstract $origin): string + protected function writeHeader(TypeAbstract $origin, Code\Name $className): string { $code = ''; diff --git a/src/Generator/Python.php b/src/Generator/Python.php index 5f76221c..2fa9e0e2 100644 --- a/src/Generator/Python.php +++ b/src/Generator/Python.php @@ -103,7 +103,7 @@ protected function writeReference(Code\Name $name, string $type, ReferenceType $ return $code; } - protected function writeHeader(TypeAbstract $origin): string + protected function writeHeader(TypeAbstract $origin, Code\Name $className): string { $code = ''; diff --git a/src/Generator/Ruby.php b/src/Generator/Ruby.php index cdda9258..fcde0c7b 100644 --- a/src/Generator/Ruby.php +++ b/src/Generator/Ruby.php @@ -92,7 +92,7 @@ protected function writeReference(Code\Name $name, string $type, ReferenceType $ return $code; } - protected function writeHeader(TypeAbstract $origin): string + protected function writeHeader(TypeAbstract $origin, Code\Name $className): string { $code = ''; @@ -109,7 +109,7 @@ protected function writeHeader(TypeAbstract $origin): string return $code; } - protected function writeFooter(TypeAbstract $origin): string + protected function writeFooter(TypeAbstract $origin, Code\Name $className): string { $code = ''; diff --git a/src/Generator/Rust.php b/src/Generator/Rust.php index 2e7e93f7..6d3e1d71 100644 --- a/src/Generator/Rust.php +++ b/src/Generator/Rust.php @@ -88,7 +88,7 @@ protected function writeReference(Code\Name $name, string $type, ReferenceType $ return 'pub type ' . $name->getClass() . ' = ' . $type . ';' . "\n"; } - protected function writeHeader(TypeAbstract $origin): string + protected function writeHeader(TypeAbstract $origin, Code\Name $className): string { $code = ''; diff --git a/src/Generator/Swift.php b/src/Generator/Swift.php index af11c705..91df7069 100644 --- a/src/Generator/Swift.php +++ b/src/Generator/Swift.php @@ -112,7 +112,7 @@ protected function writeReference(Code\Name $name, string $type, ReferenceType $ return 'typealias ' . $name->getClass() . ' = ' . $type . ';' . "\n"; } - protected function writeHeader(TypeAbstract $origin): string + protected function writeHeader(TypeAbstract $origin, Code\Name $className): string { $code = ''; diff --git a/src/Generator/TypeScript.php b/src/Generator/TypeScript.php index 92cd1471..15bbfd9e 100644 --- a/src/Generator/TypeScript.php +++ b/src/Generator/TypeScript.php @@ -112,11 +112,11 @@ protected function writeReference(Code\Name $name, string $type, ReferenceType $ return 'export type ' . $name->getClass() . ' = ' . $type . ';' . "\n"; } - protected function writeHeader(TypeAbstract $origin): string + protected function writeHeader(TypeAbstract $origin, Code\Name $className): string { $code = ''; - $imports = $this->getImports($origin); + $imports = $this->getImports($origin, $className); if (!empty($imports)) { $code.= "\n"; $code.= implode("\n", $imports); @@ -135,10 +135,10 @@ protected function writeHeader(TypeAbstract $origin): string return $code; } - private function getImports(TypeInterface $origin): array + private function getImports(TypeInterface $origin, Code\Name $className): array { $refs = []; - TypeUtil::walk($origin, function(TypeInterface $type) use (&$refs){ + TypeUtil::walk($origin, function(TypeInterface $type) use (&$refs, $className){ if ($type instanceof ReferenceType) { $refs[$type->getRef()] = $type->getRef(); if ($type->getTemplate()) { @@ -154,7 +154,14 @@ private function getImports(TypeInterface $origin): array $imports = []; foreach ($refs as $ref) { [$ns, $name] = TypeUtil::split($ref); - $imports[] = 'import {' . $this->normalizer->class($name) . '} from "./' . $this->normalizer->file($name) . '";'; + + $typeName = $this->normalizer->class($name); + if ($typeName === $className->getClass()) { + // we dont need to include the same class + continue; + } + + $imports[] = 'import {' . $typeName . '} from "./' . $this->normalizer->file($name) . '";'; } return $imports; diff --git a/src/Generator/VisualBasic.php b/src/Generator/VisualBasic.php index 0785e15f..2bfdab68 100644 --- a/src/Generator/VisualBasic.php +++ b/src/Generator/VisualBasic.php @@ -97,7 +97,7 @@ protected function writeReference(Code\Name $name, string $type, ReferenceType $ return $code; } - protected function writeHeader(TypeAbstract $origin): string + protected function writeHeader(TypeAbstract $origin, Code\Name $className): string { $code = ''; @@ -122,7 +122,7 @@ protected function writeHeader(TypeAbstract $origin): string return $code; } - protected function writeFooter(TypeAbstract $origin): string + protected function writeFooter(TypeAbstract $origin, Code\Name $className): string { if (!empty($this->namespace)) { return 'End Namespace' . "\n"; diff --git a/tests/Generator/resource/csharp/csharp_oop.cs b/tests/Generator/resource/csharp/csharp_oop.cs index 91fcb569..558b6801 100644 --- a/tests/Generator/resource/csharp/csharp_oop.cs +++ b/tests/Generator/resource/csharp/csharp_oop.cs @@ -3,6 +3,8 @@ public class Human { [JsonPropertyName("firstName")] public string? FirstName { get; set; } + [JsonPropertyName("parent")] + public Human? Parent { get; set; } } using System.Text.Json.Serialization; diff --git a/tests/Generator/resource/go/go_import.go b/tests/Generator/resource/go/go_import.go index d5b14145..1baad5ab 100644 --- a/tests/Generator/resource/go/go_import.go +++ b/tests/Generator/resource/go/go_import.go @@ -6,4 +6,5 @@ type Import struct { type MyMap struct { MatricleNumber string `json:"matricleNumber"` FirstName string `json:"firstName"` + Parent *Human `json:"parent"` } diff --git a/tests/Generator/resource/go/go_import_ns.go b/tests/Generator/resource/go/go_import_ns.go index bfbbafd4..98dba0fa 100644 --- a/tests/Generator/resource/go/go_import_ns.go +++ b/tests/Generator/resource/go/go_import_ns.go @@ -8,4 +8,5 @@ package Foo.Bar type MyMap struct { MatricleNumber string `json:"matricleNumber"` FirstName string `json:"firstName"` + Parent *My.Import.Human `json:"parent"` } diff --git a/tests/Generator/resource/go/go_oop.go b/tests/Generator/resource/go/go_oop.go index 09887064..16803edc 100644 --- a/tests/Generator/resource/go/go_oop.go +++ b/tests/Generator/resource/go/go_oop.go @@ -1,9 +1,11 @@ type Human struct { FirstName string `json:"firstName"` + Parent *Human `json:"parent"` } type Student struct { FirstName string `json:"firstName"` + Parent *Human `json:"parent"` MatricleNumber string `json:"matricleNumber"` } diff --git a/tests/Generator/resource/html/html_oop.htm b/tests/Generator/resource/html/html_oop.htm index dfba35b6..b164b643 100644 --- a/tests/Generator/resource/html/html_oop.htm +++ b/tests/Generator/resource/html/html_oop.htm @@ -1,6 +1,7 @@

Human

{
   "firstName": String,
-}
FieldDescription
firstNameString
+ "parent": Human, +}
FieldDescription
firstNameString
parentHuman

Student extends Human

{
   "matricleNumber": String,
diff --git a/tests/Generator/resource/java/java_oop.java b/tests/Generator/resource/java/java_oop.java
index 2f89fe98..e1536902 100644
--- a/tests/Generator/resource/java/java_oop.java
+++ b/tests/Generator/resource/java/java_oop.java
@@ -3,6 +3,7 @@
 import java.util.List;
 public class Human {
     private String firstName;
+    private Human parent;
     @JsonSetter("firstName")
     public void setFirstName(String firstName) {
         this.firstName = firstName;
@@ -11,6 +12,14 @@ public void setFirstName(String firstName) {
     public String getFirstName() {
         return this.firstName;
     }
+    @JsonSetter("parent")
+    public void setParent(Human parent) {
+        this.parent = parent;
+    }
+    @JsonGetter("parent")
+    public Human getParent() {
+        return this.parent;
+    }
 }
 
 import com.fasterxml.jackson.annotation.JsonGetter;
diff --git a/tests/Generator/resource/jsonschema/jsonschema_import.json b/tests/Generator/resource/jsonschema/jsonschema_import.json
index b62d983c..b85d1caa 100644
--- a/tests/Generator/resource/jsonschema/jsonschema_import.json
+++ b/tests/Generator/resource/jsonschema/jsonschema_import.json
@@ -5,6 +5,9 @@
       "properties": {
         "firstName": {
           "type": "string"
+        },
+        "parent": {
+          "$ref": "#/definitions/Human"
         }
       }
     },
@@ -24,14 +27,14 @@
       "type": "object",
       "properties": {
         "students": {
-          "$ref": "#\/definitions\/StudentMap"
+          "$ref": "#/definitions/StudentMap"
         }
       }
     },
     "Student": {
       "allOf": [
         {
-          "$ref": "#\/definitions\/Human"
+          "$ref": "#/definitions/Human"
         },
         {
           "type": "object",
@@ -54,7 +57,7 @@
           "items": {
             "allOf": [
               {
-                "$ref": "#\/definitions\/Human"
+                "$ref": "#/definitions/Human"
               },
               {
                 "type": "object",
@@ -73,17 +76,17 @@
       "type": "object",
       "properties": {
         "students": {
-          "$ref": "#\/definitions\/StudentMap"
+          "$ref": "#/definitions/StudentMap"
         },
         "student": {
-          "$ref": "#\/definitions\/Student"
+          "$ref": "#/definitions/Student"
         }
       }
     },
     "MyMap": {
       "allOf": [
         {
-          "$ref": "#\/definitions\/Student"
+          "$ref": "#/definitions/Student"
         },
         {
           "type": "object"
@@ -91,5 +94,5 @@
       ]
     }
   },
-  "$ref": "#\/definitions\/Import"
-}
\ No newline at end of file
+  "$ref": "#/definitions/Import"
+}
diff --git a/tests/Generator/resource/jsonschema/jsonschema_oop.json b/tests/Generator/resource/jsonschema/jsonschema_oop.json
index bb6479f4..8474a6c8 100644
--- a/tests/Generator/resource/jsonschema/jsonschema_oop.json
+++ b/tests/Generator/resource/jsonschema/jsonschema_oop.json
@@ -5,6 +5,9 @@
       "properties": {
         "firstName": {
           "type": "string"
+        },
+        "parent": {
+          "$ref": "#/definitions/Human"
         }
       }
     },
@@ -24,14 +27,14 @@
       "type": "object",
       "properties": {
         "students": {
-          "$ref": "#\/definitions\/StudentMap"
+          "$ref": "#/definitions/StudentMap"
         }
       }
     },
     "Student": {
       "allOf": [
         {
-          "$ref": "#\/definitions\/Human"
+          "$ref": "#/definitions/Human"
         },
         {
           "type": "object",
@@ -54,7 +57,7 @@
           "items": {
             "allOf": [
               {
-                "$ref": "#\/definitions\/Human"
+                "$ref": "#/definitions/Human"
               },
               {
                 "type": "object",
@@ -70,5 +73,5 @@
       }
     }
   },
-  "$ref": "#\/definitions\/RootSchema"
-}
\ No newline at end of file
+  "$ref": "#/definitions/RootSchema"
+}
diff --git a/tests/Generator/resource/kotlin/kotlin_oop.kt b/tests/Generator/resource/kotlin/kotlin_oop.kt
index 312f9f83..d49ae4f2 100644
--- a/tests/Generator/resource/kotlin/kotlin_oop.kt
+++ b/tests/Generator/resource/kotlin/kotlin_oop.kt
@@ -1,5 +1,6 @@
 open class Human {
     var firstName: String? = null
+    var parent: Human? = null
 }
 
 open class Student : Human {
diff --git a/tests/Generator/resource/php/php_oop.php b/tests/Generator/resource/php/php_oop.php
index 6c46dbc0..d2e7ccc0 100644
--- a/tests/Generator/resource/php/php_oop.php
+++ b/tests/Generator/resource/php/php_oop.php
@@ -1,6 +1,7 @@
 class Human implements \JsonSerializable, \PSX\Record\RecordableInterface
 {
     protected ?string $firstName = null;
+    protected ?Human $parent = null;
     public function setFirstName(?string $firstName) : void
     {
         $this->firstName = $firstName;
@@ -9,11 +10,20 @@ public function getFirstName() : ?string
     {
         return $this->firstName;
     }
+    public function setParent(?Human $parent) : void
+    {
+        $this->parent = $parent;
+    }
+    public function getParent() : ?Human
+    {
+        return $this->parent;
+    }
     public function toRecord() : \PSX\Record\RecordInterface
     {
         /** @var \PSX\Record\Record $record */
         $record = new \PSX\Record\Record();
         $record->put('firstName', $this->firstName);
+        $record->put('parent', $this->parent);
         return $record;
     }
     public function jsonSerialize() : object
diff --git a/tests/Generator/resource/protobuf/protobuf_oop.txt b/tests/Generator/resource/protobuf/protobuf_oop.txt
index 1ed2934d..f0d9727f 100644
--- a/tests/Generator/resource/protobuf/protobuf_oop.txt
+++ b/tests/Generator/resource/protobuf/protobuf_oop.txt
@@ -1,10 +1,12 @@
 message Human {
     optional string firstName = 1 [json_name="firstName"];
+    optional Human parent = 2 [json_name="parent"];
 }
 
 message Student {
     optional string firstName = 1 [json_name="firstName"];
-    optional string matricleNumber = 2 [json_name="matricleNumber"];
+    optional Human parent = 2 [json_name="parent"];
+    optional string matricleNumber = 3 [json_name="matricleNumber"];
 }
 
 message Map {
diff --git a/tests/Generator/resource/python/python_oop.py b/tests/Generator/resource/python/python_oop.py
index 28626955..4cbace41 100644
--- a/tests/Generator/resource/python/python_oop.py
+++ b/tests/Generator/resource/python/python_oop.py
@@ -1,9 +1,11 @@
 from dataclasses import dataclass
 from dataclasses_json import dataclass_json
+from human import Human
 @dataclass_json
 @dataclass
 class Human:
     first_name: str
+    parent: Human
 
 from dataclasses import dataclass
 from dataclasses_json import dataclass_json
diff --git a/tests/Generator/resource/ruby/ruby_oop.rb b/tests/Generator/resource/ruby/ruby_oop.rb
index 16214dd2..31177b4c 100644
--- a/tests/Generator/resource/ruby/ruby_oop.rb
+++ b/tests/Generator/resource/ruby/ruby_oop.rb
@@ -1,8 +1,9 @@
 class Human
-  attr_accessor :first_name
+  attr_accessor :first_name, :parent
 
-  def initialize(first_name)
+  def initialize(first_name, parent)
     @first_name = first_name
+    @parent = parent
   end
 end
 
diff --git a/tests/Generator/resource/rust/rust_import.rs b/tests/Generator/resource/rust/rust_import.rs
index 602be4d8..c042cfdd 100644
--- a/tests/Generator/resource/rust/rust_import.rs
+++ b/tests/Generator/resource/rust/rust_import.rs
@@ -11,10 +11,13 @@ pub struct Import {
 
 use serde::{Serialize, Deserialize};
 use student::Student;
+use human::Human;
 #[derive(Serialize, Deserialize)]
 pub struct MyMap {
     #[serde(rename = "matricleNumber")]
     matricle_number: Option,
     #[serde(rename = "firstName")]
     first_name: Option,
+    #[serde(rename = "parent")]
+    parent: Option,
 }
diff --git a/tests/Generator/resource/rust/rust_import_ns.rs b/tests/Generator/resource/rust/rust_import_ns.rs
index 2e262a9a..21d1a404 100644
--- a/tests/Generator/resource/rust/rust_import_ns.rs
+++ b/tests/Generator/resource/rust/rust_import_ns.rs
@@ -15,10 +15,13 @@ mod FooBar;
 
 use serde::{Serialize, Deserialize};
 use student::Student;
+use human::Human;
 #[derive(Serialize, Deserialize)]
 pub struct MyMap {
     #[serde(rename = "matricleNumber")]
     matricle_number: Option,
     #[serde(rename = "firstName")]
     first_name: Option,
+    #[serde(rename = "parent")]
+    parent: Option,
 }
diff --git a/tests/Generator/resource/rust/rust_oop.rs b/tests/Generator/resource/rust/rust_oop.rs
index 6cbbb50d..d3ace15e 100644
--- a/tests/Generator/resource/rust/rust_oop.rs
+++ b/tests/Generator/resource/rust/rust_oop.rs
@@ -1,8 +1,11 @@
 use serde::{Serialize, Deserialize};
+use human::Human;
 #[derive(Serialize, Deserialize)]
 pub struct Human {
     #[serde(rename = "firstName")]
     first_name: Option,
+    #[serde(rename = "parent")]
+    parent: Option,
 }
 
 use serde::{Serialize, Deserialize};
@@ -11,6 +14,8 @@ use human::Human;
 pub struct Student {
     #[serde(rename = "firstName")]
     first_name: Option,
+    #[serde(rename = "parent")]
+    parent: Option,
     #[serde(rename = "matricleNumber")]
     matricle_number: Option,
 }
diff --git a/tests/Generator/resource/source_oop.json b/tests/Generator/resource/source_oop.json
index 5c1a0351..3472fdad 100644
--- a/tests/Generator/resource/source_oop.json
+++ b/tests/Generator/resource/source_oop.json
@@ -5,6 +5,9 @@
       "properties": {
         "firstName": {
           "type": "string"
+        },
+        "parent": {
+          "$ref": "Human"
         }
       }
     },
diff --git a/tests/Generator/resource/swift/swift_oop.swift b/tests/Generator/resource/swift/swift_oop.swift
index 5bbd1e20..fde3b975 100644
--- a/tests/Generator/resource/swift/swift_oop.swift
+++ b/tests/Generator/resource/swift/swift_oop.swift
@@ -1,8 +1,10 @@
 class Human: Codable {
     var firstName: String
+    var parent: Human
 
     enum CodingKeys: String, CodingKey {
         case firstName = "firstName"
+        case parent = "parent"
     }
 }
 
diff --git a/tests/Generator/resource/typeschema/typeschema_import.json b/tests/Generator/resource/typeschema/typeschema_import.json
index 29732fa0..ae510193 100644
--- a/tests/Generator/resource/typeschema/typeschema_import.json
+++ b/tests/Generator/resource/typeschema/typeschema_import.json
@@ -5,6 +5,9 @@
       "properties": {
         "firstName": {
           "type": "string"
+        },
+        "parent": {
+          "$ref": "my_import:Human"
         }
       }
     },
@@ -62,4 +65,4 @@
     }
   },
   "$ref": "Import"
-}
\ No newline at end of file
+}
diff --git a/tests/Generator/resource/typeschema/typeschema_oop.json b/tests/Generator/resource/typeschema/typeschema_oop.json
index 407946db..a03d7dd8 100644
--- a/tests/Generator/resource/typeschema/typeschema_oop.json
+++ b/tests/Generator/resource/typeschema/typeschema_oop.json
@@ -5,6 +5,9 @@
       "properties": {
         "firstName": {
           "type": "string"
+        },
+        "parent": {
+          "$ref": "Human"
         }
       }
     },
@@ -47,4 +50,4 @@
     }
   },
   "$ref": "RootSchema"
-}
\ No newline at end of file
+}
diff --git a/tests/Generator/resource/typescript/typescript_oop.ts b/tests/Generator/resource/typescript/typescript_oop.ts
index 05b9afb1..9022fe48 100644
--- a/tests/Generator/resource/typescript/typescript_oop.ts
+++ b/tests/Generator/resource/typescript/typescript_oop.ts
@@ -1,5 +1,6 @@
 export interface Human {
     firstName?: string
+    parent?: Human
 }
 
 import {Human} from "./Human";
diff --git a/tests/Generator/resource/visualbasic/visualbasic_oop.vb b/tests/Generator/resource/visualbasic/visualbasic_oop.vb
index 81459c17..26543c55 100644
--- a/tests/Generator/resource/visualbasic/visualbasic_oop.vb
+++ b/tests/Generator/resource/visualbasic/visualbasic_oop.vb
@@ -2,6 +2,8 @@ Imports System.Text.Json.Serialization
 Public Class Human
     
     Public Property FirstName As String
+    
+    Public Property Parent As Human
 End Class
 
 Imports System.Text.Json.Serialization