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

[Bug]: Confusion on field annotation for inherited models (protobuf) #3266

Open
4 tasks done
0237h opened this issue May 3, 2024 · 0 comments
Open
4 tasks done

[Bug]: Confusion on field annotation for inherited models (protobuf) #3266

0237h opened this issue May 3, 2024 · 0 comments
Assignees
Labels
bug Something isn't working triaged:core
Milestone

Comments

@0237h
Copy link

0237h commented May 3, 2024

Describe the bug

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 !

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triaged:core
Projects
None yet
Development

No branches or pull requests

4 participants