Skip to content

Commit

Permalink
Fix missing-x-ms-identifier rule not checking base class for properti…
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeguerin authored Oct 2, 2024
1 parent a926989 commit f984827
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: fix
packages:
- "@azure-tools/typespec-azure-resource-manager"
---

Fix missing-x-ms-identifier rule not checking base class for properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const missingXmsIdentifiersRule = createRule({
if (Array.isArray(xmsIdentifiers)) {
for (const prop of xmsIdentifiers) {
if (typeof prop === "string") {
if (!elementType.properties.has(prop)) {
if (getProperty(elementType, prop) === undefined) {
context.reportDiagnostic({
messageId: "missingProperty",
format: { propertyName: prop, targetModelName: elementType.name },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,26 @@ describe("typespec-azure-core: no-enum rule", () => {
)
.toBeValid();
});

it(`doesn't emit diagnostic if x-ms-identifiers property is defined in a base class`, async () => {
await tester
.expect(
`
model Foo {
@OpenAPI.extension("x-ms-identifiers", ["name"])
bar: Child[];
}
model Child extends Base {
other: string;
}
model Base { name: string;}
`,
)
.toBeValid();
});

it(`doesn't emit diagnostic if element is a primitive type`, async () => {
await tester
.expect(
Expand Down

0 comments on commit f984827

Please sign in to comment.