Skip to content

resource-object-id-required errors when the id is there, but in items > anyOf > allOf > $ref #12

@philsturgeon

Description

@philsturgeon

Maybe we just shouldn't be trying to get that deep, perhaps we ignore items and let the singular handle it, but here's a fail case all the same.

components:
  schemas:
    BaseModel:
      title: Base Model
      type: object
      properties:
        type:
          type: string
        id:
          type: string
          format: uuid
        attributes:
          type: object
      required:
        - type
        - id
        - attributes
   Foo:
      type: array
      items:
        anyOf:
          - $ref: '#/components/schemas/Branch'
          # .. snip many more ..

    Branch:
      title: Branch
      allOf:
        - $ref: '#/components/schemas/BaseModel'
        - type: object
          properties:
            type:
              type: string
            attributes:
              type: object
              properties:
                name:
                  type: string

If anyone is struggling with this just turn it off:

extends:
  - "spectral:oas"
  - "@apisyouwonthate/spectral-jsonapi"


overrides:
  - files:
    - "openapi.yml#/components/schemas/Foo/items"
    rules:
      resource-object-id-required: "off"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions