Updated scramble

This commit is contained in:
Constantin Graf
2024-07-17 16:25:34 +02:00
committed by Gregor Vostrak
parent 99c652a61b
commit 0e7dec2f40
4 changed files with 22 additions and 10 deletions

View File

@@ -27,13 +27,10 @@ class PaginatedResourceCollectionTypeToSchema extends TypeToSchemaExtension
&& $type->isInstanceOf(PaginatedResourceCollection::class);
}
/**
* @param Generic $type
*/
public function toResponse(Type $type): ?Response
public function toSchema(Type $type): ?OpenApiObjectType
{
/** @var Type|null $collectingClassType */
$collectingClassType = $type->templateTypes[0];
$collectingClassType = $type->templateTypes[0] ?? null;
if (! $collectingClassType instanceof ObjectType) {
return null;
@@ -79,6 +76,21 @@ class PaginatedResourceCollectionTypeToSchema extends TypeToSchemaExtension
);
$type->setRequired(['data', 'links', 'meta']);
return $type;
}
/**
* @param Generic $type
*/
public function toResponse(Type $type): ?Response
{
/** @var ObjectType|null $collectingClassType */
$collectingClassType = $type->templateTypes[0] ?? null;
if (! $collectingClassType instanceof ObjectType) {
return null;
}
$type = $this->toSchema($type);
return Response::make(200)
->description('Paginated set of `'.$this->components->uniqueSchemaName($collectingClassType->name).'`')
->setContent('application/json', Schema::fromType($type));

View File

@@ -12,5 +12,6 @@ abstract class BaseResource extends JsonResource
protected function formatDateTime(?Carbon $carbon): ?string
{
return $carbon?->toIso8601ZuluString();
}
}

8
composer.lock generated
View File

@@ -1403,12 +1403,12 @@
"source": {
"type": "git",
"url": "https://github.com/korridor/scramble.git",
"reference": "78b2a5a5eb8071b006bddc95e34e0620c8bf3b7d"
"reference": "ff692e60e3827ee395007d19ae377fc0d7274fe3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/korridor/scramble/zipball/78b2a5a5eb8071b006bddc95e34e0620c8bf3b7d",
"reference": "78b2a5a5eb8071b006bddc95e34e0620c8bf3b7d",
"url": "https://api.github.com/repos/korridor/scramble/zipball/ff692e60e3827ee395007d19ae377fc0d7274fe3",
"reference": "ff692e60e3827ee395007d19ae377fc0d7274fe3",
"shasum": ""
},
"require": {
@@ -1487,7 +1487,7 @@
"url": "https://github.com/romalytvynenko"
}
],
"time": "2024-03-19T15:56:18+00:00"
"time": "2024-07-17T11:33:15+00:00"
},
{
"name": "defuse/php-encryption",

View File

@@ -28,7 +28,6 @@ services:
extra_hosts:
- 'host.docker.internal:host-gateway'
environment:
SUPERVISOR_PHP_COMMAND: "/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan octane:start --server=frankenphp --host=0.0.0.0 --admin-port=2019 --port=80 --watch"
XDG_CONFIG_HOME: /var/www/html/config
XDG_DATA_HOME: /var/www/html/data
WWWUSER: '${WWWUSER}'