Multiple responces openAPI

I wanna add a list of error responses to each endpoint that we have in the server. Can I define a list and then add them at them to the responses?

/**
 * @openapi
 * components:
 *   responses:
 *     ErrorResponseList:
 *       400:
 *         description: Bad request
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/ApiError'
 *       401:
 *         description: Unauthorized
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/ApiError'
 *       403:
 *         description: Forbidden
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/ApiError'
 *       404:
 *         description: Challenge not found
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/ApiError'
 *       500:
 *         description: Internal server error
 *         content:
 *           application/json:
 *             schema:
 *               $ref: '#/components/schemas/ApiError'
 */

I want to add the list of error responses along with the 200 response.

  /**
   * @openapi
............
   *     responses:
   *       200:
   *         description: Challenge list
   *         content:
   *           application/json:
   *             schema:
   *               type: array
   *               items:
   *                 $ref: '#/components/schemas/ChallengeResponse'
   *       $ref: '#/components/responses/ErrorResponseList'
  */

What ends up happening is all the error responses show except for the 200

Leave a Comment