{"action":"created","comment":{"url":"https://api.github.com/repos/nijens/openapi-bundle/pulls/comments/236401524","pull_request_review_id":178469681,"id":236401524,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNjQwMTUyNA==","diff_hunk":"@@ -0,0 +1,73 @@\n+<?php\n+\n+/*\n+ * This file is part of the OpenapiBundle package.\n+ *\n+ * (c) Niels Nijens <nijens.niels@gmail.com>\n+ *\n+ * For the full copyright and license information, please view the LICENSE\n+ * file that was distributed with this source code.\n+ */\n+\n+namespace Nijens\\OpenapiBundle\\Service;\n+\n+use Exception;\n+use Nijens\\OpenapiBundle\\Exception\\HttpExceptionInterface;\n+use Symfony\\Component\\HttpFoundation\\JsonResponse;\n+use Symfony\\Component\\HttpKernel\\Exception\\HttpException;\n+\n+/**\n+ * Builds a JSON response to an exception for OpenAPI routes.\n+ *\n+ * @author David Cochrum <dcochrum@sonnysdirect.com>\n+ */\n+class JsonResponseBuilderException implements JsonResponseBuilderExceptionInterface","path":"src/Service/JsonResponseBuilderException.php","position":24,"original_position":24,"commit_id":"8f5dd96b8a85e92dd7e65b4c82d4c3f8a52d3d2e","original_commit_id":"8f5dd96b8a85e92dd7e65b4c82d4c3f8a52d3d2e","user":{"login":"niels-nijens","id":3245362,"node_id":"MDQ6VXNlcjMyNDUzNjI=","avatar_url":"https://avatars3.githubusercontent.com/u/3245362?v=4","gravatar_id":"","url":"https://api.github.com/users/niels-nijens","html_url":"https://github.com/niels-nijens","followers_url":"https://api.github.com/users/niels-nijens/followers","following_url":"https://api.github.com/users/niels-nijens/following{/other_user}","gists_url":"https://api.github.com/users/niels-nijens/gists{/gist_id}","starred_url":"https://api.github.com/users/niels-nijens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/niels-nijens/subscriptions","organizations_url":"https://api.github.com/users/niels-nijens/orgs","repos_url":"https://api.github.com/users/niels-nijens/repos","events_url":"https://api.github.com/users/niels-nijens/events{/privacy}","received_events_url":"https://api.github.com/users/niels-nijens/received_events","type":"User","site_admin":false},"body":"Why did you decide to change the name from the previous `ExceptionJsonResponseBuilder` to this? At the moment the name would suggest this class is actually an exception class.","created_at":"2018-11-26T19:49:14Z","updated_at":"2018-11-26T19:49:15Z","html_url":"https://github.com/nijens/openapi-bundle/pull/13#discussion_r236401524","pull_request_url":"https://api.github.com/repos/nijens/openapi-bundle/pulls/13","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/nijens/openapi-bundle/pulls/comments/236401524"},"html":{"href":"https://github.com/nijens/openapi-bundle/pull/13#discussion_r236401524"},"pull_request":{"href":"https://api.github.com/repos/nijens/openapi-bundle/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/nijens/openapi-bundle/pulls/13","id":232805869,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMyODA1ODY5","html_url":"https://github.com/nijens/openapi-bundle/pull/13","diff_url":"https://github.com/nijens/openapi-bundle/pull/13.diff","patch_url":"https://github.com/nijens/openapi-bundle/pull/13.patch","issue_url":"https://api.github.com/repos/nijens/openapi-bundle/issues/13","number":13,"state":"open","locked":false,"title":"Add capability to override exception responses","user":{"login":"davidcochrum","id":10524697,"node_id":"MDQ6VXNlcjEwNTI0Njk3","avatar_url":"https://avatars1.githubusercontent.com/u/10524697?v=4","gravatar_id":"","url":"https://api.github.com/users/davidcochrum","html_url":"https://github.com/davidcochrum","followers_url":"https://api.github.com/users/davidcochrum/followers","following_url":"https://api.github.com/users/davidcochrum/following{/other_user}","gists_url":"https://api.github.com/users/davidcochrum/gists{/gist_id}","starred_url":"https://api.github.com/users/davidcochrum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidcochrum/subscriptions","organizations_url":"https://api.github.com/users/davidcochrum/orgs","repos_url":"https://api.github.com/users/davidcochrum/repos","events_url":"https://api.github.com/users/davidcochrum/events{/privacy}","received_events_url":"https://api.github.com/users/davidcochrum/received_events","type":"User","site_admin":false},"body":"## Custom Error Handling\r\n\r\nThe default error response template looks like:\r\n```json\r\n{\r\n    \"message\": \"Validation of JSON request body failed.\",\r\n    \"errors\": [\r\n        \"The property iAmRequired is required\",\r\n        \"The property iAmExtra is not defined and the definition does not allow additional properties\"\r\n    ]\r\n}\r\n```\r\n\r\nIf your project requires a different formatting of the response or perhaps different response codes, the default response builder can be overridden. Following the [\"How to Decorate Services\" guide from Symfony](https://symfony.com/doc/current/service_container/service_decoration.html), you can define your own service which implements `JsonResponseBuilderExceptionInterface` and handles the error response building instead of `nijens_openapi.service.json_response_builder_exception`. When validation against the schema fails, an exception will be thrown which implements `HttpExceptionInterface`. The `getErrors()` method will provide a multi-dimensional array similar to this:\r\n```php\r\narray(\r\n    array(\r\n        'property' => 'iAmRequired',\r\n        'pointer' => '/iAmRequired',\r\n        'message' => 'The property iAmRequired is required',\r\n        'constraint' => 'required',\r\n        'context' => 1,\r\n    ),\r\n    array(\r\n        'property' => '',\r\n        'pointer' => '',\r\n        'message' => 'The property iAmExtra is not defined and the definition does not allow additional properties',\r\n        'constraint' => 'additionalProp',\r\n        'context' => 1,\r\n    ),\r\n)\r\n```","created_at":"2018-11-21T21:46:03Z","updated_at":"2018-11-26T19:49:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2af3cb5e86f4fb3aa2559ca562de9acf487c72ff","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/nijens/openapi-bundle/pulls/13/commits","review_comments_url":"https://api.github.com/repos/nijens/openapi-bundle/pulls/13/comments","review_comment_url":"https://api.github.com/repos/nijens/openapi-bundle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nijens/openapi-bundle/issues/13/comments","statuses_url":"https://api.github.com/repos/nijens/openapi-bundle/statuses/8f5dd96b8a85e92dd7e65b4c82d4c3f8a52d3d2e","head":{"label":"sonnys-carwash-controls:exception-response-builder","ref":"exception-response-builder","sha":"8f5dd96b8a85e92dd7e65b4c82d4c3f8a52d3d2e","user":{"login":"sonnys-carwash-controls","id":22939903,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyOTM5OTAz","avatar_url":"https://avatars1.githubusercontent.com/u/22939903?v=4","gravatar_id":"","url":"https://api.github.com/users/sonnys-carwash-controls","html_url":"https://github.com/sonnys-carwash-controls","followers_url":"https://api.github.com/users/sonnys-carwash-controls/followers","following_url":"https://api.github.com/users/sonnys-carwash-controls/following{/other_user}","gists_url":"https://api.github.com/users/sonnys-carwash-controls/gists{/gist_id}","starred_url":"https://api.github.com/users/sonnys-carwash-controls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonnys-carwash-controls/subscriptions","organizations_url":"https://api.github.com/users/sonnys-carwash-controls/orgs","repos_url":"https://api.github.com/users/sonnys-carwash-controls/repos","events_url":"https://api.github.com/users/sonnys-carwash-controls/events{/privacy}","received_events_url":"https://api.github.com/users/sonnys-carwash-controls/received_events","type":"Organization","site_admin":false},"repo":{"id":158573650,"node_id":"MDEwOlJlcG9zaXRvcnkxNTg1NzM2NTA=","name":"openapi-bundle","full_name":"sonnys-carwash-controls/openapi-bundle","private":false,"owner":{"login":"sonnys-carwash-controls","id":22939903,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyOTM5OTAz","avatar_url":"https://avatars1.githubusercontent.com/u/22939903?v=4","gravatar_id":"","url":"https://api.github.com/users/sonnys-carwash-controls","html_url":"https://github.com/sonnys-carwash-controls","followers_url":"https://api.github.com/users/sonnys-carwash-controls/followers","following_url":"https://api.github.com/users/sonnys-carwash-controls/following{/other_user}","gists_url":"https://api.github.com/users/sonnys-carwash-controls/gists{/gist_id}","starred_url":"https://api.github.com/users/sonnys-carwash-controls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonnys-carwash-controls/subscriptions","organizations_url":"https://api.github.com/users/sonnys-carwash-controls/orgs","repos_url":"https://api.github.com/users/sonnys-carwash-controls/repos","events_url":"https://api.github.com/users/sonnys-carwash-controls/events{/privacy}","received_events_url":"https://api.github.com/users/sonnys-carwash-controls/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/sonnys-carwash-controls/openapi-bundle","description":"Helps you create a REST API from your OpenAPI specification.","fork":true,"url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle","forks_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/forks","keys_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/teams","hooks_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/hooks","issue_events_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/issues/events{/number}","events_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/events","assignees_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/assignees{/user}","branches_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/branches{/branch}","tags_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/tags","blobs_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/statuses/{sha}","languages_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/languages","stargazers_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/stargazers","contributors_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/contributors","subscribers_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/subscribers","subscription_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/subscription","commits_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/contents/{+path}","compare_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/merges","archive_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/downloads","issues_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/issues{/number}","pulls_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/pulls{/number}","milestones_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/milestones{/number}","notifications_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/labels{/name}","releases_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/releases{/id}","deployments_url":"https://api.github.com/repos/sonnys-carwash-controls/openapi-bundle/deployments","created_at":"2018-11-21T16:03:47Z","updated_at":"2018-11-23T16:13:45Z","pushed_at":"2018-11-23T16:15:06Z","git_url":"git://github.com/sonnys-carwash-controls/openapi-bundle.git","ssh_url":"git@github.com:sonnys-carwash-controls/openapi-bundle.git","clone_url":"https://github.com/sonnys-carwash-controls/openapi-bundle.git","svn_url":"https://github.com/sonnys-carwash-controls/openapi-bundle","homepage":null,"size":82,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"nijens:master","ref":"master","sha":"296882a5f8ce989e231e96e0188c6acd37fcd99d","user":{"login":"nijens","id":22254531,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyMjU0NTMx","avatar_url":"https://avatars3.githubusercontent.com/u/22254531?v=4","gravatar_id":"","url":"https://api.github.com/users/nijens","html_url":"https://github.com/nijens","followers_url":"https://api.github.com/users/nijens/followers","following_url":"https://api.github.com/users/nijens/following{/other_user}","gists_url":"https://api.github.com/users/nijens/gists{/gist_id}","starred_url":"https://api.github.com/users/nijens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nijens/subscriptions","organizations_url":"https://api.github.com/users/nijens/orgs","repos_url":"https://api.github.com/users/nijens/repos","events_url":"https://api.github.com/users/nijens/events{/privacy}","received_events_url":"https://api.github.com/users/nijens/received_events","type":"Organization","site_admin":false},"repo":{"id":134330854,"node_id":"MDEwOlJlcG9zaXRvcnkxMzQzMzA4NTQ=","name":"openapi-bundle","full_name":"nijens/openapi-bundle","private":false,"owner":{"login":"nijens","id":22254531,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIyMjU0NTMx","avatar_url":"https://avatars3.githubusercontent.com/u/22254531?v=4","gravatar_id":"","url":"https://api.github.com/users/nijens","html_url":"https://github.com/nijens","followers_url":"https://api.github.com/users/nijens/followers","following_url":"https://api.github.com/users/nijens/following{/other_user}","gists_url":"https://api.github.com/users/nijens/gists{/gist_id}","starred_url":"https://api.github.com/users/nijens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nijens/subscriptions","organizations_url":"https://api.github.com/users/nijens/orgs","repos_url":"https://api.github.com/users/nijens/repos","events_url":"https://api.github.com/users/nijens/events{/privacy}","received_events_url":"https://api.github.com/users/nijens/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/nijens/openapi-bundle","description":"Helps you create a REST API from your OpenAPI specification.","fork":false,"url":"https://api.github.com/repos/nijens/openapi-bundle","forks_url":"https://api.github.com/repos/nijens/openapi-bundle/forks","keys_url":"https://api.github.com/repos/nijens/openapi-bundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nijens/openapi-bundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nijens/openapi-bundle/teams","hooks_url":"https://api.github.com/repos/nijens/openapi-bundle/hooks","issue_events_url":"https://api.github.com/repos/nijens/openapi-bundle/issues/events{/number}","events_url":"https://api.github.com/repos/nijens/openapi-bundle/events","assignees_url":"https://api.github.com/repos/nijens/openapi-bundle/assignees{/user}","branches_url":"https://api.github.com/repos/nijens/openapi-bundle/branches{/branch}","tags_url":"https://api.github.com/repos/nijens/openapi-bundle/tags","blobs_url":"https://api.github.com/repos/nijens/openapi-bundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nijens/openapi-bundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nijens/openapi-bundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/nijens/openapi-bundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nijens/openapi-bundle/statuses/{sha}","languages_url":"https://api.github.com/repos/nijens/openapi-bundle/languages","stargazers_url":"https://api.github.com/repos/nijens/openapi-bundle/stargazers","contributors_url":"https://api.github.com/repos/nijens/openapi-bundle/contributors","subscribers_url":"https://api.github.com/repos/nijens/openapi-bundle/subscribers","subscription_url":"https://api.github.com/repos/nijens/openapi-bundle/subscription","commits_url":"https://api.github.com/repos/nijens/openapi-bundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/nijens/openapi-bundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/nijens/openapi-bundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/nijens/openapi-bundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/nijens/openapi-bundle/contents/{+path}","compare_url":"https://api.github.com/repos/nijens/openapi-bundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nijens/openapi-bundle/merges","archive_url":"https://api.github.com/repos/nijens/openapi-bundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nijens/openapi-bundle/downloads","issues_url":"https://api.github.com/repos/nijens/openapi-bundle/issues{/number}","pulls_url":"https://api.github.com/repos/nijens/openapi-bundle/pulls{/number}","milestones_url":"https://api.github.com/repos/nijens/openapi-bundle/milestones{/number}","notifications_url":"https://api.github.com/repos/nijens/openapi-bundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nijens/openapi-bundle/labels{/name}","releases_url":"https://api.github.com/repos/nijens/openapi-bundle/releases{/id}","deployments_url":"https://api.github.com/repos/nijens/openapi-bundle/deployments","created_at":"2018-05-21T22:16:39Z","updated_at":"2018-11-23T16:26:45Z","pushed_at":"2018-11-23T16:11:36Z","git_url":"git://github.com/nijens/openapi-bundle.git","ssh_url":"git@github.com:nijens/openapi-bundle.git","clone_url":"https://github.com/nijens/openapi-bundle.git","svn_url":"https://github.com/nijens/openapi-bundle","homepage":null,"size":62,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":5,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":2,"open_issues":5,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nijens/openapi-bundle/pulls/13"},"html":{"href":"https://github.com/nijens/openapi-bundle/pull/13"},"issue":{"href":"https://api.github.com/repos/nijens/openapi-bundle/issues/13"},"comments":{"href":"https://api.github.com/repos/nijens/openapi-bundle/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/nijens/openapi-bundle/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/nijens/openapi-bundle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nijens/openapi-bundle/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/nijens/openapi-bundle/statuses/8f5dd96b8a85e92dd7e65b4c82d4c3f8a52d3d2e"}},"author_association":"NONE"}}
{"actor":{"display_login":"niels-nijens"}}