Error type in composed struct
Opened this issue · 1 comments
Hi!
First of all, I want to thank you for your work, I really love ❤️ this project, I've been waiting for a tool like this (sourcery+plantuml) for quite a long time!
Next, I've found a problem that I don't if it's a bug or I'm missing something.
I've two files:
Container.swift
public struct Container: Codable {
public var url: String
public var headers: ContainerHeaders?
public init(url: String, headers: ContainerHeaders? = nil) {
self.url = url
self.headers = headers
}
public enum CodingKeys: String, CodingKey {
case url
case headers
}
}
ContainerHeaders.swift
public struct ContainerHeaders: Codable {
public var name: String
public var value: String
public init(name: String, value: String) {
self.name = name
self.value = value
}
}
With those, I try to generate a diagram using this command
swiftplantuml classdiagram Container.swift ContainerHeaders.swift --sdk $(xcrun --show-sdk-path -sdk macosx) --output consoleOnly
Which results in an error, as it can bee seen in the output given:
@startuml
' STYLE START
hide empty members
skinparam shadowing false
' STYLE END
class "Container" as Container << (S, SkyBlue) struct >> {
+url : String
+headers : <<error type>>
+init(url:headers:)
}
class "ContainerHeaders" as ContainerHeaders << (S, SkyBlue) struct >> {
+name : String
+value : String
+init(name:value:)
}
Container --|> Codable : inherits
ContainerHeaders --|> Codable : inherits
@enduml
So, is this a bug or do I miss something?
Hi @kikeenrique ,
if you omit -sdk
option then it's working for given example.
Hence, using swiftplantuml classdiagram Container.swift ContainerHeaders.swift --output consoleOnly
will result in
@startuml
' STYLE START
hide empty members
skinparam shadowing false
' STYLE END
class "Container" as Container << (S, SkyBlue) struct >> {
+url : String
+headers : ContainerHeaders?
+init(url:headers:)
}
class "ContainerHeaders" as ContainerHeaders << (S, SkyBlue) struct >> {
+name : String
+value : String
+init(name:value:)
}
Codable <|-- Container : inherits
Codable <|-- ContainerHeaders : inherits
@enduml
and in this example no type inference support is needed (which is the purpose of using --sdk
).
Yes, this is a bug but I haven't checked yet how easy it is to fix it (might be bubbling up from SourceKitten). As I am working on replacing SourceKitten with SwiftSyntaxt (the goal is to support type inference without the --sdk
option) I will not immediately fix the issue for the current (SourceKitten-based) version of SwiftPlantUML