Skip to content

Commit 9ca4763

Browse files
Merge branch 'feature/add-openapi-documentation-to-controller-marketplace---distributionsapicontroller' into feature/swagger-documentation
2 parents 8789348 + 1c30cea commit 9ca4763

22 files changed

+611
-5
lines changed

app/Http/Controllers/Apis/Marketplace/DistributionsApiController.php

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?php namespace App\Http\Controllers;
1+
<?php
2+
namespace App\Http\Controllers;
23
/**
34
* Copyright 2017 OpenStack Foundation
45
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,7 +13,9 @@
1213
* limitations under the License.
1314
**/
1415
use App\Models\Foundation\Marketplace\IDistributionRepository;
16+
use Illuminate\Http\Response;
1517
use models\oauth2\IResourceServerContext;
18+
use OpenApi\Attributes as OA;
1619

1720
/**
1821
* Class DistributionsApiController
@@ -30,6 +33,78 @@ public function __construct(IDistributionRepository $repository, IResourceServer
3033
parent::__construct($repository, $resource_server_context);
3134
}
3235

36+
#[OA\Get(
37+
path: "/api/public/v1/marketplace/distros",
38+
description: "Get all marketplace distributions (OpenStack implementations)",
39+
summary: 'Get all distributions',
40+
operationId: 'getAllDistributions',
41+
tags: ['Marketplace', 'Marketplace Distributions'],
42+
parameters: [
43+
new OA\Parameter(
44+
name: 'page',
45+
in: 'query',
46+
required: false,
47+
description: 'Page number for pagination',
48+
schema: new OA\Schema(type: 'integer', example: 1)
49+
),
50+
new OA\Parameter(
51+
name: 'per_page',
52+
in: 'query',
53+
required: false,
54+
description: 'Items per page',
55+
schema: new OA\Schema(type: 'integer', example: 10, maximum: 100)
56+
),
57+
new OA\Parameter(
58+
name: 'filter[]',
59+
in: 'query',
60+
required: false,
61+
description: 'Filter expressions in the format field<op>value. Available fields: name, company. Operators: =@, ==, @@.',
62+
style: 'form',
63+
explode: true,
64+
schema: new OA\Schema(
65+
type: 'array',
66+
items: new OA\Items(type: 'string', example: 'name@@ubuntu')
67+
)
68+
),
69+
new OA\Parameter(
70+
name: 'order',
71+
in: 'query',
72+
required: false,
73+
description: 'Order by field(s). Allowed fields: id, name, company',
74+
schema: new OA\Schema(type: 'string', example: 'name,-id'),
75+
),
76+
new OA\Parameter(
77+
name: 'expand',
78+
in: 'query',
79+
required: false,
80+
description: 'Comma-separated list of related resources to include. Available relations: company, type, capabilities, guests, hypervisors, supported_regions',
81+
schema: new OA\Schema(type: 'string', example: 'company,type')
82+
),
83+
new OA\Parameter(
84+
name: 'relations',
85+
in: 'query',
86+
required: false,
87+
description: 'Relations to load eagerly',
88+
schema: new OA\Schema(type: 'string', example: 'company,type')
89+
),
90+
new OA\Parameter(
91+
name: 'fields',
92+
in: 'query',
93+
required: false,
94+
description: 'Comma-separated list of fields to return',
95+
schema: new OA\Schema(type: 'string', example: 'id,name,company.name')
96+
),
97+
],
98+
responses: [
99+
new OA\Response(
100+
response: 200,
101+
description: 'Success - Returns paginated list of distributions',
102+
content: new OA\JsonContent(ref: "#/components/schemas/PaginatedMarketplaceDistributionResponseSchema")
103+
),
104+
new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"),
105+
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error")
106+
]
107+
)]
33108
public function getAll()
34109
{
35110
return parent::getAll();

app/Models/Foundation/Marketplace/CompanyService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function getCompany()
152152
}
153153

154154
/**
155-
* @return Company
155+
* @return MarketPlaceType
156156
*/
157157
public function getType()
158158
{
@@ -225,4 +225,4 @@ public function getResources()
225225
{
226226
return $this->resources->toArray();
227227
}
228-
}
228+
}

app/Swagger/MarketplaceSchemas.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
'type_id' => new OA\Property(property: 'type_id', type: 'integer', example: 1)
2020
]
2121
)]
22-
class ConsultantsResponseSchema {}
22+
class ConsultantsResponseSchema
23+
{
24+
}
2325

2426
#[OA\Schema(
2527
schema: 'PaginatedConsultantsResponse',
@@ -37,4 +39,29 @@ class ConsultantsResponseSchema {}
3739
)
3840
]
3941
)]
40-
class PaginatedConsultantsResponseSchema {}
42+
class PaginatedConsultantsResponseSchema
43+
{
44+
}
45+
46+
47+
48+
49+
#[OA\Schema(
50+
schema: 'PaginatedMarketplaceDistributionResponseSchema',
51+
allOf: [
52+
new OA\Schema(ref: '#/components/schemas/PaginateDataSchemaResponse'),
53+
new OA\Schema(
54+
type: 'object',
55+
properties: [
56+
new OA\Property(
57+
property: 'data',
58+
type: 'array',
59+
items: new OA\Items(ref: '#/components/schemas/Distribution')
60+
)
61+
]
62+
)
63+
]
64+
)]
65+
class PaginatedMarketplaceDistributionResponseSchema
66+
{
67+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace App\Swagger\schemas;
4+
5+
use OpenApi\Attributes as OA;
6+
7+
8+
#[OA\Schema(
9+
schema: 'Company',
10+
type: 'object',
11+
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: 'url'),
30+
new OA\Property(property: 'big_logo', type: 'url'),
31+
new OA\Property(property: 'color', type: 'color'),
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+
]
40+
class CompanySchema
41+
{
42+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace App\Swagger\schemas;
4+
5+
use OpenApi\Attributes as OA;
6+
7+
8+
#[OA\Schema(
9+
schema: 'Distribution',
10+
ref: '#/components/schemas/OpenStackImplementation',
11+
)]
12+
class DistributionSchema
13+
{
14+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace App\Swagger\schemas;
4+
5+
use OpenApi\Attributes as OA;
6+
7+
8+
#[OA\Schema(
9+
schema: 'GuestOSType',
10+
type: 'object',
11+
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: 'type', type: 'string', example: 'KVM'),
16+
])
17+
]
18+
class GuestOSTypeSchema
19+
{
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace App\Swagger\schemas;
4+
5+
use OpenApi\Attributes as OA;
6+
7+
8+
#[OA\Schema(
9+
schema: 'HyperVisorType',
10+
type: 'object',
11+
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: 'type', type: 'string', example: 'KVM'),
16+
])
17+
]
18+
class HyperVisorTypeSchema
19+
{
20+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace App\Swagger\schemas;
4+
5+
use OpenApi\Attributes as OA;
6+
7+
8+
#[OA\Schema(
9+
schema: 'OpenStackComponent',
10+
type: 'object',
11+
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: 'code_name', type: 'string'),
17+
])
18+
]
19+
class OpenStackComponentSchema
20+
{
21+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace App\Swagger\schemas;
4+
5+
use OpenApi\Attributes as OA;
6+
7+
8+
#[OA\Schema(
9+
schema: 'OpenStackImplementationApiCoverage',
10+
type: 'object',
11+
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: 'api_coverage', type: 'integer', example: 1),
16+
new OA\Property(property: 'component', ref: '#/components/schemas/OpenStackComponent'),
17+
new OA\Property(property: 'release', ref: '#/components/schemas/OpenStackRelease'),
18+
]
19+
)]
20+
class OpenStackImplementationApiCoverageSchema
21+
{
22+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
namespace App\Swagger\schemas;
4+
5+
use OpenApi\Attributes as OA;
6+
7+
#[OA\Schema(
8+
schema: 'OpenStackImplementation',
9+
type: 'object',
10+
properties: [
11+
new OA\Property(property: 'id', type: 'integer', example: 1),
12+
new OA\Property(property: 'created', type: 'integer', example: 1),
13+
new OA\Property(property: 'last_edited', type: 'integer', example: 1),
14+
new OA\Property(property: 'name', type: 'string'),
15+
new OA\Property(property: 'url', type: 'string'),
16+
new OA\Property(property: 'url_segment', type: 'string'),
17+
new OA\Property(property: 'city', type: 'string'),
18+
new OA\Property(property: 'state', type: 'string'),
19+
new OA\Property(property: 'country', type: 'string'),
20+
new OA\Property(property: 'description', type: 'string'),
21+
new OA\Property(property: 'industry', type: 'string'),
22+
new OA\Property(property: 'contributions', type: 'string'),
23+
new OA\Property(property: 'member_level', type: 'string'),
24+
new OA\Property(property: 'overview', type: 'string'),
25+
new OA\Property(property: 'products', type: 'string'),
26+
new OA\Property(property: 'commitment', type: 'string'),
27+
new OA\Property(property: 'commitment_author', type: 'string'),
28+
new OA\Property(property: 'logo', type: 'string'),
29+
new OA\Property(property: 'big_logo', type: 'string'),
30+
new OA\Property(property: 'color', type: 'string'),
31+
new OA\Property(property: 'display_on_site', type: 'boolean'),
32+
new OA\Property(property: 'featured', type: 'boolean'),
33+
new OA\Property(property: 'contact_email', type: 'string'),
34+
new OA\Property(property: 'admin_email', type: 'string'),
35+
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"),
36+
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"),
37+
new OA\Property(property: 'supported_regions', type: 'array', items: new OA\Items(oneOf: [new OA\Schema(type: 'integer'), new OA\Schema(ref: '#/components/schemas/RegionalSupport'),]), description: "RegionalSupport, only available on expand"),
38+
new OA\Property(property: 'is_compatible_with_storage', type: 'boolean', description: "RegionalSupport, only available on expand", ),
39+
new OA\Property(property: 'is_compatible_with_compute', type: 'boolean', description: "RegionalSupport, only available on expand", ),
40+
new OA\Property(property: 'is_compatible_with_federated_identity', type: 'boolean', description: "RegionalSupport, only available on expand", ),
41+
new OA\Property(property: 'is_compatible_with_platform', type: 'boolean', description: "RegionalSupport, only available on expand", ),
42+
new OA\Property(property: 'is_openstack_powered', type: 'boolean', description: "RegionalSupport, only available on expand", ),
43+
new OA\Property(property: 'is_openstack_tested', type: 'boolean', description: "RegionalSupport, only available on expand", ),
44+
new OA\Property(property: 'openstack_tested_info', type: 'string', description: "RegionalSupport, only available on expand", ),
45+
new OA\Property(property: 'capabilities', type: 'array', items: new OA\Items(ref: '#/components/schemas/OpenStackImplementationApiCoverage'), description: "OpenStackImplementationApiCoverage, only available on relations", ),
46+
new OA\Property(property: 'guests', type: 'array', items: new OA\Items(ref: '#/components/schemas/GuestOSType'), description: "GuestOSType, only available on relations", ),
47+
new OA\Property(property: 'hypervisors', type: 'array', items: new OA\Items(ref: '#/components/schemas/HyperVisorType'), description: "HyperVisorType, only available on relations", ),
48+
]
49+
)]
50+
class OpenStackImplementationSchema
51+
{
52+
}

0 commit comments

Comments
 (0)