Open timotheeguerin opened 4 months ago
model extends: Means inheritence
I think this statement only holds true when there is a discriminator from the spec's perspective? If we only write
model Foo extends Bar {};
op test(@body body: Bar): void;
I think the spec should only be expecting the payload to be Bar
and extra properties should be rejected by the service.
At least our current usage calculation in TCGC works in this way.
extends does create this explicit relation between the 2 models it doesn't have much to do with discriminator in the base language. Docs. I'd expect that every language that support inheritance to keep that relation. Of course if you try to send/return the base model then without a discriminator there isn't a good way to discriminate which child but that can still be used to organize your types.
In relation to the nominal type proposal #3900 our current mixed use of
extends
is confusingmodel extends
: Means inheritenceinterface extends
: Means spread operationsextends
means constraint satisfiesOption could be
model extends
: Keepinterface extends
: Replace with spreadextends
: replace with:
model Foo<T: string>