2

I have an OpenAPI 3.0 schema where one of the properties (the taskRequireSkills array) needs to reference another schema (TaskRequireUserSkill), like this:

components:
  schemas:

    Task:
      properties:
        id:
          type: integer
        name:
          type: string

        taskRequireSkills:
          type: array
            schema:  # ERROR : bad indentation of a mapping entry
              $ref: '#/components/schemas/TaskRequireUserSkill'

        created_at:
          type: string
          format: datetime

    TaskRequireUserSkill:
      properties:
        id:
          type: integer
        skill_id:
          type: integer
        skill_name:
          type: string
        ordering:
          type: integer
        created_at:
          type: string
          format: datetime

But I get the "bad indentation of a mapping entry" error. I suppose my syntax is invalid. But which syntax is valid?

Helen
  • 87,344
  • 17
  • 243
  • 314
Petro Gromovo
  • 1,755
  • 5
  • 33
  • 91

1 Answers1

4

An array of $refs is defined as follows:

        taskRequireSkills:
          type: array
          items:
            $ref: '#/components/schemas/TaskRequireUserSkill'
Helen
  • 87,344
  • 17
  • 243
  • 314