Skip to content

Commit 561cbd8

Browse files
feat: Extend Swagger Coverage for controller OAuth2ElectionsApiController
1 parent 09fc7e3 commit 561cbd8

File tree

8 files changed

+803
-37
lines changed

8 files changed

+803
-37
lines changed

app/Http/Controllers/Apis/Protected/Main/OAuth2ElectionsApiController.php

Lines changed: 401 additions & 30 deletions
Large diffs are not rendered by default.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
namespace App\Swagger\schemas;
3+
4+
use OpenApi\Attributes as OA;
5+
6+
#[OA\Schema(
7+
schema: "CandidatesList",
8+
type: "object",
9+
properties: [
10+
new OA\Property(
11+
property: "data",
12+
type: "array",
13+
items: new OA\Items(ref: "#/components/schemas/Candidate")
14+
),
15+
new OA\Property(
16+
property: "total",
17+
type: "integer",
18+
example: 5
19+
),
20+
new OA\Property(
21+
property: "per_page",
22+
type: "integer",
23+
example: 20
24+
),
25+
new OA\Property(
26+
property: "current_page",
27+
type: "integer",
28+
example: 1
29+
),
30+
]
31+
)]
32+
class CandidatesListSchema {}

app/Swagger/ElectionSchemas.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
namespace App\Swagger\schemas;
3+
4+
use OpenApi\Attributes as OA;
5+
6+
7+
8+
9+
#[OA\Schema(
10+
schema: 'CandidateProfileUpdateRequest',
11+
type: 'object',
12+
properties: [
13+
new OA\Property(property: 'bio', type: 'string', description: 'Candidate biography'),
14+
new OA\Property(property: 'relationship_to_openstack', type: 'string', description: 'Relationship to OpenStack'),
15+
new OA\Property(property: 'experience', type: 'string', description: 'Professional experience'),
16+
new OA\Property(property: 'boards_role', type: 'string', description: 'Board role experience'),
17+
new OA\Property(property: 'top_priority', type: 'string', description: 'Top priority if elected'),
18+
]
19+
)]
20+
class CandidateProfileUpdateRequestSchema {}
21+
22+
#[OA\Schema(
23+
schema: 'NominationRequest',
24+
type: 'object',
25+
properties: [
26+
new OA\Property(property: 'comment', type: 'string', nullable: true, description: 'Optional comment for the nomination'),
27+
]
28+
)]
29+
class NominationRequestSchema {}
30+
31+
32+
#[OA\Schema(
33+
schema: "ElectionsList",
34+
type: "object",
35+
properties: [
36+
new OA\Property(
37+
property: "data",
38+
type: "array",
39+
items: new OA\Items(ref: "#/components/schemas/Election")
40+
),
41+
new OA\Property(
42+
property: "total",
43+
type: "integer",
44+
example: 10
45+
),
46+
new OA\Property(
47+
property: "per_page",
48+
type: "integer",
49+
example: 20
50+
),
51+
new OA\Property(
52+
property: "current_page",
53+
type: "integer",
54+
example: 1
55+
),
56+
]
57+
)]
58+
class ElectionsListSchema {}

app/Swagger/ElectionsSchemas.php

Lines changed: 0 additions & 7 deletions
This file was deleted.

app/Swagger/NominationSchema.php

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
namespace App\Swagger\schemas;
3+
4+
use OpenApi\Attributes as OA;
5+
6+
7+
#[OA\Schema(
8+
schema: "Nomination",
9+
type: "object",
10+
required: ["id", "candidate_id", "nominator_id", "election_id"],
11+
properties: [
12+
new OA\Property(
13+
property: "id",
14+
type: "integer",
15+
format: "int64",
16+
description: "Nomination ID",
17+
example: 1
18+
),
19+
new OA\Property(
20+
property: "election_id",
21+
type: "integer",
22+
format: "int64",
23+
description: "Associated election ID",
24+
example: 1
25+
),
26+
new OA\Property(
27+
property: "candidate_id",
28+
type: "integer",
29+
format: "int64",
30+
description: "Nominated candidate ID",
31+
example: 123
32+
),
33+
new OA\Property(
34+
property: "nominator_id",
35+
type: "integer",
36+
format: "int64",
37+
description: "Member who made the nomination",
38+
example: 456
39+
),
40+
new OA\Property(
41+
property: "comment",
42+
type: "string",
43+
nullable: true,
44+
description: "Optional nomination comment",
45+
example: "Great candidate for the board"
46+
),
47+
new OA\Property(
48+
property: "created_at",
49+
type: "integer",
50+
format: "int64",
51+
description: "Creation timestamp (unix epoch)"
52+
),
53+
new OA\Property(
54+
property: "updated_at",
55+
type: "integer",
56+
format: "int64",
57+
description: "Last update timestamp (unix epoch)"
58+
),
59+
new OA\Property(
60+
property: "election",
61+
description: "Expanded election object (only with expand=election)",
62+
ref: "#/components/schemas/Election",
63+
nullable: true
64+
),
65+
new OA\Property(
66+
property: "candidate",
67+
description: "Expanded candidate object (only with expand=candidate)",
68+
ref: "#/components/schemas/Candidate",
69+
nullable: true
70+
),
71+
new OA\Property(
72+
property: "nominator",
73+
description: "Expanded nominator member object (only with expand=nominator)",
74+
ref: "#/components/schemas/Member",
75+
nullable: true
76+
),
77+
]
78+
)]
79+
class NominationSchema {}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
namespace App\Swagger\schemas;
3+
4+
use OpenApi\Attributes as OA;
5+
6+
#[OA\Schema(
7+
schema: "Candidate",
8+
type: "object",
9+
required: ["id", "member_id", "election_id"],
10+
properties: [
11+
new OA\Property(
12+
property: "id",
13+
type: "integer",
14+
format: "int64",
15+
description: "Candidate ID",
16+
example: 1
17+
),
18+
new OA\Property(
19+
property: "member_id",
20+
type: "integer",
21+
format: "int64",
22+
description: "Associated member ID",
23+
example: 123
24+
),
25+
new OA\Property(
26+
property: "election_id",
27+
type: "integer",
28+
format: "int64",
29+
description: "Associated election ID",
30+
example: 1
31+
),
32+
new OA\Property(
33+
property: "has_accepted_nomination",
34+
type: "boolean",
35+
description: "Whether candidate has accepted nomination",
36+
example: true
37+
),
38+
new OA\Property(
39+
property: "is_gold_member",
40+
type: "boolean",
41+
description: "Whether candidate is featured/gold",
42+
example: false
43+
),
44+
new OA\Property(
45+
property: "relationship_to_openstack",
46+
type: "string",
47+
nullable: true,
48+
description: "Relationship to OpenStack",
49+
example: "Core contributor"
50+
),
51+
new OA\Property(
52+
property: "experience",
53+
type: "string",
54+
nullable: true,
55+
description: "Professional experience",
56+
example: "10 years in open source"
57+
),
58+
new OA\Property(
59+
property: "boards_role",
60+
type: "string",
61+
nullable: true,
62+
description: "Board role experience",
63+
example: "Board member for 3 years"
64+
),
65+
new OA\Property(
66+
property: "bio",
67+
type: "string",
68+
nullable: true,
69+
description: "Candidate biography",
70+
example: "Passionate OpenStack contributor"
71+
),
72+
new OA\Property(
73+
property: "top_priority",
74+
type: "string",
75+
nullable: true,
76+
description: "Top priority if elected",
77+
example: "Improve community engagement"
78+
),
79+
new OA\Property(
80+
property: "created_at",
81+
type: "integer",
82+
format: "int64",
83+
description: "Creation timestamp (unix epoch)"
84+
),
85+
new OA\Property(
86+
property: "updated_at",
87+
type: "integer",
88+
format: "int64",
89+
description: "Last update timestamp (unix epoch)"
90+
),
91+
new OA\Property(
92+
property: "member",
93+
description: "Member details (only when expand=member)",
94+
ref: "#/components/schemas/Member",
95+
nullable: true
96+
),
97+
new OA\Property(
98+
property: "election",
99+
description: "Election details (only when expand=election)",
100+
ref: "#/components/schemas/Election",
101+
nullable: true
102+
),
103+
]
104+
)]
105+
class CandidateSchema {}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
namespace App\Swagger\schemas;
3+
4+
use OpenApi\Attributes as OA;
5+
6+
#[OA\Schema(
7+
schema: "Election",
8+
type: "object",
9+
required: ["id", "name"],
10+
properties: [
11+
new OA\Property(
12+
property: "id",
13+
type: "integer",
14+
format: "int64",
15+
example: 1
16+
),
17+
new OA\Property(
18+
property: "name",
19+
type: "string",
20+
example: "Board Election 2025"
21+
),
22+
new OA\Property(
23+
property: "status",
24+
type: "string",
25+
enum: ["open", "closed", "upcoming"],
26+
example: "open"
27+
),
28+
new OA\Property(
29+
property: "opens",
30+
type: "integer",
31+
format: "int64",
32+
description: "Unix timestamp when election opens",
33+
example: 1634567890
34+
),
35+
new OA\Property(
36+
property: "closes",
37+
type: "integer",
38+
format: "int64",
39+
description: "Unix timestamp when election closes",
40+
example: 1634654290
41+
),
42+
new OA\Property(
43+
property: "nomination_opens",
44+
type: "integer",
45+
format: "int64",
46+
description: "Unix timestamp when nominations open",
47+
example: 1634481490
48+
),
49+
new OA\Property(
50+
property: "nomination_closes",
51+
type: "integer",
52+
format: "int64",
53+
description: "Unix timestamp when nominations close",
54+
example: 1634567890
55+
),
56+
new OA\Property(
57+
property: "nomination_application_deadline",
58+
type: "integer",
59+
format: "int64",
60+
description: "Unix timestamp for nomination application deadline",
61+
example: 1634567890
62+
),
63+
new OA\Property(
64+
property: "candidate_application_form_relationship_to_openstack_label",
65+
type: "string",
66+
example: "Relationship to OpenStack"
67+
),
68+
new OA\Property(
69+
property: "candidate_application_form_experience_label",
70+
type: "string",
71+
example: "Experience in OpenStack"
72+
),
73+
new OA\Property(
74+
property: "candidate_application_form_boards_role_label",
75+
type: "string",
76+
example: "Board Role Experience"
77+
),
78+
new OA\Property(
79+
property: "candidate_application_form_top_priority_label",
80+
type: "string",
81+
example: "Top Priorities"
82+
),
83+
new OA\Property(
84+
property: "nominations_limit",
85+
type: "integer",
86+
example: 10
87+
),
88+
new OA\Property(
89+
property: "created_at",
90+
type: "integer",
91+
format: "int64",
92+
description: "Creation timestamp"
93+
),
94+
new OA\Property(
95+
property: "updated_at",
96+
type: "integer",
97+
format: "int64",
98+
description: "Last update timestamp"
99+
),
100+
]
101+
)]
102+
class ElectionSchema {}

0 commit comments

Comments
 (0)