From 67549b20e1a4106725d8de5041b538a292ed2a59 Mon Sep 17 00:00:00 2001 From: Matias Perrone Date: Mon, 29 Sep 2025 15:15:26 -0300 Subject: [PATCH 1/4] feat: Add OpenAPI documentation to "getAll" method --- .../Marketplace/ConsultantsApiController.php | 87 ++++++++++++++++++- 1 file changed, 86 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Apis/Marketplace/ConsultantsApiController.php b/app/Http/Controllers/Apis/Marketplace/ConsultantsApiController.php index 43256704f..c78fc54ef 100644 --- a/app/Http/Controllers/Apis/Marketplace/ConsultantsApiController.php +++ b/app/Http/Controllers/Apis/Marketplace/ConsultantsApiController.php @@ -12,7 +12,9 @@ * limitations under the License. **/ use App\Models\Foundation\Marketplace\IConsultantRepository; +use Illuminate\Http\Response; use models\oauth2\IResourceServerContext; +use OpenApi\Attributes as OA; /** * Class ConsultantsApiController @@ -30,8 +32,91 @@ public function __construct(IConsultantRepository $repository, IResourceServerCo parent::__construct($repository, $resource_server_context); } + #[OA\Get( + path: "/api/public/v1/marketplace/consultants", + description: "Get all marketplace consultants and consulting services", + summary: 'Get all consultants', + operationId: 'getAllConsultants', + tags: ['Consultants'], + parameters: [ + new OA\Parameter( + name: 'filter[]', + in: 'query', + required: false, + description: 'Filter expressions in the format fieldvalue. Available fields: name, company. Operators: =@, ==, @@.', + style: 'form', + explode: true, + schema: new OA\Schema( + type: 'array', + items: new OA\Items(type: 'string', example: 'name@@consulting') + ) + ), + new OA\Parameter( + name: 'order', + in: 'query', + required: false, + description: 'Order by field(s)', + schema: new OA\Schema(type: 'string', example: 'name,-id') + ), + new OA\Parameter( + name: 'expand', + in: 'query', + required: false, + description: 'Comma-separated list of related resources to include. Available relations: company, type, offices, clients, spoken_languages, configuration_management_expertise, expertise_areas, services_offered, supported_regions', + schema: new OA\Schema(type: 'string', example: 'company,offices') + ), + new OA\Parameter( + name: 'relations', + in: 'query', + required: false, + description: 'Relations to load eagerly', + schema: new OA\Schema(type: 'string', example: 'company,offices') + ), + new OA\Parameter( + name: 'fields', + in: 'query', + required: false, + description: 'Comma-separated list of fields to return', + schema: new OA\Schema(type: 'string', example: 'id,name,company.name') + ), + ], + responses: [ + new OA\Response( + response: 200, + description: 'Success - Returns paginated list of consultants', + content: new OA\JsonContent( + properties: [ + 'total' => new OA\Property(property: 'total', type: 'integer', example: 15), + 'per_page' => new OA\Property(property: 'per_page', type: 'integer', example: 15), + 'current_page' => new OA\Property(property: 'current_page', type: 'integer', example: 1), + 'last_page' => new OA\Property(property: 'last_page', type: 'integer', example: 1), + 'data' => new OA\Property( + property: 'data', + type: 'array', + items: new OA\Items( + properties: [ + 'id' => new OA\Property(property: 'id', type: 'integer', example: 1), + 'class_name' => new OA\Property(property: 'class_name', type: 'string', example: 'Consultant'), + 'name' => new OA\Property(property: 'name', type: 'string', example: 'OpenStack Consulting Services'), + 'overview' => new OA\Property(property: 'overview', type: 'string', example: 'Professional OpenStack consulting and support services'), + 'call_2_action_url' => new OA\Property(property: 'call_2_action_url', type: 'string', example: 'https://example.com/contact'), + 'slug' => new OA\Property(property: 'slug', type: 'string', example: 'openstack-consulting'), + 'company_id' => new OA\Property(property: 'company_id', type: 'integer', example: 1), + 'type_id' => new OA\Property(property: 'type_id', type: 'integer', example: 1) + ], + type: 'object' + ) + ) + ], + type: 'object' + ) + ), + new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"), + new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") + ] + )] public function getAll() { return parent::getAll(); } -} \ No newline at end of file +} From 25b285eafba59740c4837d6134495c9563457f30 Mon Sep 17 00:00:00 2001 From: Matias Perrone Date: Tue, 30 Sep 2025 16:34:11 -0300 Subject: [PATCH 2/4] chore: Add controller's response OpenAPI schema --- .../Marketplace/ConsultantsApiController.php | 27 +-------------- app/Swagger/schemas.php | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/app/Http/Controllers/Apis/Marketplace/ConsultantsApiController.php b/app/Http/Controllers/Apis/Marketplace/ConsultantsApiController.php index c78fc54ef..d6550b09d 100644 --- a/app/Http/Controllers/Apis/Marketplace/ConsultantsApiController.php +++ b/app/Http/Controllers/Apis/Marketplace/ConsultantsApiController.php @@ -84,32 +84,7 @@ public function __construct(IConsultantRepository $repository, IResourceServerCo new OA\Response( response: 200, description: 'Success - Returns paginated list of consultants', - content: new OA\JsonContent( - properties: [ - 'total' => new OA\Property(property: 'total', type: 'integer', example: 15), - 'per_page' => new OA\Property(property: 'per_page', type: 'integer', example: 15), - 'current_page' => new OA\Property(property: 'current_page', type: 'integer', example: 1), - 'last_page' => new OA\Property(property: 'last_page', type: 'integer', example: 1), - 'data' => new OA\Property( - property: 'data', - type: 'array', - items: new OA\Items( - properties: [ - 'id' => new OA\Property(property: 'id', type: 'integer', example: 1), - 'class_name' => new OA\Property(property: 'class_name', type: 'string', example: 'Consultant'), - 'name' => new OA\Property(property: 'name', type: 'string', example: 'OpenStack Consulting Services'), - 'overview' => new OA\Property(property: 'overview', type: 'string', example: 'Professional OpenStack consulting and support services'), - 'call_2_action_url' => new OA\Property(property: 'call_2_action_url', type: 'string', example: 'https://example.com/contact'), - 'slug' => new OA\Property(property: 'slug', type: 'string', example: 'openstack-consulting'), - 'company_id' => new OA\Property(property: 'company_id', type: 'integer', example: 1), - 'type_id' => new OA\Property(property: 'type_id', type: 'integer', example: 1) - ], - type: 'object' - ) - ) - ], - type: 'object' - ) + content: new OA\JsonContent(ref: '#/components/schemas/PaginatedConsultantsResponse') ), new OA\Response(response: Response::HTTP_PRECONDITION_FAILED, description: "Validation Error"), new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error") diff --git a/app/Swagger/schemas.php b/app/Swagger/schemas.php index 1eff77226..fab70cf30 100644 --- a/app/Swagger/schemas.php +++ b/app/Swagger/schemas.php @@ -351,3 +351,37 @@ class RSVPUpdateRequestSchema_{ ] )] class RSVPAdminAddRequestSchema {} + +#[OA\Schema( + schema: 'ConsultantsResponseSchema', + type: 'object', + properties: [ + 'id' => new OA\Property(property: 'id', type: 'integer', example: 1), + 'class_name' => new OA\Property(property: 'class_name', type: 'string', example: 'Consultant'), + 'name' => new OA\Property(property: 'name', type: 'string', example: 'OpenStack Consulting Services'), + 'overview' => new OA\Property(property: 'overview', type: 'string', example: 'Professional OpenStack consulting and support services'), + 'call_2_action_url' => new OA\Property(property: 'call_2_action_url', type: 'string', example: 'https://example.com/contact'), + 'slug' => new OA\Property(property: 'slug', type: 'string', example: 'openstack-consulting'), + 'company_id' => new OA\Property(property: 'company_id', type: 'integer', example: 1), + 'type_id' => new OA\Property(property: 'type_id', type: 'integer', example: 1) + ] +)] +class ConsultantsResponseSchema {} + +#[OA\Schema( + schema: 'PaginatedConsultantsResponseSchema', + allOf: [ + new OA\Schema(ref: '#/components/schemas/PaginateDataSchemaResponse'), + new OA\Schema( + type: 'object', + properties: [ + new OA\Property( + property: 'data', + type: 'array', + items: new OA\Items(ref: '#/components/schemas/ConsultantsResponseSchema') + ) + ] + ) + ] +)] +class PaginatedConsultantsResponseSchema {} From 45f9678b7feec1cdabfed7591e6fa6e00a420676 Mon Sep 17 00:00:00 2001 From: Matias Perrone Date: Tue, 7 Oct 2025 18:33:51 -0300 Subject: [PATCH 3/4] chore: move schema to independent file for Marketplace schemas --- app/Swagger/MarketplaceSchemas.php | 35 +++++++++++++++++++++++++++++- app/Swagger/schemas.php | 34 ----------------------------- 2 files changed, 34 insertions(+), 35 deletions(-) diff --git a/app/Swagger/MarketplaceSchemas.php b/app/Swagger/MarketplaceSchemas.php index 6b3e2f895..3f05714e3 100644 --- a/app/Swagger/MarketplaceSchemas.php +++ b/app/Swagger/MarketplaceSchemas.php @@ -4,4 +4,37 @@ use OpenApi\Attributes as OA; -// + +#[OA\Schema( + schema: 'ConsultantsResponse', + type: 'object', + properties: [ + 'id' => new OA\Property(property: 'id', type: 'integer', example: 1), + 'class_name' => new OA\Property(property: 'class_name', type: 'string', example: 'Consultant'), + 'name' => new OA\Property(property: 'name', type: 'string', example: 'OpenStack Consulting Services'), + 'overview' => new OA\Property(property: 'overview', type: 'string', example: 'Professional OpenStack consulting and support services'), + 'call_2_action_url' => new OA\Property(property: 'call_2_action_url', type: 'string', example: 'https://example.com/contact'), + 'slug' => new OA\Property(property: 'slug', type: 'string', example: 'openstack-consulting'), + 'company_id' => new OA\Property(property: 'company_id', type: 'integer', example: 1), + 'type_id' => new OA\Property(property: 'type_id', type: 'integer', example: 1) + ] +)] +class ConsultantsResponseSchema {} + +#[OA\Schema( + schema: 'PaginatedConsultantsResponse', + allOf: [ + new OA\Schema(ref: '#/components/schemas/PaginateDataSchemaResponse'), + new OA\Schema( + type: 'object', + properties: [ + new OA\Property( + property: 'data', + type: 'array', + items: new OA\Items(ref: '#/components/schemas/ConsultantsResponse') + ) + ] + ) + ] +)] +class PaginatedConsultantsResponseSchema {} diff --git a/app/Swagger/schemas.php b/app/Swagger/schemas.php index fab70cf30..1eff77226 100644 --- a/app/Swagger/schemas.php +++ b/app/Swagger/schemas.php @@ -351,37 +351,3 @@ class RSVPUpdateRequestSchema_{ ] )] class RSVPAdminAddRequestSchema {} - -#[OA\Schema( - schema: 'ConsultantsResponseSchema', - type: 'object', - properties: [ - 'id' => new OA\Property(property: 'id', type: 'integer', example: 1), - 'class_name' => new OA\Property(property: 'class_name', type: 'string', example: 'Consultant'), - 'name' => new OA\Property(property: 'name', type: 'string', example: 'OpenStack Consulting Services'), - 'overview' => new OA\Property(property: 'overview', type: 'string', example: 'Professional OpenStack consulting and support services'), - 'call_2_action_url' => new OA\Property(property: 'call_2_action_url', type: 'string', example: 'https://example.com/contact'), - 'slug' => new OA\Property(property: 'slug', type: 'string', example: 'openstack-consulting'), - 'company_id' => new OA\Property(property: 'company_id', type: 'integer', example: 1), - 'type_id' => new OA\Property(property: 'type_id', type: 'integer', example: 1) - ] -)] -class ConsultantsResponseSchema {} - -#[OA\Schema( - schema: 'PaginatedConsultantsResponseSchema', - allOf: [ - new OA\Schema(ref: '#/components/schemas/PaginateDataSchemaResponse'), - new OA\Schema( - type: 'object', - properties: [ - new OA\Property( - property: 'data', - type: 'array', - items: new OA\Items(ref: '#/components/schemas/ConsultantsResponseSchema') - ) - ] - ) - ] -)] -class PaginatedConsultantsResponseSchema {} From 3b94e72d95855b116007a5688e1aa87b2d4b86a4 Mon Sep 17 00:00:00 2001 From: Matias Perrone Date: Tue, 14 Oct 2025 12:59:28 -0300 Subject: [PATCH 4/4] fix: Change "namespace" word positioning --- .../Apis/Marketplace/ConsultantsApiController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Apis/Marketplace/ConsultantsApiController.php b/app/Http/Controllers/Apis/Marketplace/ConsultantsApiController.php index d6550b09d..74ff62b43 100644 --- a/app/Http/Controllers/Apis/Marketplace/ConsultantsApiController.php +++ b/app/Http/Controllers/Apis/Marketplace/ConsultantsApiController.php @@ -1,4 +1,7 @@ -