import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method '{{request_method}}'
        urlPath('{{request_url}}') {{#request_urlpath_present}} {
            queryParameters {
                {{#request_queryparams}}
                    parameter('''{{key}}''', '''{{value}}''')
                {{/request_queryparams}}
            }
        } {{/request_urlpath_present}}
        {{#request_body_present}}
        body('''{{request_body}}''')
        {{/request_body_present}}
        {{#request_headers_present}}
        headers {
            {{#request_headers}}
            header('''{{key}}''', '''{{value}}''')
            {{/request_headers}}
        }
        {{/request_headers_present}}
        {{#request_json_paths_present}}
        bodyMatchers {
            {{#request_json_paths}}
                jsonPath('''{{jsonPath}}''', byEquality())
            {{/request_json_paths}}
        }
        {{/request_json_paths_present}}
    }
    response {
        status {{response_status}}
    {{#response_body_present}}
        body('''{{response_body}}''')
    {{/response_body_present}}
    {{#response_headers_present}}
        headers {
        {{#response_headers}}
            header('''{{key}}''', '''{{value}}''')
        {{/response_headers}}
        }
    {{/response_headers_present}}
    }
    {{#priority_present}}
    priority {{priority}}
    {{/priority_present}}
}
