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

View File

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

8
composer.lock generated
View File

@@ -1403,12 +1403,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/korridor/scramble.git", "url": "https://github.com/korridor/scramble.git",
"reference": "78b2a5a5eb8071b006bddc95e34e0620c8bf3b7d" "reference": "ff692e60e3827ee395007d19ae377fc0d7274fe3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/korridor/scramble/zipball/78b2a5a5eb8071b006bddc95e34e0620c8bf3b7d", "url": "https://api.github.com/repos/korridor/scramble/zipball/ff692e60e3827ee395007d19ae377fc0d7274fe3",
"reference": "78b2a5a5eb8071b006bddc95e34e0620c8bf3b7d", "reference": "ff692e60e3827ee395007d19ae377fc0d7274fe3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1487,7 +1487,7 @@
"url": "https://github.com/romalytvynenko" "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", "name": "defuse/php-encryption",

View File

@@ -28,7 +28,6 @@ services:
extra_hosts: extra_hosts:
- 'host.docker.internal:host-gateway' - 'host.docker.internal:host-gateway'
environment: 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_CONFIG_HOME: /var/www/html/config
XDG_DATA_HOME: /var/www/html/data XDG_DATA_HOME: /var/www/html/data
WWWUSER: '${WWWUSER}' WWWUSER: '${WWWUSER}'