<commit_before>swagger: '2.0'
info:
  version: '0.1'
  title: MediaWiki Reading Lists API
  description: API for manipulating private [reading lists](https://www.mediawiki.org/wiki/Reading/Reading_Lists)
  termsOfService: https://www.mediawiki.org/wiki/REST_API#Terms_and_conditions
  contact:
    name: Reading Infrastructure
    url: https://www.mediawiki.org/wiki/Wikimedia_Reading_Infrastructure_team
  license:
    name: Apache licence, v2
    url: https://www.apache.org/licenses/LICENSE-2.0
  x-configuration:
    maxListsPerUser: &maxListsPerUser 100
    maxEntriesPerList: &maxEntriesPerList 5000
    deletedRetentionDays: &deletedRetentionDays 30
x-yaml-anchors:
  csrf_token: &csrf_token
    name: csrf_token
    in: query
    required: true
    type: string
    description: "The CRSF edit token provided by the MediaWiki API"
    example: "<KEY>\"
  list_common: &list_common
    name:
      type: string
      example: "Planets"
    description:
      type: string
      example: "Planets of the Solar System"
  list_entry_common: &list_entry_common
    project: &list_entry_common_project
      type: string
      description: 'Domain of the wiki containing the page.'
      example: 'https://en.wikipedia.org'
    title: &list_entry_common_title
      type: string
      description: 'Title of the page containing the page, in database format.'
      example: 'Barack_Obama'
paths:
  /lists/setup:
    post:
      tags:
        - Reading lists
      summary: Opt in to use reading lists.
      description: |
        Must precede other list operations.

        Request must be authenticated with a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      produces:
        - application/json; charset=utf-8
      parameters:
        - <<: *csrf_token
      responses:
        '200':
          description: Success.
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: setup
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
      x-monitor: false
  /lists/teardown:
    post:
      tags:
        - Reading lists
      summary: Opt out from using reading lists.
      description: |
        Deletes all data. User needs to opt in again before being able to do anything.

        Request must be authenticated with a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      produces:
        - application/json; charset=utf-8
      parameters:
        - <<: *csrf_token
      responses:
        '200':
          description: Success.
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: teardown
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
      x-monitor: false
  /lists/:
    get:
      tags:
        - Reading lists
      summary: Get all lists of the current user.
      description: |
        Returns metadata describing the lists of the current user. Might be truncated and include
        a continuation token.

        Request must be authenticated with a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      parameters:
        - name: next
          in: query
          description: Continuation parameter from previous request
          type: string
          required: false
        - name: sort
          in: query
          description: |
            Sort order
            - `name`: by name, ascending;
            - `updated`: by last modification date, descending.
          type: string
          default: updated
          enum: [ name, updated ]
          required: false
      produces:
        - application/json; charset=utf-8; profile="https://www.mediawiki.org/wiki/Specs/Lists/0.1"
      responses:
        '200':
          description: An array of list metadata.
          schema:
            type: object
            properties:
              lists:
                type: array
                items:
                  $ref: '#/definitions/list_read'
              next:
                type: string
                description: Continuation token.
              continue-from:
                type: string
                format: date-time
                description: |
                  Timestamp to sync from, to be used with the `GET /lists/changes/since/{date}`
                  endpoint.
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: query
                meta: readinglists
                rlsort: '{{getSortParameters(request.query.sort).sort}}'
                rldir: '{{getSortParameters(request.query.sort).dir}}'
                rllimit: max
                continue: '{{unflattenContinuation(request.query.next).continue}}'
                rlcontinue: '{{unflattenContinuation(request.query.next).rlcontinue}}'
            return:
              status: 200
              headers:
                content-type: application/json; charset=utf-8; profile="https://www.mediawiki.org/wiki/Specs/Lists/0.1"
                cache-control: "max-age=0, s-maxage=0"
              body:
                lists: '{{forward_to_mw.body.query.readinglists}}'
                next: '{{flattenContinuation(forward_to_mw.body.continue)}}'
                continue-from: '{{getContinueFrom(forward_to_mw.body, request.query.next)}}'
      x-monitor: false
    post:
      tags:
        - Reading lists
      summary: Create a new list for the current user.
      description: |
        Creates a new empty list.

        Request must be authenticated with a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)

        This endpoint is deprecated and might be removed without warning. Use the batch version
        instead.
      x-maxsize: *maxEntriesPerList
      produces:
        - application/json; charset=utf-8
      parameters:
        - name: list
          in: body
          required: true
          schema:
            $ref: '#/definitions/list_write'
        - <<: *csrf_token
      responses:
        '200':
          description: The ID of the new list.
          schema:
            type: object
            properties:
              id:
                type: integer
                description: List ID
                example: 7
                required: true
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: create
                name: '{{request.body.name}}'
                description: '{{request.body.description}}'
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
              headers:
                content-type: application/json; charset=utf-8
              body:
                id: '{{forward_to_mw.body.create.id}}'
      x-monitor: false
  /lists/{id}:
    put:
      tags:
        - Reading lists
      summary: Update a list.
      description: |
        List must belong to current user and request must be authenticated with
        a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      parameters:
        - name: id
          in: path
          type: integer
          example: 42
          required: true
        - name: list
          in: body
          schema:
            $ref: '#/definitions/list_write'
        - <<: *csrf_token
      produces:
        - application/json; charset=utf-8
      responses:
        '200':
          description: Success.
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: update
                list: '{{request.params.id}}'
                name: '{{request.body.name}}'
                description: '{{request.body.description}}'
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
      x-monitor: false
    delete:
      tags:
        - Reading lists
      summary: Delete a list.
      description: |
        List must belong to current user and request must be authenticated with
        a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      produces:
        - application/json; charset=utf-8
      parameters:
        - name: id
          in: path
          type: integer
          example: 42
          required: true
        - <<: *csrf_token
      responses:
        '200':
          description: Success.
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: delete
                list: '{{request.params.id}}'
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
      x-monitor: false
  /lists/batch:
    post:
      tags:
        - Reading lists
      summary: Create multiple new lists for the current user.
      description: |
        See `POST /lists/`.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      x-maxsize: *maxEntriesPerList
      produces:
        - application/json; charset=utf-8
      parameters:
        - name: batch
          in: body
          required: true
          schema:
            title: batch
            type: object
            required: ['batch']
            properties:
              batch:
                type: array
                items:
                  title: list
                  $ref: '#/definitions/list_write'
        - <<: *csrf_token
      responses:
        '200':
          description: The IDs of the new lists (in the same order as the inputs).
          schema:
            title: list_create_batch
            type: object
            required: ['batch']
            properties:
              batch:
                type: array
                items:
                  title: list_id
                  type: object
                  required: ['id']
                  properties:
                    id:
                      type: integer
                      description: List ID
                      example: 7
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: create
                batch: '{{stringify(request.body.batch)}}'
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
              headers:
                content-type: application/json; charset=utf-8
              body:
                batch: '{{idsToObjects(forward_to_mw.body.create.ids, "id")}}'
      x-monitor: false
  /lists/{id}/entries/:
    get:
      tags:
        - Reading lists
      summary: Get all entries of a given list.
      description: |
        Returns pages contained by the given list. Might be truncated and include
        a continuation token.

        List must belong to current user and request must be authenticated with
        a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      parameters:
        - name: id
          in: path
          type: integer
          example: 42
          required: true
        - name: next
          in: query
          description: Continuation parameter from previous request
          type: string
          required: false
        - name: sort
          in: query
          description: |
            Sort order
            - `name`: by page title, ascending;
            - `updated`: by last modification date, descending.
          type: string
          default: updated
          enum: [ name, updated ]
          required: false
      produces:
        - application/json; charset=utf-8; profile="https://www.mediawiki.org/wiki/Specs/Lists/0.1"
      responses:
        '200':
          description: An array of list entries.
          schema:
            type: object
            properties:
              entries:
                type: array
                items:
                  $ref: '#/definitions/list_entry_read'
              next:
                type: string
                description: Continuation token.
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      operationId: getListEntries
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-monitor: false
    post:
      tags:
        - Reading lists
      summary: Create a new list entry.
      description: |
        Creates a new list entry in the given list.

        The list must belong to the current user and the request must be
        authenticated with a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)

        This endpoint is deprecated and might be removed without warning. Use the batch version
        instead.
      x-maxsize: *maxListsPerUser
      produces:
        - application/json; charset=utf-8
      parameters:
        - name: id
          in: path
          type: integer
          example: 42
          required: true
        - name: list_entry
          in: body
          required: true
          schema:
            $ref: '#/definitions/list_entry_write'
        - <<: *csrf_token
      responses:
        '200':
          description: The id of the new list entry.
          schema:
            type: object
            properties:
              id:
                type: integer
                description: List entry ID
                example: 13
                required: true
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: createentry
                list: '{{request.params.id}}'
                project: '{{request.body.project}}'
                title: '{{request.body.title}}'
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
              headers:
                content-type: application/json; charset=utf-8
              body:
                id: '{{forward_to_mw.body.createentry.id}}'
      x-monitor: false
  /lists/{id}/entries/{entry_id}:
    delete:
      tags:
        - Reading lists
      summary: Delete a list entry.
      description: |
        Deletes a given list entry.

        The list must belong to the current user and the request must be
        authenticated with a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      parameters:
        - name: id
          in: path
          type: integer
          example: 42
          required: true
        - name: entry_id
          in: path
          type: integer
          example: 64
          required: true
        - <<: *csrf_token
      produces:
        - application/json; charset=utf-8
      responses:
        '200':
          description: Success.
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: deleteentry
                entry: '{{request.params.entry_id}}'
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
      x-monitor: false
  /lists/{id}/entries/batch:
    post:
      tags:
        - Reading lists
      summary: Create multiple new list entries.
      description: |
        See `POST /lists/{id}/entries/`.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      x-maxsize: *maxListsPerUser
      produces:
        - application/json; charset=utf-8
      parameters:
        - name: id
          in: path
          type: integer
          example: 42
          required: true
        - name: batch
          in: body
          required: true
          schema:
            type: object
            required: ['batch']
            properties:
              batch:
                title: list_entries
                type: array
                items:
                  $ref: '#/definitions/list_entry_write'
        - <<: *csrf_token
      responses:
        '200':
          description: The id of the new list entry.
          schema:
            type: object
            properties:
              batch:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                      description: List entry ID
                      example: 13
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery<commit_msg>Reading lists: add maxItems for batch operation arrays<commit_after>swagger: '2.0'
info:
  version: '0.1'
  title: MediaWiki Reading Lists API
  description: API for manipulating private [reading lists](https://www.mediawiki.org/wiki/Reading/Reading_Lists)
  termsOfService: https://www.mediawiki.org/wiki/REST_API#Terms_and_conditions
  contact:
    name: Reading Infrastructure
    url: https://www.mediawiki.org/wiki/Wikimedia_Reading_Infrastructure_team
  license:
    name: Apache licence, v2
    url: https://www.apache.org/licenses/LICENSE-2.0
  x-configuration:
    maxListsPerUser: &maxListsPerUser 100
    maxEntriesPerList: &maxEntriesPerList 5000
    deletedRetentionDays: &deletedRetentionDays 30
    maxItemsPerBatch: &maxItemsPerBatch 500
x-yaml-anchors:
  csrf_token: &csrf_token
    name: csrf_token
    in: query
    required: true
    type: string
    description: "The CRSF edit token provided by the MediaWiki API"
    example: "f63c343876da566045e6b59c4532450559c828d3+\\"
  list_common: &list_common
    name:
      type: string
      example: "Planets"
    description:
      type: string
      example: "Planets of the Solar System"
  list_entry_common: &list_entry_common
    project: &list_entry_common_project
      type: string
      description: 'Domain of the wiki containing the page.'
      example: 'https://en.wikipedia.org'
    title: &list_entry_common_title
      type: string
      description: 'Title of the page containing the page, in database format.'
      example: 'Barack_Obama'
paths:
  /lists/setup:
    post:
      tags:
        - Reading lists
      summary: Opt in to use reading lists.
      description: |
        Must precede other list operations.

        Request must be authenticated with a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      produces:
        - application/json; charset=utf-8
      parameters:
        - <<: *csrf_token
      responses:
        '200':
          description: Success.
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: setup
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
      x-monitor: false
  /lists/teardown:
    post:
      tags:
        - Reading lists
      summary: Opt out from using reading lists.
      description: |
        Deletes all data. User needs to opt in again before being able to do anything.

        Request must be authenticated with a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      produces:
        - application/json; charset=utf-8
      parameters:
        - <<: *csrf_token
      responses:
        '200':
          description: Success.
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: teardown
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
      x-monitor: false
  /lists/:
    get:
      tags:
        - Reading lists
      summary: Get all lists of the current user.
      description: |
        Returns metadata describing the lists of the current user. Might be truncated and include
        a continuation token.

        Request must be authenticated with a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      parameters:
        - name: next
          in: query
          description: Continuation parameter from previous request
          type: string
          required: false
        - name: sort
          in: query
          description: |
            Sort order
            - `name`: by name, ascending;
            - `updated`: by last modification date, descending.
          type: string
          default: updated
          enum: [ name, updated ]
          required: false
      produces:
        - application/json; charset=utf-8; profile="https://www.mediawiki.org/wiki/Specs/Lists/0.1"
      responses:
        '200':
          description: An array of list metadata.
          schema:
            type: object
            properties:
              lists:
                type: array
                items:
                  $ref: '#/definitions/list_read'
              next:
                type: string
                description: Continuation token.
              continue-from:
                type: string
                format: date-time
                description: |
                  Timestamp to sync from, to be used with the `GET /lists/changes/since/{date}`
                  endpoint.
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: query
                meta: readinglists
                rlsort: '{{getSortParameters(request.query.sort).sort}}'
                rldir: '{{getSortParameters(request.query.sort).dir}}'
                rllimit: max
                continue: '{{unflattenContinuation(request.query.next).continue}}'
                rlcontinue: '{{unflattenContinuation(request.query.next).rlcontinue}}'
            return:
              status: 200
              headers:
                content-type: application/json; charset=utf-8; profile="https://www.mediawiki.org/wiki/Specs/Lists/0.1"
                cache-control: "max-age=0, s-maxage=0"
              body:
                lists: '{{forward_to_mw.body.query.readinglists}}'
                next: '{{flattenContinuation(forward_to_mw.body.continue)}}'
                continue-from: '{{getContinueFrom(forward_to_mw.body, request.query.next)}}'
      x-monitor: false
    post:
      tags:
        - Reading lists
      summary: Create a new list for the current user.
      description: |
        Creates a new empty list.

        Request must be authenticated with a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)

        This endpoint is deprecated and might be removed without warning. Use the batch version
        instead.
      x-maxsize: *maxEntriesPerList
      produces:
        - application/json; charset=utf-8
      parameters:
        - name: list
          in: body
          required: true
          schema:
            $ref: '#/definitions/list_write'
        - <<: *csrf_token
      responses:
        '200':
          description: The ID of the new list.
          schema:
            type: object
            properties:
              id:
                type: integer
                description: List ID
                example: 7
                required: true
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: create
                name: '{{request.body.name}}'
                description: '{{request.body.description}}'
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
              headers:
                content-type: application/json; charset=utf-8
              body:
                id: '{{forward_to_mw.body.create.id}}'
      x-monitor: false
  /lists/{id}:
    put:
      tags:
        - Reading lists
      summary: Update a list.
      description: |
        List must belong to current user and request must be authenticated with
        a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      parameters:
        - name: id
          in: path
          type: integer
          example: 42
          required: true
        - name: list
          in: body
          schema:
            $ref: '#/definitions/list_write'
        - <<: *csrf_token
      produces:
        - application/json; charset=utf-8
      responses:
        '200':
          description: Success.
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: update
                list: '{{request.params.id}}'
                name: '{{request.body.name}}'
                description: '{{request.body.description}}'
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
      x-monitor: false
    delete:
      tags:
        - Reading lists
      summary: Delete a list.
      description: |
        List must belong to current user and request must be authenticated with
        a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      produces:
        - application/json; charset=utf-8
      parameters:
        - name: id
          in: path
          type: integer
          example: 42
          required: true
        - <<: *csrf_token
      responses:
        '200':
          description: Success.
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: delete
                list: '{{request.params.id}}'
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
      x-monitor: false
  /lists/batch:
    post:
      tags:
        - Reading lists
      summary: Create multiple new lists for the current user.
      description: |
        See `POST /lists/`.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      x-maxsize: *maxEntriesPerList
      produces:
        - application/json; charset=utf-8
      parameters:
        - name: batch
          in: body
          required: true
          schema:
            title: batch
            type: object
            required: ['batch']
            properties:
              batch:
                type: array
                maxItems: *maxItemsPerBatch
                items:
                  title: list
                  $ref: '#/definitions/list_write'
        - <<: *csrf_token
      responses:
        '200':
          description: The IDs of the new lists (in the same order as the inputs).
          schema:
            title: list_create_batch
            type: object
            required: ['batch']
            properties:
              batch:
                type: array
                items:
                  title: list_id
                  type: object
                  required: ['id']
                  properties:
                    id:
                      type: integer
                      description: List ID
                      example: 7
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: create
                batch: '{{stringify(request.body.batch)}}'
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
              headers:
                content-type: application/json; charset=utf-8
              body:
                batch: '{{idsToObjects(forward_to_mw.body.create.ids, "id")}}'
      x-monitor: false
  /lists/{id}/entries/:
    get:
      tags:
        - Reading lists
      summary: Get all entries of a given list.
      description: |
        Returns pages contained by the given list. Might be truncated and include
        a continuation token.

        List must belong to current user and request must be authenticated with
        a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      parameters:
        - name: id
          in: path
          type: integer
          example: 42
          required: true
        - name: next
          in: query
          description: Continuation parameter from previous request
          type: string
          required: false
        - name: sort
          in: query
          description: |
            Sort order
            - `name`: by page title, ascending;
            - `updated`: by last modification date, descending.
          type: string
          default: updated
          enum: [ name, updated ]
          required: false
      produces:
        - application/json; charset=utf-8; profile="https://www.mediawiki.org/wiki/Specs/Lists/0.1"
      responses:
        '200':
          description: An array of list entries.
          schema:
            type: object
            properties:
              entries:
                type: array
                items:
                  $ref: '#/definitions/list_entry_read'
              next:
                type: string
                description: Continuation token.
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      operationId: getListEntries
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-monitor: false
    post:
      tags:
        - Reading lists
      summary: Create a new list entry.
      description: |
        Creates a new list entry in the given list.

        The list must belong to the current user and the request must be
        authenticated with a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)

        This endpoint is deprecated and might be removed without warning. Use the batch version
        instead.
      x-maxsize: *maxListsPerUser
      produces:
        - application/json; charset=utf-8
      parameters:
        - name: id
          in: path
          type: integer
          example: 42
          required: true
        - name: list_entry
          in: body
          required: true
          schema:
            $ref: '#/definitions/list_entry_write'
        - <<: *csrf_token
      responses:
        '200':
          description: The id of the new list entry.
          schema:
            type: object
            properties:
              id:
                type: integer
                description: List entry ID
                example: 13
                required: true
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: createentry
                list: '{{request.params.id}}'
                project: '{{request.body.project}}'
                title: '{{request.body.title}}'
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
              headers:
                content-type: application/json; charset=utf-8
              body:
                id: '{{forward_to_mw.body.createentry.id}}'
      x-monitor: false
  /lists/{id}/entries/{entry_id}:
    delete:
      tags:
        - Reading lists
      summary: Delete a list entry.
      description: |
        Deletes a given list entry.

        The list must belong to the current user and the request must be
        authenticated with a MediaWiki session cookie.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      parameters:
        - name: id
          in: path
          type: integer
          example: 42
          required: true
        - name: entry_id
          in: path
          type: integer
          example: 64
          required: true
        - <<: *csrf_token
      produces:
        - application/json; charset=utf-8
      responses:
        '200':
          description: Success.
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
              body:
                action: readinglists
                command: deleteentry
                entry: '{{request.params.entry_id}}'
                token: '{{request.query.csrf_token}}'
            return:
              status: 200
      x-monitor: false
  /lists/{id}/entries/batch:
    post:
      tags:
        - Reading lists
      summary: Create multiple new list entries.
      description: |
        See `POST /lists/{id}/entries/`.

        Stability: [unstable](https://www.mediawiki.org/wiki/API_versioning#Unstable)
      x-maxsize: *maxListsPerUser
      produces:
        - application/json; charset=utf-8
      parameters:
        - name: id
          in: path
          type: integer
          example: 42
          required: true
        - name: batch
          in: body
          required: true
          schema:
            type: object
            required: ['batch']
            properties:
              batch:
                title: list_entries
                type: array
                maxItems: *maxItemsPerBatch
                items:
                  $ref: '#/definitions/list_entry_write'
        - <<: *csrf_token
      responses:
        '200':
          description: The id of the new list entry.
          schema:
            type: object
            properties:
              batch:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                      description: List entry ID
                      example: 13
        default:
          description: Error
          schema:
            $ref: '#/definitions/problem'
      x-route-filters:
        - path: ./lib/mediawiki_auth_filter.js
      x-request-handler:
        - forward_to_mw:
            request:
              uri: /{domain}/sys/action/rawquery
{'fraction_non_alphanumeric': 0.08705368610326226, 'fraction_numerical': 0.0069868995633187774, 'mean_word_length': 1.438063627254509, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 4, 'https://': 38, 'lorem ipsum': 0, 'www.': 36, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5849387', 'n_tokens_mistral': 10506, 'n_tokens_neox': 9883, 'n_words': 2651}