Skip to content

Commit

Permalink
Merge pull request #59 from api-platform/api_resource
Browse files Browse the repository at this point in the history
Prefix annotations of API Platform with Api
  • Loading branch information
dunglas committed May 16, 2016
2 parents 6814340 + 90bce71 commit c3ae6c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public function generateClassAnnotations($className)
{
$resource = $this->classes[$className]['resource'];

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

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

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

return $typeIsEnum ? [] : ['ApiPlatform\Core\Annotation\Resource', 'ApiPlatform\Core\Annotation\Property'];
return $typeIsEnum ? [] : ['ApiPlatform\Core\Annotation\ApiResource', 'ApiPlatform\Core\Annotation\ApiProperty'];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ public function setUp()

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

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

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

0 comments on commit c3ae6c1

Please sign in to comment.