# Copyright 2016 OpenMarket Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
openapi: 3.1.0
info:
  title: Matrix Client-Server Typing API
  version: 1.0.0
paths:
  "/rooms/{roomId}/typing/{userId}":
    put:
      summary: Informs the server that the user has started or stopped typing.
      description: |-
        This tells the server that the user is typing for the next N
        milliseconds where N is the value specified in the `timeout` key.
        Alternatively, if `typing` is `false`, it tells the server that the
        user has stopped typing.
      operationId: setTyping
      security:
        - accessTokenQuery: []
        - accessTokenBearer: []
      parameters:
        - in: path
          name: userId
          description: The user who has started to type.
          required: true
          example: "@alice:example.com"
          schema:
            type: string
        - in: path
          name: roomId
          description: The room in which the user is typing.
          required: true
          example: "!wefh3sfukhs:example.com"
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              example: {
                "typing": true,
                "timeout": 30000
              }
              properties:
                typing:
                  type: boolean
                  description: |-
                    Whether the user is typing or not. If `false`, the `timeout`
                    key can be omitted.
                timeout:
                  type: integer
                  description: The length of time in milliseconds to mark this user as typing.
              required:
                - typing
        description: The current typing state.
        required: true
      responses:
        "200":
          description: The new typing state was set.
          content:
            application/json:
              schema:
                type: object  # empty json object
              examples:
                response:
                  value: {}
        "429":
          description: This request was rate-limited.
          content:
            application/json:
              schema:
                $ref: definitions/errors/rate_limited.yaml
      tags:
        - Room participation
servers:
  - url: "{protocol}://{hostname}{basePath}"
    variables:
      protocol:
        enum:
          - http
          - https
        default: https
      hostname:
        default: localhost:8008
      basePath:
        default: /_matrix/client/v3
components:
  securitySchemes:
    accessTokenQuery:
      $ref: definitions/security.yaml#/accessTokenQuery
    accessTokenBearer:
      $ref: definitions/security.yaml#/accessTokenBearer
