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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #1530 use discriminator with several mappings for one schema #1534

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jKiler
Copy link

@jKiler jKiler commented Apr 8, 2024

I've decided I'll give it a try but as long as fixing ValueByDiscriminator seems pretty straightforward, it requires some more changes to support proper generation of FromX and MergeX methods.

Let's assume our Dog has breeds [ beagle, poodle ]. It will produce a code:

func (t *Pet) FromDog(v Dog) error {
	v.Breed = "beagle"
	v.Breed = "poodle"
	b, err := json.Marshal(v)
	t.union = b
	return err
}

which seems fair if you're not planning to use it, but it compiles only if we specify our breed as required.

I am not fully aware of the intentions behind setting the mapping field in these methods, so I'm not sure if resigning from setting the field is the solution here.

Another pair of 馃憖 would be much appreciated. Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant