Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Jan 27, 2025
1 parent e3e2040 commit 7792617
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/JsonApi/JsonSchema/SchemaFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@ public function buildSchema(string $className, string $format = 'jsonapi', strin
}
// We don't use the serializer context here as JSON:API doesn't leverage serializer groups for related resources.
// That is done by query parameter. @see https://jsonapi.org/format/#fetching-includes
$operation ??= $this->findOperation($className, $type, $operation, $serializerContext, $format);
$serializerContext ??= $this->getSerializerContext($operation, $type);
$jsonApiSerializerContext = !($serializerContext[self::DISABLE_JSON_SCHEMA_SERIALIZER_GROUPS] ?? true) ? $serializerContext : [];
$jsonApiSerializerContext = !($serializerContext[self::DISABLE_JSON_SCHEMA_SERIALIZER_GROUPS] ?? true) ? $this->getSerializerContext($operation, $type) : [];
$schema = $this->schemaFactory->buildSchema($className, $format, $type, $operation, $schema, $jsonApiSerializerContext, $forceCollection);

if (($key = $schema->getRootDefinitionKey()) || ($key = $schema->getItemsDefinitionKey())) {
Expand Down
1 change: 1 addition & 0 deletions src/OpenApi/Factory/OpenApiFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ private function getErrorResource(string $error, ?int $status = null, ?string $d
throw new RuntimeException(\sprintf('The error class "%s" does not implement "%s". Did you forget a use statement?', $error, ProblemExceptionInterface::class));
}

dump($error);
try {
$errorResource = $this->resourceMetadataFactory->create($error)[0] ?? new ErrorResource(status: $status, description: $description, class: ApiResourceError::class);
if (!is_a($errorResource, ErrorResource::class)) {
Expand Down
5 changes: 2 additions & 3 deletions tests/JsonSchema/Command/JsonSchemaGenerateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Question;
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\RelatedDummy;
use ApiPlatform\Tests\SetupClassResourcesTrait;
use PHPUnit\Framework\Attributes\DataProvider;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Tester\ApplicationTester;
Expand Down Expand Up @@ -378,9 +379,7 @@ public function testGenId(): void
$this->assertArrayNotHasKey('@id', $json['definitions']['DisableIdGenerationItem.jsonld']['properties']);
}

/**
* @dataProvider arrayPropertyTypeSyntaxProvider
*/
#[DataProvider('arrayPropertyTypeSyntaxProvider')]
public function testOpenApiSchemaGenerationForArrayProperty(string $propertyName, array $expectedProperties): void
{
$this->tester->run([
Expand Down

0 comments on commit 7792617

Please sign in to comment.