Special logic for x-ms-mutability and possibly other cases doesn't work when a sibling of $ref
- Dominant language
- TypeScript
- Stars
- 104
- Forks
- 62
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 5
Description
In developing the fix for https://github.com/Azure/azure-sdk-tools/issues/6840, we discovered that the special logic in `lib/swaggerValidator/ajvSchemaValidator.ts` for `x-ms-mutability` doesn't work when that property is a sibling of "$ref".
https://github.com/Azure/oav/blob/develop/lib/swaggerValidator/ajvSchemaValidator.ts#L288
```
// If a response has x-ms-mutability property and its missing the read we can skip this error
if (
cxt.isResponse &&
((keyword === "required" &&
(parentSchema.properties?.[(params as any).missingProperty]?.[xmsMutability]?.indexOf(
"read"
) === -1 ||
// required check is ignored when x-ms-secret is true
(parentSchema.properties?.[(params as any).missingProperty] as any)?.[xmsSecret] ===
true)) ||
(keyword === "type" && data === null && parentSchema[xmsMutability]?.indexOf("read") === -1))
) {
return true;
}
```
Autorest allows some properties to be siblings of $ref, and specifically any "x-" properties.
https://github.com/Azure/autorest/blob/main/docs/openapi/howto/%24ref-siblings.md
Contributor guide
Research direction
Start in lib/swaggerValidator/ajvSchemaValidator.ts around line 288 and inspect how the x-ms-mutability special case reads schemas when a property is a sibling of $ref. Reproduce validation with an OpenAPI schema using that sibling form, then verify that the special handling applies there without breaking existing response validation behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100