cancel
Showing results for 
Search instead for 
Did you mean: 

How can I define and reference an array of object as a parameter

New Member

How can I define and reference an array of object as a parameter

I have a REST endpoint which accepts and Id and an object as input parameter. I have documented it as follows :

 

 

/api/exam/end:
    post:
      tags:
        - Exam
      summary: Bla bla
      operationId: exam_end
      description: Bla bla
      parameters:
        - in: query
          name: sectionId
          description: Bla bla
          required: true
          schema:
            type: integer
            format: int32
        - in: query
          name: answers
          description: Bla bla
          required: true
          schema:
            type: array
            items:
              $ref: '#/components/schemas/ExamAnswerObject'
      responses:
        '200':
          description: Bla bla
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/EndExamSectionResponse'

 

I also have a valid definition for "ExamAnswerObject" where it is correctly displayed in the Schemas section. The problem is the document does not have a "Schema" link as it has in other parts.

 

IS there anything I am missing here or the "parameters" part does not allow such definition?

1 REPLY 1
Moderator

Re: How can I define and reference an array of object as a parameter


@utkuozan wrote:

IS there anything I am missing here or the "parameters" part does not allow such definition?


Your definition is correct, but Swagger UI currently does not display the schemas of object parameters. This issue is tracked here:

https://github.com/swagger-api/swagger-ui/issues/4581

 


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
New Here?
Join us and watch the welcome video:
Announcements