opticdev / optic

OpenAPI linting, diffing and testing. Optic helps prevent breaking changes, publish accurate documentation and improve the design of your APIs.
https://useoptic.com
MIT License
1.36k stars 83 forks source link

Compatibility check: [error] request property oneOf schema did not overlap with the previous schema. #2836

Closed devova closed 6 months ago

devova commented 6 months ago

Describe the bug I'm getting strange compatibility check:

[error] request property oneOf schema did not overlap with the previous schema.
oneOf/0/property2.items/currency: required property was added,
oneOf/0/property2.items/amount: required property was added

Prevent expanded in request union types

To Reproduce Steps to reproduce the behavior:

  1. There was request schema
    TestSchema:
      type: object
      properties:
        property1:
          type: integer
      required:
        - property1

    TestSchema is oneOf request bodies of a POST request

  2. added a new optional field property2, so the final schema looks like
    TestSchema:
      type: object
      properties:
        property1:
          type: integer
        property2:
          type: array
          default: []
          items:
            type: object
            properties:
              currency:
                type: string
              amount:
                type: integer
            required:
              - currency
              - amount
      required:
        - property1
  3. Run optic diff spec.yaml --base main --check
  4. See error

Expected behavior I have added an optional empty list. So no error appears

Screenshots If applicable, add screenshots to help explain your problem.

Details (please complete the following information):