{"action":"created","issue":{"url":"https://api.github.com/repos/spring-cloud/spring-cloud-contract/issues/15","repository_url":"https://api.github.com/repos/spring-cloud/spring-cloud-contract","labels_url":"https://api.github.com/repos/spring-cloud/spring-cloud-contract/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/spring-cloud/spring-cloud-contract/issues/15/comments","events_url":"https://api.github.com/repos/spring-cloud/spring-cloud-contract/issues/15/events","html_url":"https://github.com/spring-cloud/spring-cloud-contract/issues/15","id":164791898,"number":15,"title":"Response DSL does not seem to support plain text on server side","user":{"login":"marcingrzejszczak","id":3297437,"avatar_url":"https://avatars.githubusercontent.com/u/3297437?v=3","gravatar_id":"","url":"https://api.github.com/users/marcingrzejszczak","html_url":"https://github.com/marcingrzejszczak","followers_url":"https://api.github.com/users/marcingrzejszczak/followers","following_url":"https://api.github.com/users/marcingrzejszczak/following{/other_user}","gists_url":"https://api.github.com/users/marcingrzejszczak/gists{/gist_id}","starred_url":"https://api.github.com/users/marcingrzejszczak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcingrzejszczak/subscriptions","organizations_url":"https://api.github.com/users/marcingrzejszczak/orgs","repos_url":"https://api.github.com/users/marcingrzejszczak/repos","events_url":"https://api.github.com/users/marcingrzejszczak/events{/privacy}","received_events_url":"https://api.github.com/users/marcingrzejszczak/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/spring-cloud/spring-cloud-contract/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-07-11T09:11:01Z","updated_at":"2016-07-11T09:11:05Z","closed_at":null,"body":"_From @making on May 4, 2016 6:44_\n\nI'd like to test plain text response but it does not support `regex`, `optional`, `execute` and so on.\r\n\r\n\r\nFor example,\r\n\r\n``` groovy\r\nio.codearte.accurest.dsl.GroovyDsl.make {\r\n    request {\r\n        method 'GET'\r\n        urlPath '/'\r\n    }\r\n    response {\r\n        status 200\r\n        body(value(\r\n                client('123'),\r\n                server(regex('[0-9]+'))\r\n        ))\r\n        headers {\r\n            header('Content-Type': 'text/plain;charset=ISO-8859-1')\r\n        }\r\n    }\r\n}\r\n```\r\n\r\ngenerates\r\n\r\n``` java\r\n\t@Test\r\n\tpublic void validate_shouldSayHello() throws Exception {\r\n\t\t// given:\r\n\t\t\tMockMvcRequestSpecification request = given();\r\n\r\n\t\t// when:\r\n\t\t\tResponseOptions response = given().spec(request)\r\n\t\t\t\t\t.get(\"/\");\r\n\r\n\t\t// then:\r\n\t\t\tassertThat(response.statusCode()).isEqualTo(200);\r\n\t\t\tassertThat(response.header(\"Content-Type\")).isEqualTo(\"text/plain;charset=ISO-8859-1\");\r\n\t\t// and:\r\n\t\t\tObject responseBody = (response.getBody().asString());\r\n\t\t\tassertThat(responseBody).isEqualTo(\"[0-9]+\"); // .matches(...) is expected 😩 \r\n\t}\r\n````\r\n\r\nOf course, JSON response works well\r\n\r\n``` groovy\r\nio.codearte.accurest.dsl.GroovyDsl.make {\r\n    request {\r\n        method 'GET'\r\n        urlPath '/'\r\n    }\r\n    response {\r\n        status 200\r\n        body(id : value(\r\n                client('123'),\r\n                server(regex('[0-9]+'))\r\n        ))\r\n        headers {\r\n            header('Content-Type': 'application/json;charset=UTF-8')\r\n        }\r\n    }\r\n}\r\n```\r\n\r\ngenerates\r\n\r\n``` java\r\n\t@Test\r\n\tpublic void validate_shouldSayHello() throws Exception {\r\n\t\t// given:\r\n\t\t\tMockMvcRequestSpecification request = given();\r\n\r\n\t\t// when:\r\n\t\t\tResponseOptions response = given().spec(request)\r\n\t\t\t\t\t.get(\"/\");\r\n\r\n\t\t// then:\r\n\t\t\tassertThat(response.statusCode()).isEqualTo(200);\r\n\t\t\tassertThat(response.header(\"Content-Type\")).isEqualTo(\"application/json;charset=UTF-8\");\r\n\t\t// and:\r\n\t\t\tDocumentContext parsedJson = JsonPath.parse(response.getBody().asString());\r\n\t\t\tassertThatJson(parsedJson).field(\"id\").matches(\"[0-9]+\"); // 😀\r\n\t}\r\n```\n\n_Copied from original issue: Codearte/accurest#263_"},"comment":{"url":"https://api.github.com/repos/spring-cloud/spring-cloud-contract/issues/comments/231681144","html_url":"https://github.com/spring-cloud/spring-cloud-contract/issues/15#issuecomment-231681144","issue_url":"https://api.github.com/repos/spring-cloud/spring-cloud-contract/issues/15","id":231681144,"user":{"login":"marcingrzejszczak","id":3297437,"avatar_url":"https://avatars.githubusercontent.com/u/3297437?v=3","gravatar_id":"","url":"https://api.github.com/users/marcingrzejszczak","html_url":"https://github.com/marcingrzejszczak","followers_url":"https://api.github.com/users/marcingrzejszczak/followers","following_url":"https://api.github.com/users/marcingrzejszczak/following{/other_user}","gists_url":"https://api.github.com/users/marcingrzejszczak/gists{/gist_id}","starred_url":"https://api.github.com/users/marcingrzejszczak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcingrzejszczak/subscriptions","organizations_url":"https://api.github.com/users/marcingrzejszczak/orgs","repos_url":"https://api.github.com/users/marcingrzejszczak/repos","events_url":"https://api.github.com/users/marcingrzejszczak/events{/privacy}","received_events_url":"https://api.github.com/users/marcingrzejszczak/received_events","type":"User","site_admin":false},"created_at":"2016-07-11T09:11:03Z","updated_at":"2016-07-11T09:11:03Z","body":"_From @making on May 4, 2016 8:10_\n\n> Ah the regex etc might have never worked actually. I think we focused on jsons with those\r\n\r\nOh..\r\nActually, this is not critical.\r\nI just wanted to create a small demo project using accurest.\r\nhttps://github.com/making/jsug-spring-cloud/tree/accurest\r\n\r\nI'll use a fixed value to test plain text response so far.\r\nhttps://github.com/making/jsug-spring-cloud/blob/1f0d5f766fb558051fc30ca08333dda1a4017f4b/jsug-producer/src/test/java/com/example/MvcTest.java#L14-L15"}}
{"actor":{"display_login":"marcingrzejszczak"}}