Skip to content

Commit ec1d230

Browse files
authored
fix: issues schema (#18)
1 parent 7617b9a commit ec1d230

File tree

1 file changed

+60
-141
lines changed

1 file changed

+60
-141
lines changed

src/schemas/issues.schema.js

Lines changed: 60 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -8,132 +8,79 @@ export const githubUserModel = S.object()
88
.prop('login', S.string().examples(['octocat']))
99
.prop('id', S.integer().examples([1]))
1010
.prop('node_id', S.string().examples(['MDQ6VXNlcjE=']))
11-
.prop('avatar_url', S.string().format('uri').examples(['https://github.com/images/error/octocat_happy.gif']))
12-
.prop('gravatar_id', S.anyOf([S.null(), S.string()]).examples(['41d064eb2195891e12d0413f63227ea7']))
13-
.prop('url', S.string().format('uri').examples(['https://api.github.com/users/octocat']))
14-
.prop('html_url', S.string().format('uri').examples(['https://github.com/octocat']))
15-
.prop('followers_url', S.string().format('uri').examples(['https://api.github.com/users/octocat/followers']))
16-
.prop('following_url', S.string().examples(['https://api.github.com/users/octocat/following{/other_user}']))
17-
.prop('gists_url', S.string().examples(['https://api.github.com/users/octocat/gists{/gist_id}']))
18-
.prop('starred_url', S.string().examples(['https://api.github.com/users/octocat/starred{/owner}{/repo}']))
19-
.prop('subscriptions_url', S.string().format('uri').examples(['https://api.github.com/users/octocat/subscriptions']))
20-
.prop('organizations_url', S.string().format('uri').examples(['https://api.github.com/users/octocat/orgs']))
21-
.prop('repos_url', S.string().format('uri').examples(['https://api.github.com/users/octocat/repos']))
22-
.prop('events_url', S.string().examples(['https://api.github.com/users/octocat/events{/privacy}']))
23-
.prop('received_events_url', S.string().format('uri').examples(['https://api.github.com/users/octocat/received_events']))
11+
.prop('avatar_url', S.string().format('uri'))
12+
.prop('gravatar_id', S.anyOf([S.null(), S.string()]))
13+
.prop('url', S.string().format('uri'))
14+
.prop('html_url', S.string().format('uri'))
15+
.prop('followers_url', S.string().format('uri'))
16+
.prop('following_url', S.string())
17+
.prop('gists_url', S.string())
18+
.prop('starred_url', S.string())
19+
.prop('subscriptions_url', S.string().format('uri'))
20+
.prop('organizations_url', S.string().format('uri'))
21+
.prop('repos_url', S.string().format('uri'))
22+
.prop('events_url', S.string())
23+
.prop('received_events_url', S.string().format('uri'))
2424
.prop('type', S.string().examples(['User']))
2525
.prop('site_admin', S.boolean())
26-
.prop('starred_at', S.string().examples(['"2020-07-09T00:17:55Z"']))
27-
.prop('user_view_type', S.string().examples(['public']))
28-
.required([
29-
'avatar_url',
30-
'events_url',
31-
'followers_url',
32-
'following_url',
33-
'gists_url',
34-
'gravatar_id',
35-
'html_url',
36-
'id',
37-
'node_id',
38-
'login',
39-
'organizations_url',
40-
'received_events_url',
41-
'repos_url',
42-
'site_admin',
43-
'starred_url',
44-
'subscriptions_url',
45-
'type',
46-
'url',
47-
]);
26+
.prop('starred_at', S.anyOf([S.null(), S.string().format('date-time')]))
27+
.prop('user_view_type', S.anyOf([S.null(), S.string()]))
28+
.additionalProperties(true);
4829

4930
export const githubMilestoneModel = S.object()
5031
.id('GithubMilestoneModel')
5132
.description('A collection of related issues and pull requests.')
52-
.prop('url', S.string().format('uri').examples(['https://api.github.com/repos/octocat/Hello-World/milestones/1']))
53-
.prop('html_url', S.string().format('uri').examples(['https://github.com/octocat/Hello-World/milestones/v1.0']))
54-
.prop('labels_url', S.string().format('uri').examples(['https://api.github.com/repos/octocat/Hello-World/milestones/1/labels']))
55-
.prop('id', S.integer().examples([1002604]))
56-
.prop('node_id', S.string().examples(['MDk6TWlsZXN0b25lMTAwMjYwNA==']))
57-
.prop('number', S.integer().description('The number of the milestone.').examples([42]))
58-
.prop('state', S.string().description('The state of the milestone.').enum(['open', 'closed']).default('open').examples(['open']))
59-
.prop('title', S.string().description('The title of the milestone.').examples(['v1.0']))
60-
.prop('description', S.anyOf([S.null(), S.string()]).examples(['Tracking milestone for version 1.0']))
33+
.prop('url', S.string().format('uri'))
34+
.prop('html_url', S.string().format('uri'))
35+
.prop('labels_url', S.string().format('uri'))
36+
.prop('id', S.integer())
37+
.prop('node_id', S.string())
38+
.prop('number', S.integer().description('The number of the milestone.'))
39+
.prop('state', S.string().enum(['open', 'closed']).default('open'))
40+
.prop('title', S.string())
41+
.prop('description', S.anyOf([S.null(), S.string()]))
6142
.prop('creator', S.anyOf([S.null(), S.ref('GithubUserModel')]))
62-
.prop('open_issues', S.integer().examples([4]))
63-
.prop('closed_issues', S.integer().examples([8]))
64-
.prop('created_at', S.string().format('date-time').examples(['2011-04-10T20:09:31Z']))
65-
.prop('updated_at', S.string().format('date-time').examples(['2014-03-03T18:58:10Z']))
66-
.prop('closed_at', S.anyOf([S.null(), S.string().format('date-time')]).examples(['2013-02-12T13:22:01Z']))
67-
.prop('due_on', S.anyOf([S.null(), S.string().format('date-time')]).examples(['2012-10-09T23:39:01Z']))
68-
.required([
69-
'closed_issues',
70-
'creator',
71-
'description',
72-
'due_on',
73-
'closed_at',
74-
'id',
75-
'node_id',
76-
'labels_url',
77-
'html_url',
78-
'number',
79-
'open_issues',
80-
'state',
81-
'title',
82-
'url',
83-
'created_at',
84-
'updated_at',
85-
]);
43+
.prop('open_issues', S.integer())
44+
.prop('closed_issues', S.integer())
45+
.prop('created_at', S.string().format('date-time'))
46+
.prop('updated_at', S.string().format('date-time'))
47+
.prop('closed_at', S.anyOf([S.null(), S.string().format('date-time')]))
48+
.prop('due_on', S.anyOf([S.null(), S.string().format('date-time')]))
49+
.additionalProperties(true);
8650

8751
export const githubIssueModel = S.object()
8852
.id('GithubIssueModel')
89-
.description('Issues are a great way to keep track of tasks, enhancements, and bugs for your projects.')
53+
.description('A GitHub issue, which may represent a task, enhancement, bug, or pull request.')
9054
.prop('id', S.integer())
9155
.prop('node_id', S.string())
92-
.prop('url', S.string().format('uri').description('URL for the issue').examples(['https://api.github.com/repositories/42/issues/1']))
56+
.prop('url', S.string().format('uri'))
9357
.prop('repository_url', S.string().format('uri'))
9458
.prop('labels_url', S.string())
9559
.prop('comments_url', S.string().format('uri'))
9660
.prop('events_url', S.string().format('uri'))
9761
.prop('html_url', S.string().format('uri'))
98-
.prop('number', S.integer().description('Number uniquely identifying the issue within its repository').examples([42]))
99-
.prop('state', S.string().description("State of the issue; either 'open' or 'closed'").examples(['open']))
100-
.prop(
101-
'state_reason',
102-
S.anyOf([S.null(), S.string()])
103-
.enum(['completed', 'reopened', 'not_planned', null])
104-
.description('The reason for the current state')
105-
.examples(['not_planned']),
106-
)
107-
.prop('title', S.string().description('Title of the issue').examples(['Widget creation fails in Safari on OS X 10.8']))
108-
.prop(
109-
'body',
110-
S.anyOf([S.null(), S.string()])
111-
.description('Contents of the issue')
112-
.examples([
113-
'It looks like the new widget form is broken on Safari. When I try and create the widget, Safari crashes. This is reproducible on 10.8, but not 10.9. Maybe a browser bug?',
114-
]),
115-
)
62+
.prop('number', S.integer())
63+
.prop('state', S.string().enum(['open', 'closed']))
64+
.prop('state_reason', S.anyOf([S.null(), S.string().enum(['completed', 'reopened', 'not_planned'])]))
65+
.prop('title', S.string())
66+
.prop('body', S.anyOf([S.null(), S.string()]))
11667
.prop('user', S.anyOf([S.null(), S.ref('GithubUserModel')]))
11768
.prop(
11869
'labels',
119-
S.array()
120-
.items(
121-
S.anyOf([
122-
S.string(),
123-
S.object()
124-
.prop('id', S.integer())
125-
.prop('node_id', S.string())
126-
.prop('url', S.string().format('uri'))
127-
.prop('name', S.string())
128-
.prop('description', S.anyOf([S.null(), S.string()]))
129-
.prop('color', S.anyOf([S.null(), S.string()]))
130-
.prop('default', S.boolean()),
131-
]),
132-
)
133-
.description(
134-
'Labels to associate with this issue; pass one or more label names to replace the set of labels on this issue; send an empty array to clear all labels from the issue; note that the labels are silently dropped for users without push access to the repository',
135-
)
136-
.examples(['bug', 'registration']),
70+
S.array().items(
71+
S.anyOf([
72+
S.string(),
73+
S.object()
74+
.prop('id', S.integer())
75+
.prop('node_id', S.string())
76+
.prop('url', S.string().format('uri'))
77+
.prop('name', S.string())
78+
.prop('description', S.anyOf([S.null(), S.string()]))
79+
.prop('color', S.anyOf([S.null(), S.string()]))
80+
.prop('default', S.boolean())
81+
.additionalProperties(true),
82+
]),
83+
),
13784
)
13885
.prop('assignee', S.anyOf([S.null(), S.ref('GithubUserModel')]))
13986
.prop('assignees', S.anyOf([S.null(), S.array().items(S.ref('GithubUserModel'))]))
@@ -145,46 +92,18 @@ export const githubIssueModel = S.object()
14592
'pull_request',
14693
S.object()
14794
.prop('merged_at', S.anyOf([S.null(), S.string().format('date-time')]))
148-
.prop('diff_url', S.anyOf([S.null(), S.string().format('url')]))
149-
.prop('html_url', S.anyOf([S.null(), S.string().format('url')]))
150-
.prop('patch_url', S.anyOf([S.null(), S.string().format('url')]))
151-
.prop('url', S.anyOf([S.null(), S.string().format('url')]))
152-
.required(['diff_url', 'html_url', 'patch_url', 'url']),
95+
.prop('diff_url', S.anyOf([S.null(), S.string().format('uri')]))
96+
.prop('html_url', S.anyOf([S.null(), S.string().format('uri')]))
97+
.prop('patch_url', S.anyOf([S.null(), S.string().format('uri')]))
98+
.prop('url', S.anyOf([S.null(), S.string().format('uri')]))
99+
.additionalProperties(true),
153100
)
154101
.prop('closed_at', S.anyOf([S.null(), S.string().format('date-time')]))
155102
.prop('created_at', S.string().format('date-time'))
156103
.prop('updated_at', S.string().format('date-time'))
157104
.prop('draft', S.boolean())
158105
.prop('closed_by', S.anyOf([S.null(), S.ref('GithubUserModel')]))
159-
.required([
160-
'id',
161-
'node_id',
162-
'url',
163-
'repository_url',
164-
'labels_url',
165-
'comments_url',
166-
'events_url',
167-
'html_url',
168-
'number',
169-
'state',
170-
'state_reason',
171-
'title',
172-
'body',
173-
'user',
174-
'labels',
175-
'assignee',
176-
'assignees',
177-
'milestone',
178-
'locked',
179-
'active_lock_reason',
180-
'comments',
181-
'pull_request',
182-
'closed_at',
183-
'created_at',
184-
'updated_at',
185-
'draft',
186-
'closed_by',
187-
]);
106+
.additionalProperties(true);
188107

189108
/**
190109
* Create issue endpoint schema
@@ -204,7 +123,7 @@ export const createIssueSchema = {
204123
.prop('expectedBehavior', S.string().minLength(5).maxLength(1000).description('What was expected to happen'))
205124
.prop('actualBehavior', S.string().minLength(5).maxLength(1000).description('What actually happened'))
206125
.prop('reproducibility', S.string().enum(['always', 'sometimes', 'rarely', 'once']).description('How often the issue can be reproduced'))
207-
.prop('attachments', S.array().items(S.object()))
126+
// .prop('attachments', S.array().items(S.object()))
208127
.required([
209128
'type',
210129
'title',

0 commit comments

Comments
 (0)