Updates on the openapi spec

This commit is contained in:
2024-02-21 12:07:16 +01:00
parent 7950c1f0c8
commit f0dba6f8b2
3 changed files with 18 additions and 10 deletions
+3 -3
View File
@@ -7,10 +7,10 @@ use App\Library\Economy\Payment\GatewayInterface;
use App\State\GatewayStateProvider;
/**
* Gateways represent payment services used to perform Transactions from Users into Accountings of the platform.\
* Gateways represent payment services used to perform the necessary payments for Transactions between Accounts.\
* \
* For each Gateway there is an internal implementation that handles the creation and validation of Transactions between Accountings.
* These implementations make use of external or internal payment services to gather the funds that are inside a Transaction,
* For each Gateway there is an internal implementation that handles the creation and validation of Transactions between Accounts.
* These implementations make use of external or internal services to gather the funds that are inside a Transaction,
* perform corroboration of funds and store the Transactions into the system.
*/
#[API\GetCollection(provider: GatewayStateProvider::class)]
+4
View File
@@ -6,8 +6,12 @@ use ApiPlatform\Metadata as API;
use App\Repository\AccountRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* Accounts are the senders and receivers of Transactions.
*/
#[ORM\Entity(repositoryClass: AccountRepository::class)]
#[API\ApiResource]
#[API\Get()]
class Account
{
#[ORM\Id]
+11 -7
View File
@@ -22,15 +22,19 @@ class OpenApiFactory implements OpenApiFactoryInterface
$idResource = $operation->getTags()[0];
$idOperation = array_slice($idParts, -1)[0];
$operationDescription = $operation->getDescription();
switch ($idOperation) {
case 'collection':
$operationId = sprintf('List all %ss', $idResource);
break;
case 'post':
$operationId = sprintf('Create one %s', $idResource);
$operationDescription = sprintf('Creates a new %s resource.', $idResource);
break;
case 'get':
$operationId = sprintf('Retrieve one %s', $idResource);
$operationDescription = sprintf('Retrieves one %s resource.', $idResource);
break;
case 'put':
$operationId = sprintf('Update one %s', $idResource);
@@ -46,8 +50,9 @@ class OpenApiFactory implements OpenApiFactoryInterface
}
return $operation
->withSummary($operationId)
->withOperationId($operationId)
->withSummary($operationId);
->withDescription($operationDescription);
}
private function updatePathItemOperations(PathItem $pathItem): PathItem
@@ -89,6 +94,10 @@ class OpenApiFactory implements OpenApiFactoryInterface
{
$openApi = $this->decorated->__invoke($context);
$openApi = $openApi->withServers([
new Model\Server(sprintf('%s://%s', $_SERVER['REQUEST_SCHEME'], $_SERVER['HTTP_HOST']))
]);
$openApi = $openApi->withInfo(
$openApi
->getInfo()
@@ -104,8 +113,7 @@ class OpenApiFactory implements OpenApiFactoryInterface
$tags = [];
foreach ($openApi->getComponents()->getSchemas() as $name => $schema) {
if (\preg_match('/.*\.json/', $name)) continue;
if (empty($schema['description'])) continue;
if (\preg_match('/.*\.jsonld/', $name)) continue;
$tags[] = [
'name' => $name,
@@ -124,10 +132,6 @@ class OpenApiFactory implements OpenApiFactoryInterface
$openApi = $openApi->withPaths($paths);
$openApi = $openApi->withServers([
new Model\Server(sprintf('%s://%s', $_SERVER['REQUEST_SCHEME'], $_SERVER['HTTP_HOST']))
]);
return $openApi;
}
}