Skip to content

Commit 268b3fc

Browse files
fix: Repeated Company schema in OpenAPI (#467)
Co-authored-by: Matias Perrone <github@matiasperrone.com>
1 parent 60cd342 commit 268b3fc

File tree

2 files changed

+49
-84
lines changed

2 files changed

+49
-84
lines changed

app/Swagger/CompaniesSchemas.php

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,6 @@
66

77
// Companies Schemas
88

9-
#[OA\Schema(
10-
schema: "Company",
11-
description: "Company",
12-
properties: [
13-
new OA\Property(property: "id", type: "integer", example: 1),
14-
new OA\Property(property: "created", type: "integer", format: "int64", description: "Creation timestamp (epoch)", example: 1234567890),
15-
new OA\Property(property: "last_edited", type: "integer", format: "int64", description: "Last edit timestamp (epoch)", example: 1234567890),
16-
new OA\Property(property: "name", type: "string", example: "Acme Corporation"),
17-
new OA\Property(property: "url", type: "string", format: "uri", nullable: true, example: "https://www.acme.com"),
18-
new OA\Property(property: "url_segment", type: "string", nullable: true, example: "acme-corporation"),
19-
new OA\Property(property: "display_on_site", type: "boolean", example: true),
20-
new OA\Property(property: "featured", type: "boolean", example: false),
21-
new OA\Property(property: "city", type: "string", nullable: true, example: "San Francisco"),
22-
new OA\Property(property: "state", type: "string", nullable: true, example: "California"),
23-
new OA\Property(property: "country", type: "string", nullable: true, example: "United States"),
24-
new OA\Property(property: "description", type: "string", nullable: true, example: "Leading technology company"),
25-
new OA\Property(property: "industry", type: "string", nullable: true, example: "Technology"),
26-
new OA\Property(property: "products", type: "string", nullable: true, example: "Cloud services, Software"),
27-
new OA\Property(property: "contributions", type: "string", nullable: true, example: "OpenStack contributions"),
28-
new OA\Property(property: "contact_email", type: "string", format: "email", nullable: true, example: "contact@acme.com"),
29-
new OA\Property(property: "member_level", type: "string", nullable: true, example: "Platinum"),
30-
new OA\Property(property: "admin_email", type: "string", format: "email", nullable: true, example: "admin@acme.com"),
31-
new OA\Property(property: "color", type: "string", nullable: true, example: "#FF5733"),
32-
new OA\Property(property: "logo", type: "string", format: "uri", nullable: true, example: "https://cdn.example.com/logo.png"),
33-
new OA\Property(property: "big_logo", type: "string", format: "uri", nullable: true, example: "https://cdn.example.com/big_logo.png"),
34-
new OA\Property(property: "overview", type: "string", nullable: true, example: "Company overview"),
35-
new OA\Property(property: "commitment", type: "string", nullable: true, example: "Commitment to open source"),
36-
new OA\Property(property: "commitment_author", type: "string", nullable: true, example: "John Doe, CEO"),
37-
new OA\Property(
38-
property: "sponsorships",
39-
type: "array",
40-
items: new OA\Items(oneOf: [
41-
new OA\Schema(type: "integer"),
42-
new OA\Schema(ref: "#/components/schemas/SummitSponsorship"),
43-
]),
44-
description: "Array of sponsorship IDs (only when relations=sponsorships)",
45-
),
46-
new OA\Property(
47-
property: "project_sponsorships",
48-
type: "array",
49-
items: new OA\Items(oneOf: [
50-
new OA\Schema(type: "integer"),
51-
new OA\Schema(ref: "#/components/schemas/ProjectSponsorshipType"),
52-
]),
53-
description: "Array of project sponsorship IDs (only when relations=project_sponsorships)",
54-
),
55-
],
56-
type: "object"
57-
)]
58-
class CompanySchema
59-
{
60-
}
61-
629
#[OA\Schema(
6310
schema: "PaginatedCompaniesResponse",
6411
description: "Paginated response for Companies",
@@ -136,4 +83,4 @@ class CompanyCreateRequestSchema
13683
)]
13784
class CompanyUpdateRequestSchema
13885
{
139-
}
86+
}

app/Swagger/Models/CompanySchema.php

Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,56 @@
55
use OpenApi\Attributes as OA;
66

77

8+
89
#[OA\Schema(
9-
schema: 'Company',
10-
type: 'object',
10+
schema: "Company",
11+
description: "Company",
1112
properties: [
12-
new OA\Property(property: 'id', type: 'integer', example: 1),
13-
new OA\Property(property: 'created', type: 'integer', example: 1),
14-
new OA\Property(property: 'last_edited', type: 'integer', example: 1),
15-
new OA\Property(property: 'name', type: 'string'),
16-
new OA\Property(property: 'url', type: 'string'),
17-
new OA\Property(property: 'url_segment', type: 'string'),
18-
new OA\Property(property: 'city', type: 'string'),
19-
new OA\Property(property: 'state', type: 'string'),
20-
new OA\Property(property: 'country', type: 'string'),
21-
new OA\Property(property: 'description', type: 'string'),
22-
new OA\Property(property: 'industry', type: 'string'),
23-
new OA\Property(property: 'contributions', type: 'string'),
24-
new OA\Property(property: 'member_level', type: 'string'),
25-
new OA\Property(property: 'overview', type: 'string'),
26-
new OA\Property(property: 'products', type: 'string'),
27-
new OA\Property(property: 'commitment', type: 'string'),
28-
new OA\Property(property: 'commitment_author', type: 'string'),
29-
new OA\Property(property: 'logo', type: 'string'),
30-
new OA\Property(property: 'big_logo', type: 'string'),
31-
new OA\Property(property: 'color', type: 'string'),
32-
new OA\Property(property: 'display_on_site', type: 'boolean'),
33-
new OA\Property(property: 'featured', type: 'boolean'),
34-
new OA\Property(property: 'contact_email', type: 'string'),
35-
new OA\Property(property: 'admin_email', type: 'string'),
36-
new OA\Property(property: 'sponsorships', type: 'array', items: new OA\Items(oneOf: [new OA\Schema(type: 'integer'), new OA\Schema(ref: '#/components/schemas/SummitSponsorship'),]), description: "SummitSponsorship, IDs when used as relationship, object when included in expand"),
37-
new OA\Property(property: 'project_sponsorships', type: 'array', items: new OA\Items(oneOf: [new OA\Schema(type: 'integer'), new OA\Schema(ref: '#/components/schemas/ProjectSponsorshipType'),]), description: "ProjectSponsorshipType supported by the distribution, IDs when used as relationship, object when included in expand"),
38-
])
39-
]
13+
new OA\Property(property: "id", type: "integer", example: 1),
14+
new OA\Property(property: "created", type: "integer", format: "int64", description: "Creation timestamp (epoch)", example: 1234567890),
15+
new OA\Property(property: "last_edited", type: "integer", format: "int64", description: "Last edit timestamp (epoch)", example: 1234567890),
16+
new OA\Property(property: "name", type: "string", example: "Acme Corporation"),
17+
new OA\Property(property: "url", type: "string", format: "uri", example: "https://www.acme.com"),
18+
new OA\Property(property: "url_segment", type: "string", example: "acme-corporation"),
19+
new OA\Property(property: "city", type: "string", example: "San Francisco"),
20+
new OA\Property(property: "state", type: "string", example: "California"),
21+
new OA\Property(property: "country", type: "string", example: "United States"),
22+
new OA\Property(property: "description", type: "string", example: "Leading technology company"),
23+
new OA\Property(property: "industry", type: "string", example: "Technology"),
24+
new OA\Property(property: "contributions", type: "string", example: "OpenStack contributions"),
25+
new OA\Property(property: "member_level", type: "string", example: "Platinum"),
26+
new OA\Property(property: "overview", type: "string", example: "Company overview"),
27+
new OA\Property(property: "products", type: "string", example: "Cloud services, Software"),
28+
new OA\Property(property: "commitment", type: "string", example: "Commitment to open source"),
29+
new OA\Property(property: "commitment_author", type: "string", example: "John Doe, CEO"),
30+
new OA\Property(property: "logo", type: "string", format: "uri", example: "https://cdn.example.com/logo.png"),
31+
new OA\Property(property: "big_logo", type: "string", format: "uri", example: "https://cdn.example.com/big_logo.png"),
32+
new OA\Property(property: "color", type: "string", example: "#FF5733"),
33+
new OA\Property(property: "display_on_site", type: "boolean", example: true),
34+
new OA\Property(property: "featured", type: "boolean", example: false),
35+
new OA\Property(property: "contact_email", type: "string", format: "email", example: "contact@acme.com"),
36+
new OA\Property(property: "admin_email", type: "string", format: "email", example: "admin@acme.com"),
37+
new OA\Property(
38+
property: "sponsorships",
39+
type: "array",
40+
items: new OA\Items(oneOf: [
41+
new OA\Schema(type: "integer"),
42+
new OA\Schema(ref: "#/components/schemas/SummitSponsorship"),
43+
]),
44+
description: "Array of sponsorship IDs (only when relations=sponsorships)",
45+
),
46+
new OA\Property(
47+
property: "project_sponsorships",
48+
type: "array",
49+
items: new OA\Items(oneOf: [
50+
new OA\Schema(type: "integer"),
51+
new OA\Schema(ref: "#/components/schemas/ProjectSponsorshipType"),
52+
]),
53+
description: "Array of project sponsorship IDs (only when relations=project_sponsorships)",
54+
),
55+
],
56+
type: "object"
57+
)]
4058
class CompanySchema
4159
{
4260
}

0 commit comments

Comments
 (0)