{"action":"created","comment":{"url":"https://api.github.com/repos/marshmallow-code/apispec/pulls/comments/44746959","id":44746959,"diff_hunk":"@@ -19,16 +19,22 @@\n \n def clean_operations(operations):\n     \"\"\"Ensure that all parameters with \"in\" equal to \"path\" are also required\n-    as required by the Swagger specification.\n+    as required by the Swagger specification, as well as normalizing any\n+    references to global parameters.\n \n     See https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#parameterObject.\n \n     :param dict operations: Dict mapping status codes to operations\n     \"\"\"\n+    get_ref = lambda x: x if isinstance(x, dict) else {'$ref': '#/parameters/' + x}\n+\n     for operation in (operations or {}).values():\n-        for parameter in operation.get('parameters', []):\n-            if parameter['in'] == 'path':\n-                parameter['required'] = True\n+        if 'parameters' in operation:","path":"apispec/core.py","position":18,"original_position":18,"commit_id":"dc422aefbcab9b7f1caf52a8826dd0ff734ae335","original_commit_id":"dc422aefbcab9b7f1caf52a8826dd0ff734ae335","user":{"login":"sloria","id":2379650,"avatar_url":"https://avatars.githubusercontent.com/u/2379650?v=3","gravatar_id":"","url":"https://api.github.com/users/sloria","html_url":"https://github.com/sloria","followers_url":"https://api.github.com/users/sloria/followers","following_url":"https://api.github.com/users/sloria/following{/other_user}","gists_url":"https://api.github.com/users/sloria/gists{/gist_id}","starred_url":"https://api.github.com/users/sloria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sloria/subscriptions","organizations_url":"https://api.github.com/users/sloria/orgs","repos_url":"https://api.github.com/users/sloria/repos","events_url":"https://api.github.com/users/sloria/events{/privacy}","received_events_url":"https://api.github.com/users/sloria/received_events","type":"User","site_admin":false},"body":"I personally liked the brevity of \r\n\r\n```python\r\n for parameter in operation.get('parameters', []):\r\n```\r\n\r\nIs there a specific reason this was changed?","created_at":"2015-11-13T03:38:50Z","updated_at":"2015-11-13T03:38:50Z","html_url":"https://github.com/marshmallow-code/apispec/pull/36#discussion_r44746959","pull_request_url":"https://api.github.com/repos/marshmallow-code/apispec/pulls/36","_links":{"self":{"href":"https://api.github.com/repos/marshmallow-code/apispec/pulls/comments/44746959"},"html":{"href":"https://github.com/marshmallow-code/apispec/pull/36#discussion_r44746959"},"pull_request":{"href":"https://api.github.com/repos/marshmallow-code/apispec/pulls/36"}}},"pull_request":{"url":"https://api.github.com/repos/marshmallow-code/apispec/pulls/36","id":50031730,"html_url":"https://github.com/marshmallow-code/apispec/pull/36","diff_url":"https://github.com/marshmallow-code/apispec/pull/36.diff","patch_url":"https://github.com/marshmallow-code/apispec/pull/36.patch","issue_url":"https://api.github.com/repos/marshmallow-code/apispec/issues/36","number":36,"state":"open","locked":false,"title":"Add global parameters to spec.","user":{"login":"jta","id":235585,"avatar_url":"https://avatars.githubusercontent.com/u/235585?v=3","gravatar_id":"","url":"https://api.github.com/users/jta","html_url":"https://github.com/jta","followers_url":"https://api.github.com/users/jta/followers","following_url":"https://api.github.com/users/jta/following{/other_user}","gists_url":"https://api.github.com/users/jta/gists{/gist_id}","starred_url":"https://api.github.com/users/jta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jta/subscriptions","organizations_url":"https://api.github.com/users/jta/orgs","repos_url":"https://api.github.com/users/jta/repos","events_url":"https://api.github.com/users/jta/events{/privacy}","received_events_url":"https://api.github.com/users/jta/received_events","type":"User","site_admin":false},"body":"Swagger supports referencing common parameters by inserting a `$ref` to\r\n`#/parameters/<name>`. This commit adds a `add_parameter` method to\r\nAPISpec, which appends parameters to the base swagger config.\r\n\r\nWhen parsing the YAML doc, string objects in the parameters field get\r\nconverted into references. This makes the docstrings much shorter, e.g:\r\n\r\n```\r\n    get:\r\n        description: Retrieve object\r\n        parameters:\r\n         - arg1\r\n         - name: arg2\r\n           in: path\r\n           ...\r\n```\r\n\r\nCurrently no check is made to verify `arg1` is a valid reference, but\r\nthis could easily be done by validating the resulting yaml from\r\n`spec.to_dict()`.\r\n\r\nI'm not hung up on implementation since I've only played around with the\r\ncode for a bit, but I do need the feature in order to be able to write\r\nlarger APIs without repeating myself constantly. Feel free to suggest\r\nimprovements.","created_at":"2015-11-07T08:48:00Z","updated_at":"2015-11-13T03:38:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d0a9cac5d0bfcf0fd4cb5272e76af3d1e88e3d7a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/marshmallow-code/apispec/pulls/36/commits","review_comments_url":"https://api.github.com/repos/marshmallow-code/apispec/pulls/36/comments","review_comment_url":"https://api.github.com/repos/marshmallow-code/apispec/pulls/comments{/number}","comments_url":"https://api.github.com/repos/marshmallow-code/apispec/issues/36/comments","statuses_url":"https://api.github.com/repos/marshmallow-code/apispec/statuses/dc422aefbcab9b7f1caf52a8826dd0ff734ae335","head":{"label":"jta:dev","ref":"dev","sha":"dc422aefbcab9b7f1caf52a8826dd0ff734ae335","user":{"login":"jta","id":235585,"avatar_url":"https://avatars.githubusercontent.com/u/235585?v=3","gravatar_id":"","url":"https://api.github.com/users/jta","html_url":"https://github.com/jta","followers_url":"https://api.github.com/users/jta/followers","following_url":"https://api.github.com/users/jta/following{/other_user}","gists_url":"https://api.github.com/users/jta/gists{/gist_id}","starred_url":"https://api.github.com/users/jta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jta/subscriptions","organizations_url":"https://api.github.com/users/jta/orgs","repos_url":"https://api.github.com/users/jta/repos","events_url":"https://api.github.com/users/jta/events{/privacy}","received_events_url":"https://api.github.com/users/jta/received_events","type":"User","site_admin":false},"repo":{"id":45728420,"name":"apispec","full_name":"jta/apispec","owner":{"login":"jta","id":235585,"avatar_url":"https://avatars.githubusercontent.com/u/235585?v=3","gravatar_id":"","url":"https://api.github.com/users/jta","html_url":"https://github.com/jta","followers_url":"https://api.github.com/users/jta/followers","following_url":"https://api.github.com/users/jta/following{/other_user}","gists_url":"https://api.github.com/users/jta/gists{/gist_id}","starred_url":"https://api.github.com/users/jta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jta/subscriptions","organizations_url":"https://api.github.com/users/jta/orgs","repos_url":"https://api.github.com/users/jta/repos","events_url":"https://api.github.com/users/jta/events{/privacy}","received_events_url":"https://api.github.com/users/jta/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jta/apispec","description":"A pluggable API documentation generator. Currently supports the Swagger 2.0 specification. Formerly smore.","fork":true,"url":"https://api.github.com/repos/jta/apispec","forks_url":"https://api.github.com/repos/jta/apispec/forks","keys_url":"https://api.github.com/repos/jta/apispec/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jta/apispec/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jta/apispec/teams","hooks_url":"https://api.github.com/repos/jta/apispec/hooks","issue_events_url":"https://api.github.com/repos/jta/apispec/issues/events{/number}","events_url":"https://api.github.com/repos/jta/apispec/events","assignees_url":"https://api.github.com/repos/jta/apispec/assignees{/user}","branches_url":"https://api.github.com/repos/jta/apispec/branches{/branch}","tags_url":"https://api.github.com/repos/jta/apispec/tags","blobs_url":"https://api.github.com/repos/jta/apispec/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jta/apispec/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jta/apispec/git/refs{/sha}","trees_url":"https://api.github.com/repos/jta/apispec/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jta/apispec/statuses/{sha}","languages_url":"https://api.github.com/repos/jta/apispec/languages","stargazers_url":"https://api.github.com/repos/jta/apispec/stargazers","contributors_url":"https://api.github.com/repos/jta/apispec/contributors","subscribers_url":"https://api.github.com/repos/jta/apispec/subscribers","subscription_url":"https://api.github.com/repos/jta/apispec/subscription","commits_url":"https://api.github.com/repos/jta/apispec/commits{/sha}","git_commits_url":"https://api.github.com/repos/jta/apispec/git/commits{/sha}","comments_url":"https://api.github.com/repos/jta/apispec/comments{/number}","issue_comment_url":"https://api.github.com/repos/jta/apispec/issues/comments{/number}","contents_url":"https://api.github.com/repos/jta/apispec/contents/{+path}","compare_url":"https://api.github.com/repos/jta/apispec/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jta/apispec/merges","archive_url":"https://api.github.com/repos/jta/apispec/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jta/apispec/downloads","issues_url":"https://api.github.com/repos/jta/apispec/issues{/number}","pulls_url":"https://api.github.com/repos/jta/apispec/pulls{/number}","milestones_url":"https://api.github.com/repos/jta/apispec/milestones{/number}","notifications_url":"https://api.github.com/repos/jta/apispec/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jta/apispec/labels{/name}","releases_url":"https://api.github.com/repos/jta/apispec/releases{/id}","created_at":"2015-11-07T08:24:27Z","updated_at":"2015-11-07T08:24:27Z","pushed_at":"2015-11-10T15:41:29Z","git_url":"git://github.com/jta/apispec.git","ssh_url":"git@github.com:jta/apispec.git","clone_url":"https://github.com/jta/apispec.git","svn_url":"https://github.com/jta/apispec","homepage":"https://apispec.readthedocs.org/","size":265,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"marshmallow-code:dev","ref":"dev","sha":"9e4a8c947b9c04fc1fb6b0c298a133c5521577cc","user":{"login":"marshmallow-code","id":10334301,"avatar_url":"https://avatars.githubusercontent.com/u/10334301?v=3","gravatar_id":"","url":"https://api.github.com/users/marshmallow-code","html_url":"https://github.com/marshmallow-code","followers_url":"https://api.github.com/users/marshmallow-code/followers","following_url":"https://api.github.com/users/marshmallow-code/following{/other_user}","gists_url":"https://api.github.com/users/marshmallow-code/gists{/gist_id}","starred_url":"https://api.github.com/users/marshmallow-code/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marshmallow-code/subscriptions","organizations_url":"https://api.github.com/users/marshmallow-code/orgs","repos_url":"https://api.github.com/users/marshmallow-code/repos","events_url":"https://api.github.com/users/marshmallow-code/events{/privacy}","received_events_url":"https://api.github.com/users/marshmallow-code/received_events","type":"Organization","site_admin":false},"repo":{"id":25413181,"name":"apispec","full_name":"marshmallow-code/apispec","owner":{"login":"marshmallow-code","id":10334301,"avatar_url":"https://avatars.githubusercontent.com/u/10334301?v=3","gravatar_id":"","url":"https://api.github.com/users/marshmallow-code","html_url":"https://github.com/marshmallow-code","followers_url":"https://api.github.com/users/marshmallow-code/followers","following_url":"https://api.github.com/users/marshmallow-code/following{/other_user}","gists_url":"https://api.github.com/users/marshmallow-code/gists{/gist_id}","starred_url":"https://api.github.com/users/marshmallow-code/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marshmallow-code/subscriptions","organizations_url":"https://api.github.com/users/marshmallow-code/orgs","repos_url":"https://api.github.com/users/marshmallow-code/repos","events_url":"https://api.github.com/users/marshmallow-code/events{/privacy}","received_events_url":"https://api.github.com/users/marshmallow-code/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/marshmallow-code/apispec","description":"A pluggable API documentation generator. Currently supports the Swagger 2.0 specification. Formerly smore.","fork":false,"url":"https://api.github.com/repos/marshmallow-code/apispec","forks_url":"https://api.github.com/repos/marshmallow-code/apispec/forks","keys_url":"https://api.github.com/repos/marshmallow-code/apispec/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marshmallow-code/apispec/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marshmallow-code/apispec/teams","hooks_url":"https://api.github.com/repos/marshmallow-code/apispec/hooks","issue_events_url":"https://api.github.com/repos/marshmallow-code/apispec/issues/events{/number}","events_url":"https://api.github.com/repos/marshmallow-code/apispec/events","assignees_url":"https://api.github.com/repos/marshmallow-code/apispec/assignees{/user}","branches_url":"https://api.github.com/repos/marshmallow-code/apispec/branches{/branch}","tags_url":"https://api.github.com/repos/marshmallow-code/apispec/tags","blobs_url":"https://api.github.com/repos/marshmallow-code/apispec/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marshmallow-code/apispec/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marshmallow-code/apispec/git/refs{/sha}","trees_url":"https://api.github.com/repos/marshmallow-code/apispec/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marshmallow-code/apispec/statuses/{sha}","languages_url":"https://api.github.com/repos/marshmallow-code/apispec/languages","stargazers_url":"https://api.github.com/repos/marshmallow-code/apispec/stargazers","contributors_url":"https://api.github.com/repos/marshmallow-code/apispec/contributors","subscribers_url":"https://api.github.com/repos/marshmallow-code/apispec/subscribers","subscription_url":"https://api.github.com/repos/marshmallow-code/apispec/subscription","commits_url":"https://api.github.com/repos/marshmallow-code/apispec/commits{/sha}","git_commits_url":"https://api.github.com/repos/marshmallow-code/apispec/git/commits{/sha}","comments_url":"https://api.github.com/repos/marshmallow-code/apispec/comments{/number}","issue_comment_url":"https://api.github.com/repos/marshmallow-code/apispec/issues/comments{/number}","contents_url":"https://api.github.com/repos/marshmallow-code/apispec/contents/{+path}","compare_url":"https://api.github.com/repos/marshmallow-code/apispec/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marshmallow-code/apispec/merges","archive_url":"https://api.github.com/repos/marshmallow-code/apispec/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marshmallow-code/apispec/downloads","issues_url":"https://api.github.com/repos/marshmallow-code/apispec/issues{/number}","pulls_url":"https://api.github.com/repos/marshmallow-code/apispec/pulls{/number}","milestones_url":"https://api.github.com/repos/marshmallow-code/apispec/milestones{/number}","notifications_url":"https://api.github.com/repos/marshmallow-code/apispec/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marshmallow-code/apispec/labels{/name}","releases_url":"https://api.github.com/repos/marshmallow-code/apispec/releases{/id}","created_at":"2014-10-18T23:48:49Z","updated_at":"2015-11-12T17:37:31Z","pushed_at":"2015-11-10T13:47:41Z","git_url":"git://github.com/marshmallow-code/apispec.git","ssh_url":"git@github.com:marshmallow-code/apispec.git","clone_url":"https://github.com/marshmallow-code/apispec.git","svn_url":"https://github.com/marshmallow-code/apispec","homepage":"https://apispec.readthedocs.org/","size":630,"stargazers_count":26,"watchers_count":26,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":4,"forks":7,"open_issues":4,"watchers":26,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/marshmallow-code/apispec/pulls/36"},"html":{"href":"https://github.com/marshmallow-code/apispec/pull/36"},"issue":{"href":"https://api.github.com/repos/marshmallow-code/apispec/issues/36"},"comments":{"href":"https://api.github.com/repos/marshmallow-code/apispec/issues/36/comments"},"review_comments":{"href":"https://api.github.com/repos/marshmallow-code/apispec/pulls/36/comments"},"review_comment":{"href":"https://api.github.com/repos/marshmallow-code/apispec/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/marshmallow-code/apispec/pulls/36/commits"},"statuses":{"href":"https://api.github.com/repos/marshmallow-code/apispec/statuses/dc422aefbcab9b7f1caf52a8826dd0ff734ae335"}}}}