departments:
  get:
    tags: [Lookups]
    summary: List departments
    description: |
      Paginated catalogue of active main departments (`Department` collection) managed from the admin dashboard.

      - Public (`SecretKeyAuth` only) — registered in `MoreRoute.unRequireAuthRoutes()`.
      - Filters: `active: true`, `isDeleted: false`.
      - DTO: `@returnObj.departmentItem` → `id`, `name`.

      <div class="figma-links"><span>Design:</span><a href="https://www.figma.com/proto/mTRILiWaS8pzLcNnmAUr2k/%D9%83%D9%85-%D8%AA%D8%B3%D9%88%D9%8A?node-id=9967-24058&viewport=176%2C570%2C0.02&t=c4yTtQLlUc9FQir5-1&scaling=scale-down&content-scaling=fixed&starting-point-node-id=9064%3A6087&page-id=0%3A1" target="_blank" rel="noopener">Mobile</a><a href="https://www.figma.com/proto/mTRILiWaS8pzLcNnmAUr2k/%D9%83%D9%85-%D8%AA%D8%B3%D9%88%D9%8A?page-id=10227%3A31854&node-id=10768-137676&viewport=-948%2C0%2C0.12&t=PNIRCKFxGV24peHK-1&scaling=min-zoom&content-scaling=fixed&starting-point-node-id=10449%3A65038" target="_blank" rel="noopener">Web</a></div>
    operationId: listDepartments
    security:
      - SecretKeyAuth: []
    parameters:
      - $ref: '../../openapi.yaml#/components/parameters/LangHeader'
      - name: page
        in: query
        required: false
        schema: { type: integer, minimum: 1, default: 1 }
      - name: limit
        in: query
        required: false
        schema: { type: integer, minimum: 1, maximum: 100, default: 20 }
    responses:
      '200':
        description: Paginated departments.
        content:
          application/json:
            schema: { $ref: '../../openapi.yaml#/components/schemas/DepartmentListResponse' }
            example:
              key: success
              message: "قائمة الأقسام"
              status: 200
              data:
                - id: "665f1c2a9b4e1d0012ab34e1"
                  name: "إلكترونيات"
              paginate: { currentPage: 1, lastPage: 1, perPage: 20, total: 1 }
      '400':
        description: Pagination validation failed.
        content:
          application/json:
            schema: { $ref: '../../openapi.yaml#/components/schemas/ValidationErrorResponse' }
            examples:
              invalidPage:
                value: { key: fail, message: "رقم الصفحة يجب أن يكون عددًا صحيحًا أكبر من صفر", status: 400 }
              invalidLimit:
                value: { key: fail, message: "عدد النتائج يجب أن يكون عددًا صحيحًا من 1 إلى 100", status: 400 }
      '500': { $ref: '#/shared-server-error' }

shared-server-error:
  description: Unexpected server error.
  content:
    application/json:
      schema: { $ref: '../../openapi.yaml#/components/schemas/ErrorResponse' }
      example: { key: exception, message: "حدث خطأ ما", status: 500 }
