jmlue42 / spectral-jsonapi-ruleset

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

'resource-identification-property' fails with `allOf` #37

Closed rngtng closed 8 months ago

rngtng commented 1 year ago

First, thanks a lot for your work you put into this ruleset! I unfortunately encountered an issue I need you help with. See the given spec:

$defs:
  resource_id:
    description: Resource objects appear in a JSON API document to represent resources.
    type: object
    required:
      - type
      - id
    additionalProperties: false
    properties:
      type:
        type: string
      id:
        type: string

allOf:
  - $ref: "#/$defs/resource_id"
  - type: object
    properties:
      attributes:
         type: object
        properties:
          foo:
             type: string

When running spectral with you linter rule I get this error

 23:18  error  resource-identification-property  Every resource object MUST contain an id member and a type member. The values of the id and type members MUST be strings.  allOf[1].properties.attributes

But debugging the json path, all properties type, id and foo are selected. How come this rule fails? Any idea?

rngtng commented 1 year ago

the rule I reference is here: https://github.com/jmlue42/spectral-jsonapi-ruleset/blob/main/rules/jsonapi-document-structure-resource-identification.yaml.old#L12

btw. why has the file the suffix old?

rngtng commented 1 year ago

Another insight, looks like the rule isn't triggered at all for non allOf cases, hence feels like it's not in used in std cases. For now we'd ignore it..

marquje commented 8 months ago

Apologies for such a long response time. The status of the project has been in flux for awhile and has just gone through another overhaul to be Stoplight.io styleguide friendly. Lots of adjustments and additions. Your issue should be at least partially taken care of. If not, please open a new issue so we can better track it.

rngtng commented 8 months ago

No worries. Thanks for you efforts