Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error type in composed struct #22

Open
kikeenrique opened this issue May 13, 2021 · 1 comment
Open

Error type in composed struct #22

kikeenrique opened this issue May 13, 2021 · 1 comment
Labels
bug Something isn't working workaround-possible This issue can be mitigated by a workaround

Comments

@kikeenrique
Copy link

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?

@MarcoEidinger
Copy link
Owner

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

@MarcoEidinger MarcoEidinger added bug Something isn't working workaround-possible This issue can be mitigated by a workaround labels May 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working workaround-possible This issue can be mitigated by a workaround
Projects
None yet
Development

No branches or pull requests

2 participants