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

Embedded struct Support #2027

Open
wayne-brush-optii opened this issue Jul 26, 2019 · 6 comments
Open

Embedded struct Support #2027

wayne-brush-optii opened this issue Jul 26, 2019 · 6 comments
Labels
generate spec Related to spec generation from code scanner

Comments

@wayne-brush-optii
Copy link

I was wondering if it was planned to support embedded structures (inheritance). I noticed Issue #413 gives the specifics for this issue but has lived for over 3 years. Does this mean that this tool will not support this functionality.

@casualjim
Copy link
Member

embedded structs should work
discriminator values it won't create but you can start with a spec and deep merge as nuclear option

@casualjim
Copy link
Member

@fredbi fredbi added the generate spec Related to spec generation from code label Jul 27, 2019
@wayne-brush-optii
Copy link
Author

Thanks for the examples. The only problem is that this solves the problem for packages I create but any package I import (3rd party) would then have to support this capability for it to work.

@ivanovaleksey
Copy link

ivanovaleksey commented Oct 23, 2020

@casualjim @fredbi embedding 3rd-party types seems to work fine.
However there is a case with 3rd-party type alias which seems to be broken.

Consider the following structure

# github.com/foo/a
color
  color.go
    type Color struct { Title string }

    type SamePackageAlias Color

alias.go
  type AnotherPackageAlias color.Color
# github.com/foo/b

import (
  "github.com/foo/a"
  "github.com/foo/a/color"
)

type Figure struct {
   a.AnotherPackageAlias // won't be rendered in Figure definition

   color.Color // would be rendered in Figure definition

   color.SamePackageAlias // would be rendered in Figure definition

   AnyName a.Color // also would be rendered in Figure definition
}

The problem is combination of embedding + aliasing in another package.
I can create demo repos if that would help.

In a real project I had alias with the same name. I created demo repo and figured out that same naming was the cause. I opened issue #2416 for that.
Then I renamed alias in a real project but it didn't help. This time I figured out that there is this corner case of embedding + aliasing in another package.

Is it can be fixed?
Please tell me if I should open another issue.

@casualjim
Copy link
Member

Yeah that's a missing feature, we never implemented type aliasing because it didn't exist when all of this was written originally.

So I think it needs a new issue, not just a comment

@ivanovaleksey
Copy link

ivanovaleksey commented Oct 24, 2020

@casualjim thanks for the reply.
I would like to note that most aliasing cases seem to work fine. It's alias in another package that doesn't work.
I opened a new issue #2417

@fredbi fredbi added the scanner label Dec 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generate spec Related to spec generation from code scanner
Projects
None yet
Development

No branches or pull requests

4 participants