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

Special logic for x-ms-mutability and possibly other cases doesn't work when a sibling of $ref #1000

Open
mikekistler opened this issue Sep 22, 2023 · 0 comments

Comments

@mikekistler
Copy link
Member

In developing the fix for Azure/azure-sdk-tools#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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant