Azure / openapi-diff

Command line tool to detect breaking changes between two openapi specifications
MIT License
256 stars 36 forks source link

False positives when readOnly property using referenced enum #286

Open cataggar opened 9 months ago

cataggar commented 9 months ago

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.

mikekistler commented 9 months ago

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