jmlue42 / spectral-jsonapi-ruleset

A Stoplight/Spectral linting ruleset for the JSON:API specification.
MIT License
12 stars 8 forks source link

resource-object-id-required triggering on schemas using 'allOf' #64

Open marquje opened 8 months ago

marquje commented 8 months ago

Rule: resource-object-id-required is triggering on allOf items that fail the rule even though another item passes the check:

Example doc snippet:

MyResourceResponseObject:
      allOf:
        - $ref: '#/components/schemas/IdentifierObject'
        - type: object
          required:
            - attributes
            - relationships
          properties:
            type:
              enum:
                - resources
            attributes:
              type: object
              required:
                - name
              properties:
                account_id:
                  type: string
                name:
                  type: string
                  example: do-hickey
                description:
                  type: string
                  example: thing that does stuff

The rule checks for the presence of id, in the above example the $ref item contains the id, the rule continues to try and validate the second item which fails and throws the alert.

Expected behavior: schema passes as one of the items meets the id requirment.

marquje commented 8 months ago

Looking into this... Currently the rule has been lowered to warn to alert user to verify the error, but not force a block.