spec_root: &spec_root
  x-sub-request-filters:
    - type: default
      name: http
  title: "The test service spec root"
  # Some more general RESTBase info
  paths:
    /service/simple_test/{title}:
      get:
        x-request-handler:
          - get_from_api:
              request:
                uri: http://mocked_domain_for_tests.com/{title}
        x-monitor: false
    /service/parallel_test/{title}:
      get:
        x-request-handler:
          - get_from_api1:
              request:
                uri: http://mocked_domain_for_tests.com/{title}
            get_from_api2:
              request:
                uri: http://mocked_domain_for_tests.com/{title}
          - return_result:
              return:
                status: 200
                headers:
                  'content-type': 'application/json'
                body:
                  res1: '{{get_from_api1.body}}'
                  res2: '{{get_from_api2.body}}'
        x-monitor: false
    /service/return_if_test/{title}:
      get:
        x-request-handler:
          - get_from_api:
              request:
                uri: http://mocked_domain_for_tests.com/{title}
              return_if:
                status: '2xx'
              catch:
                status:
                  - 404
                  - '3xx'
              return:
                status: '{{get_from_api.status}}'
                headers:
                  'content-type': '{{get_from_api.headers.content-type}}'
                body: '{{get_from_api.body}}'
          - repeat_request:
              request:
                uri: http://mocked_domain_for_tests.com/{title}
              return:
                status: '{{repeat_request.status}}'
                headers:
                  'content-type': '{{repeat_request.headers.content-type}}'
                body: '{{repeat_request.body}}'
        x-monitor: false

    /service/simple_catch/{title}:
      get:
        x-request-handler:
          - get_from_api:
              request:
                uri: http://mocked_domain_for_tests.com/{title}
              return_if:
                status: '2xx'
              catch:
                status: 404
              return:
                status: '{{get_from_api.status}}'
                headers:
                  'content-type': '{{get_from_api.headers.content-type}}'
                body: '{{get_from_api.body}}'
          - repeat_request:
              request:
                uri: http://mocked_domain_for_tests.com/{title}
              return:
                status: '{{repeat_request.status}}'
                headers:
                  'content-type': '{{repeat_request.headers.content-type}}'
                body: '{{repeat_request.body}}'
        x-monitor: false

    /service/non_status_catch/{title}:
      get:
        x-request-handler:
          - get_from_api:
              request:
                uri: http://mocked_domain_for_tests.com/{title}
              return_if:
                body:
                  test: 'test'
              return:
                status: '{{get_from_api.status}}'
                headers:
                  'content-type': '{{get_from_api.headers.content-type}}'
                body: '{{get_from_api.body}}'
        x-monitor: false

    /service/setup_test:
      get:
        x-setup-handler:
          - set_something:
              method: 'get'
              uri: http://mocked_domain_for_tests.com/test
              headers:
                test: 'test_value'
        x-request-handler:
          - get_from_api:
              return:
                status: 200
                body: 'result'
        x-monitor: false

# Finally, a standard service-runner config.
info:
  name: hyperswitch

services:
  - name: test_service
    module: ./lib/server
    conf:
      port: 12345
      spec: *spec_root
      default_page_size: 1
      user_agent: HyperSwitch-testsuite

