/api/test/testmap:
  get:
    tags: [Test]
    summary: List all test mappings
    security:
      - bearerAuth: []
    responses:
      '200':
        description: List of test mappings
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  example: success
                message:
                  type: string
                data:
                  type: array
                  items:
                    type: object
                    properties:
                      TestMapID:
                        type: integer
                      HostType:
                        type: string
                      HostID:
                        type: string
                      HostName:
                        type: string
                      ClientType:
                        type: string
                      ClientID:
                        type: string
                      ClientName:
                        type: string

  post:
    tags: [Test]
    summary: Create test mapping (header only)
    security:
      - bearerAuth: []
    requestBody:
      required: true
      content:
        application/json:
          schema:
            type: object
            properties:
              HostType:
                type: string
                description: Host type code
              HostID:
                type: string
                description: Host identifier
              ClientType:
                type: string
                description: Client type code
              ClientID:
                type: string
                description: Client identifier
              details:
                type: array
                description: Optional detail records to create alongside the header
                items:
                  type: object
                  properties:
                    HostTestCode:
                      type: string
                    HostTestName:
                      type: string
                    ConDefID:
                      type: integer
                    ClientTestCode:
                      type: string
                    ClientTestName:
                      type: string
    responses:
      '201':
        description: Test mapping created
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  example: success
                message:
                  type: string
                data:
                  type: integer
                  description: Created TestMapID


  delete:
    tags: [Test]
    summary: Soft delete test mapping (cascades to details)
    security:
      - bearerAuth: []
    requestBody:
      required: true
      content:
        application/json:
          schema:
            type: object
            properties:
              TestMapID:
                type: integer
                description: Test Map ID to delete (required)
            required:
              - TestMapID
    responses:
      '200':
        description: Test mapping deleted successfully
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  example: success
                message:
                  type: string
                data:
                  type: integer
                  description: Deleted TestMapID
      '404':
        description: Test mapping not found or already deleted

/api/test/testmap/{id}:
  get:
    tags: [Test]
    summary: Get test mapping by ID with details
    security:
      - bearerAuth: []
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
        description: Test Map ID
    responses:
      '200':
        description: Test mapping details with nested detail records
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                message:
                  type: string
                data:
                  $ref: '../components/schemas/tests.yaml#/TestMap'
      '404':
        description: Test mapping not found

  patch:
    tags: [Test]
    summary: Update test mapping
    security:
      - bearerAuth: []
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
        description: Test Map ID
    requestBody:
      required: true
      content:
        application/json:
          schema:
            type: object
            properties:
              HostType:
                type: string
              HostID:
                type: string
              ClientType:
                type: string
              ClientID:
                type: string
              details:
                type: object
                description: Apply detail-level changes together with the header update
                properties:
                  new:
                    type: array
                    description: New detail records to insert
                    items:
                      type: object
                      properties:
                        HostTestCode:
                          type: string
                        HostTestName:
                          type: string
                        ConDefID:
                          type: integer
                        ClientTestCode:
                          type: string
                        ClientTestName:
                          type: string
                  edit:
                    type: array
                    description: Existing detail records to update
                    items:
                      type: object
                      properties:
                        TestMapDetailID:
                          type: integer
                        HostTestCode:
                          type: string
                        HostTestName:
                          type: string
                        ConDefID:
                          type: integer
                        ClientTestCode:
                          type: string
                        ClientTestName:
                          type: string
                  deleted:
                    type: array
                    description: TestMapDetailIDs to soft delete
                    items:
                      type: integer
            responses:
      '200':
        description: Test mapping updated
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                  example: success
                message:
                  type: string
                data:
                  type: integer
                  description: Updated TestMapID

/api/test/testmap/by-testcode/{testCode}:
  get:
    tags: [Test]
    summary: Get test mappings by test code with details
    security:
      - bearerAuth: []
    parameters:
      - name: testCode
        in: path
        required: true
        schema:
          type: string
        description: Test Code (matches HostTestCode or ClientTestCode)
    responses:
      '200':
        description: List of test mappings with details for the test code
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                message:
                  type: string
                data:
                  type: array
                  items:
                    $ref: '../components/schemas/tests.yaml#/TestMap'

/api/test/testmap/detail:
  get:
    tags: [Test]
    summary: List test mapping details
    security:
      - bearerAuth: []
    parameters:
      - name: TestMapID
        in: query
        schema:
          type: integer
        description: Filter by TestMapID
    responses:
      '200':
        description: List of test mapping details
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                message:
                  type: string
                data:
                  type: array
                  items:
                    $ref: '../components/schemas/tests.yaml#/TestMapDetail'

  post:
    tags: [Test]
    summary: Create test mapping detail
    security:
      - bearerAuth: []
    requestBody:
      required: true
      content:
        application/json:
          schema:
            type: object
            properties:
              TestMapID:
                type: integer
                description: Test Map ID (required)
              HostTestCode:
                type: string
              HostTestName:
                type: string
              ConDefID:
                type: integer
              ClientTestCode:
                type: string
              ClientTestName:
                type: string
            required:
              - TestMapID
    responses:
      '201':
        description: Test mapping detail created
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                message:
                  type: string
                data:
                  type: integer
                  description: Created TestMapDetailID


  delete:
    tags: [Test]
    summary: Soft delete test mapping detail
    security:
      - bearerAuth: []
    requestBody:
      required: true
      content:
        application/json:
          schema:
            type: object
            properties:
              TestMapDetailID:
                type: integer
                description: Test Map Detail ID to delete (required)
            required:
              - TestMapDetailID
    responses:
      '200':
        description: Test mapping detail deleted

/api/test/testmap/detail/{id}:
  get:
    tags: [Test]
    summary: Get test mapping detail by ID
    security:
      - bearerAuth: []
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
        description: Test Map Detail ID
    responses:
      '200':
        description: Test mapping detail
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                message:
                  type: string
                data:
                  $ref: '../components/schemas/tests.yaml#/TestMapDetail'

  patch:
    tags: [Test]
    summary: Update test mapping detail
    security:
      - bearerAuth: []
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: integer
        description: Test Map Detail ID
    requestBody:
      required: true
      content:
        application/json:
          schema:
            type: object
            properties:
              TestMapID:
                type: integer
              HostTestCode:
                type: string
              HostTestName:
                type: string
              ConDefID:
                type: integer
              ClientTestCode:
                type: string
              ClientTestName:
                type: string
    responses:
      '200':
        description: Test mapping detail updated

/api/test/testmap/detail/by-testmap/{testMapID}:
  get:
    tags: [Test]
    summary: Get test mapping details by test map ID
    security:
      - bearerAuth: []
    parameters:
      - name: testMapID
        in: path
        required: true
        schema:
          type: integer
        description: Test Map ID
    responses:
      '200':
        description: List of test mapping details
        content:
          application/json:
            schema:
              type: object
              properties:
                status:
                  type: string
                message:
                  type: string
                data:
                  type: array
                  items:
                    $ref: '../components/schemas/tests.yaml#/TestMapDetail'

/api/test/testmap/detail/batch:
  post:
    tags: [Test]
    summary: Batch create test mapping details
    security:
      - bearerAuth: []
    requestBody:
      required: true
      content:
        application/json:
          schema:
            type: array
            items:
              type: object
              properties:
                TestMapID:
                  type: integer
                HostTestCode:
                  type: string
                HostTestName:
                  type: string
                ConDefID:
                  type: integer
                ClientTestCode:
                  type: string
                ClientTestName:
                  type: string
    responses:
      '200':
        description: Batch create results

  patch:
    tags: [Test]
    summary: Batch update test mapping details
    security:
      - bearerAuth: []
    requestBody:
      required: true
      content:
        application/json:
          schema:
            type: array
            items:
              type: object
              properties:
                TestMapDetailID:
                  type: integer
                TestMapID:
                  type: integer
                HostTestCode:
                  type: string
                HostTestName:
                  type: string
                ConDefID:
                  type: integer
                ClientTestCode:
                  type: string
                ClientTestName:
                  type: string
    responses:
      '200':
        description: Batch update results

  delete:
    tags: [Test]
    summary: Batch delete test mapping details
    security:
      - bearerAuth: []
    requestBody:
      required: true
      content:
        application/json:
          schema:
            type: array
            items:
              type: integer
              description: TestMapDetailIDs to delete
    responses:
      '200':
        description: Batch delete results
