You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The annotation of fields for inherited models targeting a protobuf emitter is a bit confusing.
import "@typespec/protobuf";
using TypeSpec.Protobuf;
@package({
name: "test",
})
namespace test;
model Parent {
id: int64
}
model Child1 is Parent {} // Not working
@@field(Child1.id, 1);
model Child2 extends Parent {} // Outputs empty `message`
@@field(Child2.id, 1);
model Child3 { // Correct
...Parent
}
@@field(Child3.id, 1);
I couldn't figure out from the documentation why only Child3 would yield the correct result. From what I've tested, it seems that for Child1 and Child2 there is a failure to recognize and tag the id field appropriately.
This is especially confusing since I'm using this for generating openapi3 specs (through @typespec/http) as well, with syntax of Child1 working as expected.
Any insights as to whether this is a bug or just a misunderstanding of the language would be appreciated thanks !
Describe the bug
The annotation of fields for inherited models targeting a protobuf emitter is a bit confusing.
I couldn't figure out from the documentation why only
Child3
would yield the correct result. From what I've tested, it seems that forChild1
andChild2
there is a failure to recognize and tag theid
field appropriately.This is especially confusing since I'm using this for generating
openapi3
specs (through@typespec/http
) as well, with syntax ofChild1
working as expected.Any insights as to whether this is a bug or just a misunderstanding of the language would be appreciated thanks !
Reproduction
https://typespec.io/playground?options=%7B%22linterRuleSet%22%3A%7B%22extends%22%3A%5B%22%40typespec%2Fhttp%2Fall%22%5D%7D%7D&c=aW1wb3J0ICJAdHlwZXNwZWMvcHJvdG9idWYiOwoKdXNpbmcgVHlwZVNwZWMuUMcbOwoKQHBhY2thZ2UoewogIG5hbWU6ICJ0ZXN0IiwKfSkKxBFzcGFjZSDEFDsKCm1vZGVsIFBhcmVudCB7CglpZDogaW50NjQKfcgdQ2hpbGQxIGlzySd9CkBAZmllbGQoxhwuaWQsIDEpyU%2FFFjIgZXh0ZW5k2Tcy1Tcz5ACGLi4uxjUKzzQzyDQ%3D&e=%40typespec%2Fprotobuf
Checklist
The text was updated successfully, but these errors were encountered: