{"action":"created","comment":{"url":"https://api.github.com/repos/lendingblock/aio-openapi/pulls/comments/199435032","pull_request_review_id":133541543,"id":199435032,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5OTQzNTAzMg==","diff_hunk":"@@ -67,20 +67,50 @@ def parse(self):\n             self.parsed_schemas[schema.__name__] = parsed_schema\n         return self.parsed_schemas\n \n+    def field2json(self, field):\n+        field = fields.as_field(field)\n+        mapping = self._fields_mapping.get(field.type, None)\n+        enum = None\n+        if not mapping:\n+            if is_subclass(field.type, Enum):\n+                mapping = dict(type='string')\n+                enum = [e.name for e in field.type]\n+            elif is_subclass(field.type, List):\n+                return self._list2json(field.type)\n+            elif is_dataclass(field.type):\n+                return self._get_schema_ref(field.type)\n+            else:\n+                raise InvalidTypeException(field.type)\n+\n+        json_property = {'type': mapping['type']}\n+        meta = field.metadata\n+        if meta.get(fields.DESCRIPTION):\n+            json_property['description'] = meta.get(fields.DESCRIPTION)\n+        format = meta.get(fields.FORMAT) or mapping.get(fields.FORMAT, None)\n+        if format:\n+            json_property[fields.FORMAT] = format\n+        if enum:\n+            json_property['enum'] = enum\n+        validator = meta.get(fields.VALIDATOR)\n+        if isinstance(validator, fields.Validator):\n+            validator.openapi(json_property)","path":"openapi/spec/spec.py","position":57,"original_position":57,"commit_id":"65f62f6be900552bd00de05503c0108b2e44964c","original_commit_id":"65f62f6be900552bd00de05503c0108b2e44964c","user":{"login":"ConorStevenson","id":29042708,"node_id":"MDQ6VXNlcjI5MDQyNzA4","avatar_url":"https://avatars0.githubusercontent.com/u/29042708?v=4","gravatar_id":"","url":"https://api.github.com/users/ConorStevenson","html_url":"https://github.com/ConorStevenson","followers_url":"https://api.github.com/users/ConorStevenson/followers","following_url":"https://api.github.com/users/ConorStevenson/following{/other_user}","gists_url":"https://api.github.com/users/ConorStevenson/gists{/gist_id}","starred_url":"https://api.github.com/users/ConorStevenson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ConorStevenson/subscriptions","organizations_url":"https://api.github.com/users/ConorStevenson/orgs","repos_url":"https://api.github.com/users/ConorStevenson/repos","events_url":"https://api.github.com/users/ConorStevenson/events{/privacy}","received_events_url":"https://api.github.com/users/ConorStevenson/received_events","type":"User","site_admin":false},"body":"It took me a while to figure out what `openapi` does here. Maybe rename or write a short docstring?","created_at":"2018-07-02T09:26:06Z","updated_at":"2018-07-02T09:37:59Z","html_url":"https://github.com/lendingblock/aio-openapi/pull/30#discussion_r199435032","pull_request_url":"https://api.github.com/repos/lendingblock/aio-openapi/pulls/30","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/lendingblock/aio-openapi/pulls/comments/199435032"},"html":{"href":"https://github.com/lendingblock/aio-openapi/pull/30#discussion_r199435032"},"pull_request":{"href":"https://api.github.com/repos/lendingblock/aio-openapi/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/lendingblock/aio-openapi/pulls/30","id":198531590,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4NTMxNTkw","html_url":"https://github.com/lendingblock/aio-openapi/pull/30","diff_url":"https://github.com/lendingblock/aio-openapi/pull/30.diff","patch_url":"https://github.com/lendingblock/aio-openapi/pull/30.patch","issue_url":"https://api.github.com/repos/lendingblock/aio-openapi/issues/30","number":30,"state":"open","locked":false,"title":"spec improvements","user":{"login":"lsbardel","id":144320,"node_id":"MDQ6VXNlcjE0NDMyMA==","avatar_url":"https://avatars1.githubusercontent.com/u/144320?v=4","gravatar_id":"","url":"https://api.github.com/users/lsbardel","html_url":"https://github.com/lsbardel","followers_url":"https://api.github.com/users/lsbardel/followers","following_url":"https://api.github.com/users/lsbardel/following{/other_user}","gists_url":"https://api.github.com/users/lsbardel/gists{/gist_id}","starred_url":"https://api.github.com/users/lsbardel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsbardel/subscriptions","organizations_url":"https://api.github.com/users/lsbardel/orgs","repos_url":"https://api.github.com/users/lsbardel/repos","events_url":"https://api.github.com/users/lsbardel/events{/privacy}","received_events_url":"https://api.github.com/users/lsbardel/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-07-01T16:18:46Z","updated_at":"2018-07-02T09:37:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2145e0e70cbfcc10c6a0e42c0ee2cfdf1182ddfa","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/lendingblock/aio-openapi/pulls/30/commits","review_comments_url":"https://api.github.com/repos/lendingblock/aio-openapi/pulls/30/comments","review_comment_url":"https://api.github.com/repos/lendingblock/aio-openapi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lendingblock/aio-openapi/issues/30/comments","statuses_url":"https://api.github.com/repos/lendingblock/aio-openapi/statuses/65f62f6be900552bd00de05503c0108b2e44964c","head":{"label":"lendingblock:spec","ref":"spec","sha":"65f62f6be900552bd00de05503c0108b2e44964c","user":{"login":"lendingblock","id":33968506,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzOTY4NTA2","avatar_url":"https://avatars3.githubusercontent.com/u/33968506?v=4","gravatar_id":"","url":"https://api.github.com/users/lendingblock","html_url":"https://github.com/lendingblock","followers_url":"https://api.github.com/users/lendingblock/followers","following_url":"https://api.github.com/users/lendingblock/following{/other_user}","gists_url":"https://api.github.com/users/lendingblock/gists{/gist_id}","starred_url":"https://api.github.com/users/lendingblock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lendingblock/subscriptions","organizations_url":"https://api.github.com/users/lendingblock/orgs","repos_url":"https://api.github.com/users/lendingblock/repos","events_url":"https://api.github.com/users/lendingblock/events{/privacy}","received_events_url":"https://api.github.com/users/lendingblock/received_events","type":"Organization","site_admin":false},"repo":{"id":133532636,"node_id":"MDEwOlJlcG9zaXRvcnkxMzM1MzI2MzY=","name":"aio-openapi","full_name":"lendingblock/aio-openapi","owner":{"login":"lendingblock","id":33968506,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzOTY4NTA2","avatar_url":"https://avatars3.githubusercontent.com/u/33968506?v=4","gravatar_id":"","url":"https://api.github.com/users/lendingblock","html_url":"https://github.com/lendingblock","followers_url":"https://api.github.com/users/lendingblock/followers","following_url":"https://api.github.com/users/lendingblock/following{/other_user}","gists_url":"https://api.github.com/users/lendingblock/gists{/gist_id}","starred_url":"https://api.github.com/users/lendingblock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lendingblock/subscriptions","organizations_url":"https://api.github.com/users/lendingblock/orgs","repos_url":"https://api.github.com/users/lendingblock/repos","events_url":"https://api.github.com/users/lendingblock/events{/privacy}","received_events_url":"https://api.github.com/users/lendingblock/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lendingblock/aio-openapi","description":"Open API utilities","fork":false,"url":"https://api.github.com/repos/lendingblock/aio-openapi","forks_url":"https://api.github.com/repos/lendingblock/aio-openapi/forks","keys_url":"https://api.github.com/repos/lendingblock/aio-openapi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lendingblock/aio-openapi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lendingblock/aio-openapi/teams","hooks_url":"https://api.github.com/repos/lendingblock/aio-openapi/hooks","issue_events_url":"https://api.github.com/repos/lendingblock/aio-openapi/issues/events{/number}","events_url":"https://api.github.com/repos/lendingblock/aio-openapi/events","assignees_url":"https://api.github.com/repos/lendingblock/aio-openapi/assignees{/user}","branches_url":"https://api.github.com/repos/lendingblock/aio-openapi/branches{/branch}","tags_url":"https://api.github.com/repos/lendingblock/aio-openapi/tags","blobs_url":"https://api.github.com/repos/lendingblock/aio-openapi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lendingblock/aio-openapi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lendingblock/aio-openapi/git/refs{/sha}","trees_url":"https://api.github.com/repos/lendingblock/aio-openapi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lendingblock/aio-openapi/statuses/{sha}","languages_url":"https://api.github.com/repos/lendingblock/aio-openapi/languages","stargazers_url":"https://api.github.com/repos/lendingblock/aio-openapi/stargazers","contributors_url":"https://api.github.com/repos/lendingblock/aio-openapi/contributors","subscribers_url":"https://api.github.com/repos/lendingblock/aio-openapi/subscribers","subscription_url":"https://api.github.com/repos/lendingblock/aio-openapi/subscription","commits_url":"https://api.github.com/repos/lendingblock/aio-openapi/commits{/sha}","git_commits_url":"https://api.github.com/repos/lendingblock/aio-openapi/git/commits{/sha}","comments_url":"https://api.github.com/repos/lendingblock/aio-openapi/comments{/number}","issue_comment_url":"https://api.github.com/repos/lendingblock/aio-openapi/issues/comments{/number}","contents_url":"https://api.github.com/repos/lendingblock/aio-openapi/contents/{+path}","compare_url":"https://api.github.com/repos/lendingblock/aio-openapi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lendingblock/aio-openapi/merges","archive_url":"https://api.github.com/repos/lendingblock/aio-openapi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lendingblock/aio-openapi/downloads","issues_url":"https://api.github.com/repos/lendingblock/aio-openapi/issues{/number}","pulls_url":"https://api.github.com/repos/lendingblock/aio-openapi/pulls{/number}","milestones_url":"https://api.github.com/repos/lendingblock/aio-openapi/milestones{/number}","notifications_url":"https://api.github.com/repos/lendingblock/aio-openapi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lendingblock/aio-openapi/labels{/name}","releases_url":"https://api.github.com/repos/lendingblock/aio-openapi/releases{/id}","deployments_url":"https://api.github.com/repos/lendingblock/aio-openapi/deployments","created_at":"2018-05-15T15:00:21Z","updated_at":"2018-07-01T10:24:27Z","pushed_at":"2018-07-02T08:42:06Z","git_url":"git://github.com/lendingblock/aio-openapi.git","ssh_url":"git@github.com:lendingblock/aio-openapi.git","clone_url":"https://github.com/lendingblock/aio-openapi.git","svn_url":"https://github.com/lendingblock/aio-openapi","homepage":null,"size":104,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":2,"watchers":3,"default_branch":"master"}},"base":{"label":"lendingblock:master","ref":"master","sha":"b3cd44aeb471ff0eea318327de04e96d5ac3973f","user":{"login":"lendingblock","id":33968506,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzOTY4NTA2","avatar_url":"https://avatars3.githubusercontent.com/u/33968506?v=4","gravatar_id":"","url":"https://api.github.com/users/lendingblock","html_url":"https://github.com/lendingblock","followers_url":"https://api.github.com/users/lendingblock/followers","following_url":"https://api.github.com/users/lendingblock/following{/other_user}","gists_url":"https://api.github.com/users/lendingblock/gists{/gist_id}","starred_url":"https://api.github.com/users/lendingblock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lendingblock/subscriptions","organizations_url":"https://api.github.com/users/lendingblock/orgs","repos_url":"https://api.github.com/users/lendingblock/repos","events_url":"https://api.github.com/users/lendingblock/events{/privacy}","received_events_url":"https://api.github.com/users/lendingblock/received_events","type":"Organization","site_admin":false},"repo":{"id":133532636,"node_id":"MDEwOlJlcG9zaXRvcnkxMzM1MzI2MzY=","name":"aio-openapi","full_name":"lendingblock/aio-openapi","owner":{"login":"lendingblock","id":33968506,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzOTY4NTA2","avatar_url":"https://avatars3.githubusercontent.com/u/33968506?v=4","gravatar_id":"","url":"https://api.github.com/users/lendingblock","html_url":"https://github.com/lendingblock","followers_url":"https://api.github.com/users/lendingblock/followers","following_url":"https://api.github.com/users/lendingblock/following{/other_user}","gists_url":"https://api.github.com/users/lendingblock/gists{/gist_id}","starred_url":"https://api.github.com/users/lendingblock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lendingblock/subscriptions","organizations_url":"https://api.github.com/users/lendingblock/orgs","repos_url":"https://api.github.com/users/lendingblock/repos","events_url":"https://api.github.com/users/lendingblock/events{/privacy}","received_events_url":"https://api.github.com/users/lendingblock/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lendingblock/aio-openapi","description":"Open API utilities","fork":false,"url":"https://api.github.com/repos/lendingblock/aio-openapi","forks_url":"https://api.github.com/repos/lendingblock/aio-openapi/forks","keys_url":"https://api.github.com/repos/lendingblock/aio-openapi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lendingblock/aio-openapi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lendingblock/aio-openapi/teams","hooks_url":"https://api.github.com/repos/lendingblock/aio-openapi/hooks","issue_events_url":"https://api.github.com/repos/lendingblock/aio-openapi/issues/events{/number}","events_url":"https://api.github.com/repos/lendingblock/aio-openapi/events","assignees_url":"https://api.github.com/repos/lendingblock/aio-openapi/assignees{/user}","branches_url":"https://api.github.com/repos/lendingblock/aio-openapi/branches{/branch}","tags_url":"https://api.github.com/repos/lendingblock/aio-openapi/tags","blobs_url":"https://api.github.com/repos/lendingblock/aio-openapi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lendingblock/aio-openapi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lendingblock/aio-openapi/git/refs{/sha}","trees_url":"https://api.github.com/repos/lendingblock/aio-openapi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lendingblock/aio-openapi/statuses/{sha}","languages_url":"https://api.github.com/repos/lendingblock/aio-openapi/languages","stargazers_url":"https://api.github.com/repos/lendingblock/aio-openapi/stargazers","contributors_url":"https://api.github.com/repos/lendingblock/aio-openapi/contributors","subscribers_url":"https://api.github.com/repos/lendingblock/aio-openapi/subscribers","subscription_url":"https://api.github.com/repos/lendingblock/aio-openapi/subscription","commits_url":"https://api.github.com/repos/lendingblock/aio-openapi/commits{/sha}","git_commits_url":"https://api.github.com/repos/lendingblock/aio-openapi/git/commits{/sha}","comments_url":"https://api.github.com/repos/lendingblock/aio-openapi/comments{/number}","issue_comment_url":"https://api.github.com/repos/lendingblock/aio-openapi/issues/comments{/number}","contents_url":"https://api.github.com/repos/lendingblock/aio-openapi/contents/{+path}","compare_url":"https://api.github.com/repos/lendingblock/aio-openapi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lendingblock/aio-openapi/merges","archive_url":"https://api.github.com/repos/lendingblock/aio-openapi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lendingblock/aio-openapi/downloads","issues_url":"https://api.github.com/repos/lendingblock/aio-openapi/issues{/number}","pulls_url":"https://api.github.com/repos/lendingblock/aio-openapi/pulls{/number}","milestones_url":"https://api.github.com/repos/lendingblock/aio-openapi/milestones{/number}","notifications_url":"https://api.github.com/repos/lendingblock/aio-openapi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lendingblock/aio-openapi/labels{/name}","releases_url":"https://api.github.com/repos/lendingblock/aio-openapi/releases{/id}","deployments_url":"https://api.github.com/repos/lendingblock/aio-openapi/deployments","created_at":"2018-05-15T15:00:21Z","updated_at":"2018-07-01T10:24:27Z","pushed_at":"2018-07-02T08:42:06Z","git_url":"git://github.com/lendingblock/aio-openapi.git","ssh_url":"git@github.com:lendingblock/aio-openapi.git","clone_url":"https://github.com/lendingblock/aio-openapi.git","svn_url":"https://github.com/lendingblock/aio-openapi","homepage":null,"size":104,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":0,"open_issues":2,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lendingblock/aio-openapi/pulls/30"},"html":{"href":"https://github.com/lendingblock/aio-openapi/pull/30"},"issue":{"href":"https://api.github.com/repos/lendingblock/aio-openapi/issues/30"},"comments":{"href":"https://api.github.com/repos/lendingblock/aio-openapi/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/lendingblock/aio-openapi/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/lendingblock/aio-openapi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lendingblock/aio-openapi/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/lendingblock/aio-openapi/statuses/65f62f6be900552bd00de05503c0108b2e44964c"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"ConorStevenson"}}