/
RepositoriesController.php
113 lines (106 loc) · 4.71 KB
/
RepositoriesController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
namespace OpenApi\Examples\UsingLinksPhp81;
use OpenApi\Attributes as OAT;
class RepositoriesController
{
#[OAT\Get(
path: '/2.0/repositories/{username}',
operationId: 'getRepositoriesByOwner',
parameters: [
new OAT\Parameter(name: 'username', in: 'path', required: true, schema: new OAT\Schema(type: 'string')),
],
responses: [
new OAT\Response(
response: 200,
description: 'Repositories owned by the supplied user',
content: new OAT\JsonContent(
type: 'array',
items: new OAT\Items(ref: '#/components/schemas/repository')
),
links: [
new OAT\Link(link: 'userRepository', ref: '#/components/links/UserRepository'),
]
),
]
)
]
#[OAT\Link(link: 'UserRepositories', operationId: 'getRepositoriesByOwner', parameters: ['username' => '$response.body#/username'])]
public function getRepositoriesByOwner($username)
{
}
#[OAT\Get(
path: '/2.0/repositories/{username}/{slug}',
operationId: 'getRepository',
parameters: [
new OAT\Parameter(name: 'username', in: 'path', required: true, schema: new OAT\Schema(type: 'string')),
new OAT\Parameter(name: 'slug', in: 'path', required: true, schema: new OAT\Schema(type: 'string')),
],
responses: [
new OAT\Response(
response: 200,
description: 'The repository',
content: new OAT\JsonContent(ref: '#/components/schemas/repository'),
links: [
new OAT\Link(link: 'repositoryPullRequests', ref: '#/components/links/RepositoryPullRequests'),
]
),
]
)
]
#[OAT\Link(link: 'UserRepository', operationId: 'getRepository', parameters: ['username' => '$response.body#/owner/username', 'slug' => '$response.body#/slug'])]
public function getRepository()
{
}
#[OAT\Get(
path: '/2.0/repositories/{username}/{slug}/{state}/pullrequests',
operationId: 'getPullRequestsByRepository',
responses: [
new OAT\Response(response: 200, description: 'An array of pull request objects', content: new OAT\JsonContent(type: 'array', items: new OAT\Items(ref: '#/components/schemas/pullrequest'))),
]
)
]
#[OAT\Link(link: 'RepositoryPullRequests', operationId: 'getPullRequestsByRepository', parameters: ['username' => '$response.body#/owner/username', 'slug' => '$response.body#/slug'])]
public function getPullRequestsByRepository(
#[OAT\PathParameter()]
string $username,
#[OAT\PathParameter()]
string $slug,
#[OAT\PathParameter()]
State $state,
#[OAT\QueryParameter()]
?string $label
) {
}
#[OAT\Get(
path: '/2.0/repositories/{username}/{slug}/pullrequests/{pid}',
operationId: 'getPullRequestsById',
parameters: [
new OAT\Parameter(name: 'username', in: 'path', required: true, schema: new OAT\Schema(type: 'string')),
new OAT\Parameter(name: 'slug', in: 'path', required: true, schema: new OAT\Schema(type: 'string')), new OAT\Parameter(name: 'pid', in: 'path', required: true, schema: new OAT\Schema(type: 'string')),
],
responses: [
new OAT\Response(response: 200, description: 'A pull request object', content: new OAT\JsonContent(ref: '#/components/schemas/pullrequest'), links: [new OAT\Link(link: 'pullRequestMerge', ref: '#/components/links/PullRequestMerge')]),
]
)
]
public function getPullRequestsById()
{
}
#[OAT\Post(
path: '/2.0/repositories/{username}/{slug}/pullrequests/{pid}/merge',
operationId: 'mergePullRequest',
parameters: [
new OAT\Parameter(name: 'username', in: 'path', required: true, schema: new OAT\Schema(type: 'string')),
new OAT\Parameter(name: 'slug', in: 'path', required: true, schema: new OAT\Schema(type: 'string')),
new OAT\Parameter(name: 'pid', in: 'path', required: true, schema: new OAT\Schema(type: 'string')),
],
responses: [
new OAT\Response(response: 204, description: 'The PR was successfully merged'),
]
)
]
#[OAT\Link(link: 'PullRequestMerge', operationId: 'mergePullRequest', parameters: ['username' => '$response.body#/author/username', 'slug' => '$response.body#/repository/slug', 'pid' => '$response.body#/id'])]
public function mergePullRequest(#[OAT\HeaderParameter(name: 'X-NONCE-ID')] string $nonceId, #[OAT\CookieParameter(name: 'User-Bind-Session')] ?string $bindCookie)
{
}
}