• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 7248896662

18 Dec 2023 01:40PM UTC coverage: 37.348% (-0.01%) from 37.359%
7248896662

push

github

web-flow
fix(jsonschema): fix invalid "int" type to "integer" (#6049)

* fix(jsonschema): fix invalid "int" type to "integer"

Fixes: 6048
For int backed enum, api-platform generates "type":"int", which is invalid in jsonschema. It should be "integer"

* test: enum schema as integer

---------

Co-authored-by: soyuka <soyuka@users.noreply.github.com>

1 of 9 new or added lines in 3 files covered. (11.11%)

10295 of 27565 relevant lines covered (37.35%)

28.14 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/JsonSchema/Tests/Metadata/Property/Factory/SchemaPropertyMetadataFactoryTest.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\JsonSchema\Tests\Metadata\Property\Factory;
15

16
use ApiPlatform\JsonSchema\Metadata\Property\Factory\SchemaPropertyMetadataFactory;
17
use ApiPlatform\JsonSchema\Tests\Fixtures\DummyWithEnum;
18
use ApiPlatform\JsonSchema\Tests\Fixtures\Enum\IntEnumAsIdentifier;
19
use ApiPlatform\Metadata\ApiProperty;
20
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
21
use ApiPlatform\Metadata\ResourceClassResolverInterface;
22
use PHPUnit\Framework\TestCase;
23
use Symfony\Component\PropertyInfo\Type;
24

25
class SchemaPropertyMetadataFactoryTest extends TestCase
26
{
27
    public function testEnum(): void
28
    {
NEW
29
        $resourceClassResolver = $this->createMock(ResourceClassResolverInterface::class);
×
NEW
30
        $apiProperty = new ApiProperty(builtinTypes: [new Type(builtinType: 'object', nullable: true, class: IntEnumAsIdentifier::class)]);
×
NEW
31
        $decorated = $this->createMock(PropertyMetadataFactoryInterface::class);
×
NEW
32
        $decorated->expects($this->once())->method('create')->with(DummyWithEnum::class, 'intEnumAsIdentifier')->willReturn($apiProperty);
×
NEW
33
        $schemaPropertyMetadataFactory = new SchemaPropertyMetadataFactory($resourceClassResolver, $decorated);
×
NEW
34
        $apiProperty = $schemaPropertyMetadataFactory->create(DummyWithEnum::class, 'intEnumAsIdentifier');
×
NEW
35
        $this->assertEquals(['type' => ['integer', 'null'], 'enum' => [1, 2, null]], $apiProperty->getSchema());
×
36
    }
37
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc