# yaml-language-server: $schema=../schemas/collection.json
# This collection contains one of everything. This is a regression test for
# deserialization, to make sure we don't accidentally introduce breaking changes
# to the format

name: Regression Test

.base_profile_data:
  host: https://httpbin.org
.base_recipe:
  headers:
    Accept: application/json

profiles:
  profile1:
    name: Profile 1
    data:
      $ref: "#/.base_profile_data"
      username: xX{{ command(['whoami']) | trim() }}Xx
      user_guid: abc123
  profile2:
    name: Profile 2
    default: true
    data:
      $ref: "#/.base_profile_data"

requests:
  text_body:
    method: POST
    # Missing name
    url: "{{ host }}/anything/login"
    query:
      sudo: yes_please
      fast: no_thanks
    headers:
      Accept: application/json
    # Text body
    body: >-
      {"username":"{{ username }}","password":"{{ prompt('Password', sensitive=true) }}"}

  users:
    name: Users
    requests:
      simple:
        name: Simple
        method: GET
        # No headers or authentication
        url: "{{ host }}/anything/{{ user_guid }}"
        query:
          one: "{{ field1 }}"
          many: ["{{ field1 }}", "{{ field2 }}"]

      json_body:
        $ref: "#/.base_recipe"
        method: PUT
        url: "{{ host }}/anything/{{ user_guid }}"
        authentication:
          type: bearer
          token: "{{ response('login') | jsonpath('$.token') }}"
        body:
          type: json
          data:
            {
              "username": "new username",
              "{{ dynamic_key }}": "{{ dynamic_value }}",
            }

      json_body_but_not:
        $ref: "#/.base_recipe"
        method: PUT
        url: "{{ host }}/anything/{{ user_guid }}"
        authentication:
          type: basic
          username: "{{ username }}"
          password: "{{password}}"
        body:
          type: json
          data: '{"warning": "NOT an object"}'

      form_urlencoded_body:
        $ref: "#/.base_recipe"
        method: PUT
        url: "{{ host }}/anything/{{ user_guid }}"
        body:
          type: form_urlencoded
          data:
            username: "new username"
