diff --git a/src/Generator/Swift.php b/src/Generator/Swift.php index 8ed4663..e86a9e8 100644 --- a/src/Generator/Swift.php +++ b/src/Generator/Swift.php @@ -53,10 +53,20 @@ protected function newNormalizer(): NormalizerInterface protected function writeStruct(Code\Name $name, array $properties, ?string $extends, ?array $generics, ?array $templates, StructDefinitionType $origin): string { - $code = 'class ' . $name->getClass() . ': '; + $code = 'class ' . $name->getClass(); + + if (!empty($generics)) { + $code.= $this->generator->getGenericDefinition($generics); + } + + $code.= ': '; if (!empty($extends)) { - $code.= $extends . ' '; + $code.= $extends; + if (!empty($templates)) { + $code.= $this->generator->getGenericDefinition($templates); + } + $code.= ' '; } else { $code.= 'Codable '; } diff --git a/tests/Generator/resource/swift/swift_oop.swift b/tests/Generator/resource/swift/swift_oop.swift index c4f15d6..6228119 100644 --- a/tests/Generator/resource/swift/swift_oop.swift +++ b/tests/Generator/resource/swift/swift_oop.swift @@ -16,7 +16,7 @@ class Student: Human { } } -class Map: Codable { +class Map
: Codable {
var totalResults: Int
var parent: P
var entries: Array