Skip to content

Commit 90bce71

Browse files
committed
Prefix annotations of API Platform with Api
1 parent 6814340 commit 90bce71

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/AnnotationGenerator/ApiPlatformCoreAnnotationGenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ public function generateClassAnnotations($className)
2929
{
3030
$resource = $this->classes[$className]['resource'];
3131

32-
return [sprintf('@Resource(iri="%s")', $resource->getUri())];
32+
return [sprintf('@ApiResource(iri="%s")', $resource->getUri())];
3333
}
3434

3535
/**
3636
* {@inheritdoc}
3737
*/
3838
public function generateFieldAnnotations($className, $fieldName)
3939
{
40-
return $this->classes[$className]['fields'][$fieldName]['isCustom'] ? [] : [sprintf('@Property(iri="http://schema.org/%s")', $fieldName)];
40+
return $this->classes[$className]['fields'][$fieldName]['isCustom'] ? [] : [sprintf('@ApiProperty(iri="http://schema.org/%s")', $fieldName)];
4141
}
4242

4343
/**
@@ -50,6 +50,6 @@ public function generateUses($className)
5050
$subClassOf = $resource->get('rdfs:subClassOf');
5151
$typeIsEnum = $subClassOf && $subClassOf->getUri() === TypesGenerator::SCHEMA_ORG_ENUMERATION;
5252

53-
return $typeIsEnum ? [] : ['ApiPlatform\Core\Annotation\Resource', 'ApiPlatform\Core\Annotation\Property'];
53+
return $typeIsEnum ? [] : ['ApiPlatform\Core\Annotation\ApiResource', 'ApiPlatform\Core\Annotation\ApiProperty'];
5454
}
5555
}

tests/AnnotationGenerator/ApiPlatformCoreAnnotationGeneratorTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,18 @@ public function setUp()
5151

5252
public function testGenerateClassAnnotations()
5353
{
54-
$this->assertSame(['@Resource(iri="http://schema.org/Res")'], $this->generator->generateClassAnnotations('Res'));
54+
$this->assertSame(['@ApiResource(iri="http://schema.org/Res")'], $this->generator->generateClassAnnotations('Res'));
5555
}
5656

5757
public function testGenerateFieldAnnotations()
5858
{
59-
$this->assertSame(['@Property(iri="http://schema.org/prop")'], $this->generator->generateFieldAnnotations('Res', 'prop'));
59+
$this->assertSame(['@ApiProperty(iri="http://schema.org/prop")'], $this->generator->generateFieldAnnotations('Res', 'prop'));
6060
$this->assertSame([], $this->generator->generateFieldAnnotations('Res', 'customProp'));
6161
}
6262

6363
public function testGenerateUses()
6464
{
65-
$this->assertSame(['ApiPlatform\Core\Annotation\Resource', 'ApiPlatform\Core\Annotation\Property'], $this->generator->generateUses('Res'));
65+
$this->assertSame(['ApiPlatform\Core\Annotation\ApiResource', 'ApiPlatform\Core\Annotation\ApiProperty'], $this->generator->generateUses('Res'));
6666
$this->assertSame([], $this->generator->generateUses('MyEnum'));
6767
}
6868
}

0 commit comments

Comments
 (0)