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

Vet error for new discriminator of union as enum #1206

Closed
tadelesh opened this issue Apr 11, 2024 · 3 comments · Fixed by Azure/typespec-azure#834
Closed

Vet error for new discriminator of union as enum #1206

tadelesh opened this issue Apr 11, 2024 · 3 comments · Fixed by Azure/typespec-azure#834
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. TypeSpec

Comments

@tadelesh
Copy link
Member

See example.
The discriminator models will be generated something like:

type Base struct {
    Kind: *Kind
}

type K struct {
    Kind *string
    Name *string
}

func (p *K) GetBase() *Base{
    return &Base{
        Kind: p.Kind,
    }
}

Since the kind is an open enum, it is possible that the model's kind property has a name not in the enum value list, which means the discriminator property type should not be the enum type.

@tadelesh tadelesh added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Apr 11, 2024
@jhendrixMSFT
Copy link
Member

This is how extensible enums works. Any value not in the list can still be supported via a cast. It's unclear why we'd change it at this point, can you clarify?

@tadelesh
Copy link
Member Author

Pending on final decision of open/close enum of TypeSpec.

@tadelesh
Copy link
Member Author

should be fixed tcgc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. TypeSpec
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants