Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use App\Models\Foundation\Main\Repositories\ISupportingCompanyRepository;
use App\Services\Model\ISponsoredProjectService;
use Illuminate\Http\Request as LaravelRequest;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Log;
use libs\utils\HTMLCleaner;
use models\exceptions\EntityNotFoundException;
Expand All @@ -28,6 +29,8 @@
use utils\Filter;
use utils\FilterElement;
use utils\PagingInfo;
use OpenApi\Attributes as OA;

/**
* Class OAuth2SponsoredProjectApiController
* @package App\Http\Controllers
Expand Down Expand Up @@ -180,6 +183,71 @@ function () {

// sponsorship types

#[OA\Get(
path: "/api/v1/sponsored-projects/{id}/sponsorship-types",
description: "Get all sponsorship types for a sponsored project",
summary: 'Read All Sponsorship Types',
operationId: 'getAllSponsorshipTypes',
tags: ['Sponsored Projects', 'Sponsorship Types'],
security: [['oauth2' => ['read']]],
parameters: [
new OA\Parameter(
name: 'access_token',
in: 'query',
required: false,
description: 'OAuth2 access token (alternative to Authorization: Bearer)',
schema: new OA\Schema(type: 'string', example: 'eyJhbGciOi...'),
),
new OA\Parameter(
name: 'id',
in: 'path',
required: true,
schema: new OA\Schema(type: 'string'),
description: 'The sponsored project id or slug'
),
new OA\Parameter(
name: 'filter[]',
in: 'query',
required: false,
description: 'Filter expressions in the format field<op>value',
style: 'form',
explode: true,
schema: new OA\Schema(
type: 'array',
items: new OA\Items(type: 'string', example: 'name@@type')
)
),
new OA\Parameter(
name: 'order',
in: 'query',
required: false,
description: 'Order by field(s)',
schema: new OA\Schema(type: 'string', example: 'order,name')
),
new OA\Parameter(
name: 'page',
in: 'query',
required: false,
schema: new OA\Schema(type: 'integer', default: 1)
),
new OA\Parameter(
name: 'per_page',
in: 'query',
required: false,
schema: new OA\Schema(type: 'integer', default: 10)
),
],
responses: [
new OA\Response(
response: 200,
description: 'List of sponsorship types',
content: new OA\JsonContent(ref: '#/components/schemas/PaginatedProjectSponsorshipTypesResponse')
),
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
/**
* @param $id string|int
*/
Expand Down Expand Up @@ -232,6 +300,47 @@ function ($page, $per_page, $filter, $order, $applyExtraFilters) {
);
}

#[OA\Get(
path: "/api/v1/sponsored-projects/{id}/sponsorship-types/{sponsorship_type_id}",
description: "Get a specific sponsorship type",
summary: 'Read Sponsorship Type',
operationId: 'getSponsorshipType',
tags: ['Sponsored Projects', 'Sponsorship Types'],
security: [['oauth2' => ['read']]],
parameters: [
new OA\Parameter(
name: 'access_token',
in: 'query',
required: false,
description: 'OAuth2 access token (alternative to Authorization: Bearer)',
schema: new OA\Schema(type: 'string', example: 'eyJhbGciOi...'),
),
new OA\Parameter(
name: 'id',
in: 'path',
required: true,
schema: new OA\Schema(type: 'string'),
description: 'The sponsored project id or slug'
),
new OA\Parameter(
name: 'sponsorship_type_id',
in: 'path',
required: true,
schema: new OA\Schema(type: 'integer'),
description: 'The sponsorship type id'
),
],
responses: [
new OA\Response(
response: 200,
description: 'Sponsorship type details',
content: new OA\JsonContent(ref: '#/components/schemas/ProjectSponsorshipType')
),
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
/**
* @param $id
* @param $sponsorship_type_id
Expand Down Expand Up @@ -299,6 +408,78 @@ function ($sponsorship_type_id, $project_id){

// supporting companies

#[OA\Get(
path: "/api/v1/sponsored-projects/{id}/sponsorship-types/{sponsorship_type_id}/supporting-companies",
description: "Get all supporting companies for a sponsorship type",
summary: 'Read All Supporting Companies',
operationId: 'getSupportingCompanies',
tags: ['Sponsored Projects', 'Supporting Companies'],
security: [['oauth2' => ['read']]],
parameters: [
new OA\Parameter(
name: 'access_token',
in: 'query',
required: false,
description: 'OAuth2 access token (alternative to Authorization: Bearer)',
schema: new OA\Schema(type: 'string', example: 'eyJhbGciOi...'),
),
new OA\Parameter(
name: 'id',
in: 'path',
required: true,
schema: new OA\Schema(type: 'string'),
description: 'The sponsored project id or slug'
),
new OA\Parameter(
name: 'sponsorship_type_id',
in: 'path',
required: true,
schema: new OA\Schema(type: 'string'),
description: 'The sponsorship type id or slug'
),
new OA\Parameter(
name: 'filter[]',
in: 'query',
required: false,
description: 'Filter expressions',
style: 'form',
explode: true,
schema: new OA\Schema(
type: 'array',
items: new OA\Items(type: 'string')
)
),
new OA\Parameter(
name: 'order',
in: 'query',
required: false,
description: 'Order by field(s)',
schema: new OA\Schema(type: 'string', example: 'order,name')
),
new OA\Parameter(
name: 'page',
in: 'query',
required: false,
schema: new OA\Schema(type: 'integer', default: 1)
),
new OA\Parameter(
name: 'per_page',
in: 'query',
required: false,
schema: new OA\Schema(type: 'integer', default: 10)
),
],
responses: [
new OA\Response(
response: 200,
description: 'List of supporting companies',
content: new OA\JsonContent(ref: '#/components/schemas/PaginatedSupportingCompaniesResponse')
),
new OA\Response(response: Response::HTTP_UNAUTHORIZED, description: "Unauthorized"),
new OA\Response(response: Response::HTTP_NOT_FOUND, description: "not found"),
new OA\Response(response: Response::HTTP_INTERNAL_SERVER_ERROR, description: "Server Error"),
]
)]
public function getSupportingCompanies($id, $sponsorship_type_id){
return $this->_getAll(
function () {
Expand Down
118 changes: 118 additions & 0 deletions app/Swagger/SponsoredProjectSchemas.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?php

use OpenApi\Attributes as OA;

#[OA\Schema(
schema: 'SponsoredProject',
title: 'SponsoredProject',
description: 'Represents a Sponsored Project',
type: 'object',
required: ['name'],
properties: [
new OA\Property(property: 'id', type: 'integer', format: 'int64'),
new OA\Property(property: 'name', type: 'string'),
new OA\Property(property: 'slug', type: 'string'),
new OA\Property(property: 'description', type: 'string'),
new OA\Property(property: 'is_active', type: 'boolean'),
new OA\Property(property: 'created', type: 'integer', format: 'int64'),
new OA\Property(property: 'last_edited', type: 'integer', format: 'int64'),
]
)]
class SponsoredProjectSchemas {}

#[OA\Schema(
schema: 'PaginatedSponsoredProjectsResponse',
title: 'Paginated Sponsored Projects',
description: 'Paginated list of sponsored projects',
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/SponsoredProject')
),
]
)
]
)]
class PaginatedSponsoredProjectsResponse {}

#[OA\Schema(
schema: 'ProjectSponsorshipType',
title: 'Project Sponsorship Type',
description: 'Represents a Project Sponsorship Type',
type: 'object',
required: ['name'],
properties: [
new OA\Property(property: 'id', type: 'integer', format: 'int64'),
new OA\Property(property: 'name', type: 'string'),
new OA\Property(property: 'slug', type: 'string'),
new OA\Property(property: 'description', type: 'string'),
new OA\Property(property: 'is_active', type: 'boolean'),
new OA\Property(property: 'order', type: 'integer'),
new OA\Property(property: 'sponsored_project_id', type: 'integer', format: 'int64'),
new OA\Property(property: 'created', type: 'integer', format: 'int64'),
new OA\Property(property: 'last_edited', type: 'integer', format: 'int64'),
]
)]
class ProjectSponsorshipType {}

#[OA\Schema(
schema: 'PaginatedProjectSponsorshipTypesResponse',
title: 'Paginated Project Sponsorship Types',
description: 'Paginated list of project sponsorship types',
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/ProjectSponsorshipType')
),
]
)
]
)]
class PaginatedProjectSponsorshipTypesResponse {}

#[OA\Schema(
schema: 'SupportingCompany',
title: 'Supporting Company',
description: 'Represents a Supporting Company for a Sponsorship Type',
type: 'object',
required: ['company_id'],
properties: [
new OA\Property(property: 'id', type: 'integer', format: 'int64'),
new OA\Property(property: 'company_id', type: 'integer', format: 'int64'),
new OA\Property(property: 'sponsorship_type_id', type: 'integer', format: 'int64'),
new OA\Property(property: 'order', type: 'integer'),
new OA\Property(property: 'created', type: 'integer', format: 'int64'),
new OA\Property(property: 'last_edited', type: 'integer', format: 'int64'),
]
)]
class SupportingCompany {}

#[OA\Schema(
schema: 'PaginatedSupportingCompaniesResponse',
title: 'Paginated Supporting Companies',
description: 'Paginated list of supporting companies',
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/SupportingCompany')
),
]
)
]
)]
class PaginatedSupportingCompaniesResponse {}