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

Fix missing-x-ms-identifier rule not checking base class for properties #1537

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading