openapi: 3.1.0
info:
  title: TMT API
  description: API working with Test folders in TMT
  version: 1.0.0
paths:
  /api/v2/rpc (GET_DOCUMENT for Test Folder):
    post:
      summary: Get test folder detail
      description: Get content of a test folder by given document reference
      parameters:
        - $ref: '#/components/parameters/ProjectIdHeader'
        - $ref: '#/components/parameters/SubProjectIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GetDocumentRequest'
              examples:
                $ref: example/GET_TEST_FOLDER-request.json
      responses:
        '200':
          description: Content of the test folder
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TestFolderDocumentResponse'
                examples:
                  $ref: example/GET_TEST_FOLDER-response.json
  /api/v2/rpc (CREATE_TEST_CASE_TREE_NODE):
    post:
      summary: Create a new test folder
      description: >
        Create a new test folder and add it into a test case tree.<br/>

        The new test folder will be located at the end of the folder (or the
        test suite if it is at the root level)
      parameters:
        - $ref: '#/components/parameters/ProjectIdHeader'
        - $ref: '#/components/parameters/SubProjectIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddTestFolderRequest'
              examples:
                $ref: example/ADD_TEST_FOLDER-request.json
      responses:
        '200':
          description: >-
            Information of the created test folder and its relationship
            information
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddTestFolderResponse'
                examples:
                  $ref: example/ADD_TEST_FOLDER-response.json
  /api/v2/rpc (UPDATE_TEST_CASE_TREE_NODE):
    post:
      summary: Update test folder
      description: Update test folder content
      parameters:
        - $ref: '#/components/parameters/ProjectIdHeader'
        - $ref: '#/components/parameters/SubProjectIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateTestFolderRequest'
              examples:
                $ref: example/UPDATE_TEST_FOLDER-request.json
      responses:
        '200':
          description: >-
            Updated test folder's content (with only Root.General group
            returned)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdateTestFolderResponse'
                examples:
                  $ref: example/UPDATE_TEST_FOLDER-response.json
  /api/v2/rpc (DELETE_FOLDER):
    post:
      summary: Delete a test folder
      description: >-
        Delete a test folder and its content. All test cases within test folder
        must not be in any open run.
      parameters:
        - $ref: '#/components/parameters/ProjectIdHeader'
        - $ref: '#/components/parameters/SubProjectIdHeader'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DeleteDocumentRequest'
              examples:
                $ref: example/DELETE_TEST_FOLDER-request.json
      responses:
        '200':
          description: null if successful
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeleteDocumentResponse'
                examples:
                  $ref: example/DELETE_TEST_FOLDER-response.json
security:
  - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    ListTestFolderDocumentRequest:
      allOf:
        - $ref: '#/components/schemas/ListDocumentRequest'
        - properties:
            params:
              properties:
                documentModelName:
                  type: string
                  description: TestFolder-dm
    UpdateTestFolderRequest:
      allOf:
        - $ref: '#/components/schemas/ModifyDocumentRequest'
        - type: object
          required:
            - method
            - params
          properties:
            method:
              description: UPDATE_TEST_CASE_TREE_NODE
            params:
              required:
                - docRef
                - locale
                - document
              properties:
                document:
                  $ref: '#/components/schemas/TestFolderDocument'
      examples:
        - id: modifyTestFolder_7ed09ca9-955b-43be-9aa4-95afd8e9d20c
          method: UPDATE_TEST_CASE_TREE_NODE
          jsonrpc: '2.0'
          params:
            document:
              Root:
                General:
                  ProjectId: P_9
                  ProjectVersionNumber: 1.2.0
                  SubprojectId: SP_1
                  TestSuiteId: S_1
                  Title: Responsiveness
                  Id: F_2
                  TechnicalId: 88f3d26c-2b6a-4535-a5d2-2e0a6b72d40a
                  TenantId: T_1
                  Description: >-
                    EDITED Folder cotnains the test cases that tests the
                    responsiveness
                Metadata:
                  CreatedBy: tmtdev
                  DisplayCreatedOn: '2023-03-07T12:41:29'
                  CreatedOn: 1678192889715
                  EditedBy: trung
                  DisplayEditedOn: '2024-11-12T04:57:36'
                  EditedOn: 1731387456687
                  IsImported: false
                Attachments:
                  - FileName: 16K.jpg
                    CreatedAt: '2024-11-12T04:57:11'
                    UploadOn: '2024-11-12'
                    OriginalFileName: 16K.jpg
                    UploadBy: trung
                    Referenced: false
                    CopyNumber: 0
                    ThumbnailId: f2c2ee04-b8f6-490d-b6f0-68e1ac486a76
                    File:
                      content: null
                      attachment_id: 2c384792-c948-44c9-9212-95376ac75000
                      internal_filename: 1731387430179-12e66177-78d4-4eee-b598-faa629e7ddc8.jpg
                      original_filename: 16K.jpg
                      size: 86838
                      mime_type: image/jpeg
              __meta:
                creator: SYSTEM
                modifier: trung
                docRef: TestFolder-dm/20753
                modelReference: TestFolder-dm
                createdAt: '2023-08-09T06:45:07'
                modifiedAt: '2024-11-12T04:57:36'
                modelVersion: null
            locale: en
            docRef: TestFolder-dm/20753
    UpdateTestFolderResponse:
      allOf:
        - $ref: '#/components/schemas/TestFolderDocumentResponse'
      examples:
        - jsonrpc: '2.0'
          id: modifyTestFolder_7ed09ca9-955b-43be-9aa4-95afd8e9d20c
          result:
            docRef: TestFolder-dm/20753
            documentModelName: TestFolder-dm
            document:
              Root:
                General:
                  Title: Responsiveness
                  Id: F_2
                  Description: >-
                    EDITED Folder cotnains the test cases that tests the
                    responsiveness
    TestFolderDocumentResponse:
      allOf:
        - $ref: '#/components/schemas/RpcResult'
        - type: object
          properties:
            result:
              allOf:
                - $ref: '#/components/schemas/TestFolderDocumentResult'
      examples:
        - jsonrpc: '2.0'
          id: GET_DOCUMENT-50
          result:
            docRef: TestFolder-dm/20753
            documentModelName: TestFolder-dm
            document:
              Root:
                General:
                  ProjectId: P_9
                  ProjectVersionNumber: 1.2.0
                  SubprojectId: SP_1
                  TestSuiteId: S_1
                  Title: Responsiveness
                  Id: F_2
                  TechnicalId: 88f3d26c-2b6a-4535-a5d2-2e0a6b72d40a
                  TenantId: T_1
                  Description: Folder cotnains the test cases that tests the responsiveness
                Metadata:
                  CreatedBy: tmtdev
                  DisplayCreatedOn: '2023-03-07T12:41:29'
                  CreatedOn: 1678192889715
                  EditedBy: trung
                  DisplayEditedOn: '2024-11-12T04:57:36'
                  EditedOn: 1731387456687
                  IsImported: false
                Attachments:
                  - FileName: 16K.jpg
                    CreatedAt: '2024-11-12T04:57:11'
                    UploadOn: '2024-11-12'
                    OriginalFileName: 16K.jpg
                    UploadBy: trung
                    Referenced: false
                    CopyNumber: 0
                    ThumbnailId: f2c2ee04-b8f6-490d-b6f0-68e1ac486a76
                    File:
                      content: null
                      attachment_id: 2c384792-c948-44c9-9212-95376ac75000
                      internal_filename: 1731387430179-12e66177-78d4-4eee-b598-faa629e7ddc8.jpg
                      original_filename: 16K.jpg
                      size: 86838
                      mime_type: image/jpeg
              __meta:
                creator: SYSTEM
                modifier: trung
                docRef: TestFolder-dm/20753
                modelReference: TestFolder-dm
                createdAt: '2023-08-09T06:45:07'
                modifiedAt: '2024-11-12T04:57:36'
                modelVersion: null
    AddTestFolderRequest:
      allOf:
        - $ref: '#/components/schemas/AddDocumentRequest'
        - type: object
          required:
            - method
            - params
          properties:
            method:
              description: CREATE_TEST_CASE_TREE_NODE
            params:
              required:
                - documentModelName
                - locale
                - document
                - parentNodeDocRef
              properties:
                documentModelName:
                  type: string
                  description: TestFolder-dm
                parentNodeDocRef:
                  type: string
                  description: >-
                    the parent node's docRef of the created test case (Test
                    suite's docRef or Test folder's docRef)
                document:
                  $ref: '#/components/schemas/TestFolderDocument'
      examples:
        - id: addTestFolder_d471998c-cfdf-432c-9e9b-a449713e2ce6
          method: CREATE_TEST_CASE_TREE_NODE
          jsonrpc: '2.0'
          params:
            document:
              Root:
                General:
                  ProjectId: P_9
                  ProjectVersionNumber: 1.2.0
                  SubprojectId: SP_1
                  TestSuiteId: S_1
                  Title: Subscription
                  Description: Contain the test cases that tests the subscription feature
                Attachments:
                  - FileName: 16K.jpg
                    File:
                      content: null
                      attachment_id: 7449ab68-bd5c-4034-b79f-563a402f47f0
                      internal_filename: 1731394529389-8f161c46-a102-4911-a7ac-f11c7aa71c8d.jpg
                      original_filename: 16K.jpg
                      size: 86838
                      mime_type: image/jpeg
                    CreatedAt: '2024-11-12T06:55:30'
                    UploadOn: '2024-11-12'
                    OriginalFileName: 16K.jpg
                    UploadBy: trung
                    Referenced: false
                    CopyNumber: 0
                    ThumbnailId: dc6c84de-fe26-496b-8377-b46e21025511
              id: '-1'
            documentModelName: TestFolder-dm
            locale: en
            parentNodeDocRef: TestSuite-dm/20740
    AddTestFolderResponse:
      allOf:
        - $ref: '#/components/schemas/RpcResult'
        - type: object
          properties:
            result:
              allOf:
                - $ref: '#/components/schemas/TestFolderDocumentResult'
      examples:
        - jsonrpc: '2.0'
          id: addTestFolder_d471998c-cfdf-432c-9e9b-a449713e2ce6
          result:
            linkDescriptor:
              relationshipModel: TestSuiteTestCaseFolder-rm
              entities:
                - role: TestSuite
                  modelName: TestSuite-dm
                  docRef: TestSuite-dm/20740
                - role: TestCaseFolderSupertype
                  modelName: TestFolder-dm
                  docRef: TestFolder-dm/47532e25-b336-4375-a72b-b5173fe58571
              predecessorLinkRef: null
              position: BOTTOM
            id: '947429'
    RpcRequestWithIdAndJsonRpc:
      type: object
      required:
        - id
        - jsonrpc
      properties:
        id:
          type: string
          description: id of the operation
        jsonrpc:
          type: string
          description: must be 2.0
          example: '2.0'
    GetDocumentRequest:
      allOf:
        - $ref: '#/components/schemas/RpcRequestWithIdAndJsonRpc'
        - type: object
          required:
            - method
            - params
          properties:
            method:
              type: string
              description: GET_DOCUMENT
            params:
              required:
                - docRef
              properties:
                docRef:
                  type: string
                  description: document reference
      examples:
        - jsonrpc: '2.0'
          method: GET_DOCUMENT
          id: GET_DOCUMENT-50
          params:
            docRef: TestFolder-dm/20753
    RpcResult:
      type: object
      properties:
        jsonrpc:
          type: string
          description: request jsonrpc version
        id:
          type: string
          description: id of the operation
        result:
          type: object
    DocumentResult:
      type: object
      properties:
        docRef:
          type: string
          description: document reference
        documentModelName:
          type: string
          description: model name
        document:
          type: object
    SimpleTestFolderGeneral:
      type: object
      properties:
        Title:
          type: string
          description: The title of this test folder.
        Id:
          type: string
          description: The id of the test folder. This is unique in a project version
        Description:
          type: string
          description: The description of the test folder
    TestFolderGeneral:
      allOf:
        - $ref: '#/components/schemas/SimpleTestFolderGeneral'
        - type: object
          properties:
            ProjectId:
              type: string
              description: The project's Id associated with this item.
            ProjectVersionNumber:
              type: string
              description: >-
                The version number of the (sub) project associated with this
                item.
            SubprojectId:
              type: string
              description: The subproject's id under the main project.
            TestSuiteId:
              type: string
              description: The test suite's id containing this test case.
            TechnicalId:
              type: string
              description: The technical identifier of the test folder, often a UUID.
            TenantId:
              type: string
              description: The tenant id
    Metadata:
      type: object
      readOnly: true
      description: >-
        \[**Read only**] Metadata of the document. It will be ignored if
        included in the request of the add/update operations (e.g ADD_DOCUMENT,
        MODIFY_DOCUMENT)
      properties:
        CreatedBy:
          type: string
          description: who created this project
        DisplayCreatedOn:
          type: string
          format: date-time
          description: creation time in the human readable format (UTC time zone)
        CreatedOn:
          type: integer
          description: creation time of the project
        EditedBy:
          description: the last person who edited this project document
          type: string
        DisplayEditedOn:
          type: string
          format: date-time
          description: edited time in the human readable format (UTC time zone)
        EditedOn:
          description: the last edited time of the project
          type: integer
    File:
      type: object
      properties:
        content:
          type: string
          nullable: true
          description: Content of the file in base64 format.
        attachment_id:
          type: string
          description: Unique identifier for the attachment.
        internal_filename:
          type: string
          description: Internal storage filename for the attachment.
        original_filename:
          type: string
          description: Original name of the uploaded file.
        size:
          type: integer
          description: Size of the file in bytes.
        mime_type:
          type: string
          description: MIME type of the file.
    Attachment:
      type: object
      properties:
        FileName:
          type: string
          description: Name of the file attached.
        CreatedAt:
          type: string
          format: date-time
          description: Timestamp when the attachment was created.
        UploadOn:
          type: string
          format: date
          description: Date when the file was uploaded.
        OriginalFileName:
          type: string
          description: Original filename as provided during upload.
        UploadBy:
          type: string
          description: Username of the uploader.
        Referenced:
          type: boolean
          description: Indicates if the attachment is referenced elsewhere.
        CopyNumber:
          type: integer
          description: Number of times the attachment has been copied.
        ThumbnailId:
          type: string
          description: Identifier for the attachment’s thumbnail image.
        File:
          $ref: '#/components/schemas/File'
    Root:
      type: object
      properties:
        General:
          $ref: '#/components/schemas/TestFolderGeneral'
        Metadata:
          $ref: '#/components/schemas/Metadata'
        Attachments:
          type: array
          items:
            $ref: '#/components/schemas/Attachment'
    Meta:
      type: object
      readOnly: true
      description: >-
        \[**Read only**] Contain the meta data information of the document. **It
        will be ignored if included in the request of the update operations**
        (e.g MODIFY_DOCUMENT)
      properties:
        creator:
          type: string
          readOnly: true
          description: The user who created the document
        modifier:
          type: string
          readOnly: true
          description: The user who last modified the document
        docRef:
          type: string
          description: Reference to the document
        modelReference:
          type: string
          description: Reference to the model associated with the document
        createdAt:
          type: string
          format: date-time
          description: Timestamp when the document was created
        modifiedAt:
          type: string
          format: date-time
          description: Timestamp when the document was last modified
        modelVersion:
          type: string
          nullable: true
          description: Version of the model associated with the document
    TestFolderDocument:
      type: object
      properties:
        Root:
          $ref: '#/components/schemas/Root'
        __meta:
          $ref: '#/components/schemas/Meta'
    TestFolderDocumentResult:
      allOf:
        - $ref: '#/components/schemas/DocumentResult'
        - type: object
        - properties:
            document:
              description: Test folder document
              $ref: '#/components/schemas/TestFolderDocument'
    AddDocumentRequest:
      allOf:
        - $ref: '#/components/schemas/RpcRequestWithIdAndJsonRpc'
        - type: object
          required:
            - method
            - params
          properties:
            method:
              type: string
            params:
              required:
                - docRef
              properties:
                documentModelName:
                  type: string
                locale:
                  type: string
                  description: locale of the request. 'en' or 'de'
                document:
                  type: object
                  description: added document content
    ModifyDocumentRequest:
      allOf:
        - $ref: '#/components/schemas/RpcRequestWithIdAndJsonRpc'
        - type: object
          required:
            - method
            - params
          properties:
            method:
              type: string
              description: MODIFY_DOCUMENT
            params:
              required:
                - docRef
              properties:
                docRef:
                  type: string
                  description: document reference
                locale:
                  type: string
                  description: locale of the request. 'en' or 'de'
                document:
                  type: object
                  description: modified document content
    DeleteDocumentRequest:
      allOf:
        - $ref: '#/components/schemas/RpcRequestWithIdAndJsonRpc'
        - type: object
          required:
            - method
            - params
          properties:
            method:
              type: string
              description: DELETE_DOCUMENT
            params:
              required:
                - docRef
              properties:
                docRef:
                  type: string
                  description: document reference
      examples:
        - jsonrpc: '2.0'
          id: DELETE_FOLDER_01
          method: DELETE_FOLDER
          params:
            docRef: TestFolder-dm/47532e25-b336-4375-a72b-b5173fe58571
    DeleteDocumentResponse:
      allOf:
        - $ref: '#/components/schemas/RpcResult'
        - type: object
          properties:
            result:
              type: object
              description: null value
      examples:
        - jsonrpc: '2.0'
          id: DELETE_FOLDER_01
          result: null
    FilterSpec:
      description: filter specification.
      type: object
      properties:
        fullText:
          type: string
          description: the full text search
        filters:
          type: Array<String>
          description: Array of filter
        lang:
          type: string
          description: requested language
    PageSpec:
      description: pagination specification
      type: object
      properties:
        offset:
          type: integer
        limit:
          type: integer
    SortSpec:
      description: type is a specification of the sorting to be applied on the server side.
      type: object
      properties:
        order:
          type: string
        lang:
          type: string
    SortSpecArray:
      description: type is a specification of the sorting to be applied on the server side.
      type: Array
      items:
        $ref: '#/components/schemas/SortSpec'
    ListDocumentRequest:
      allOf:
        - $ref: '#/components/schemas/RpcRequestWithIdAndJsonRpc'
        - type: object
          required:
            - method
            - params
          properties:
            method:
              type: string
              description: LIST_DOCUMENT
            params:
              properties:
                documentModelName:
                  type: string
                filter:
                  $ref: '#/components/schemas/FilterSpec'
                page:
                  $ref: '#/components/schemas/PageSpec'
                sort:
                  type: array
                  $ref: '#/components/schemas/SortSpecArray'
  parameters:
    ProjectIdHeader:
      name: Project-Id
      in: header
      required: true
      schema:
        type: string
      description: Project Id or the project document reference
    SubProjectIdHeader:
      name: Subproject-Id
      in: header
      required: false
      schema:
        type: string
      description: >-
        Sub Project Id or the project document reference. It might be required
        if you want to access the sub project's resource
