Azure / openapi-diff

Command line tool to detect breaking changes between two openapi specifications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

False positives when readOnly property using referenced enum

cataggar opened this issue · comments

Describe the bug

I'm working on https://github.com/Azure/azure-rest-api-specs-pr/pull/15631 and there are a lot of false positives with a message of `The read only property has changed from 'true' to 'false'.

image

To Reproduce
As an example from that PR:

@doc("Subscription trial availability")
model Trial {
  @doc("Trial status")
  @visibility("read")
  status?: TrialStatus;

It does produce readOnly.

        "status": {
          "$ref": "#/definitions/TrialStatus",
          "description": "Trial status",
          "readOnly": true
        },

But before it was not a $ref, it was inline:

        "status": {
          "description": "Trial status",
          "type": "string",
          "enum": [
            "TrialAvailable",
            "TrialUsed",
            "TrialDisabled"
          ],
          "readOnly": true,
          "x-ms-enum": {
            "name": "TrialStatus",
            "modelAsString": true
          }
        },

Expected behavior
It is not marked as a breaking change.

This is a bit of a grey area since technically sibling properties of $ref should be ignored, but autorest is explicit about exceptions to this rule, and readOnly is one of the exceptions.

https://github.com/Azure/autorest/blob/main/docs/openapi/howto/%24ref-siblings.md