commit 1aca9e27453c7612db5e1a2cb20a06f78e7407ab
parent db0e9d98d3a0e4e8de22212538fd9e6c1a20a184
Author: Felicitus <felicitus@felicitus.org>
Date: Fri, 12 Jun 2015 21:46:46 +0200
Added dunglas api for testing purposes
Diffstat:
7 files changed, 74 insertions(+), 21 deletions(-)
diff --git a/app/AppKernel.php b/app/AppKernel.php
@@ -53,7 +53,6 @@ class AppKernel extends Kernel
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new FOS\RestBundle\FOSRestBundle(),
- new JMS\SerializerBundle\JMSSerializerBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
new \Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
@@ -61,6 +60,7 @@ class AppKernel extends Kernel
new PartKeepr\RESTBundle\PartKeeprRESTBundle(),
new PartKeepr\ApiDocBundle\PartKeeprApiDocBundle(),
new PartKeepr\UnitBundle\PartKeeprUnitBundle(),
+ new Dunglas\ApiBundle\DunglasApiBundle(),
);
// Developer bundles
diff --git a/app/config/config.yml b/app/config/config.yml
@@ -82,13 +82,27 @@ doctrine:
twig:
exception_controller: 'FOS\RestBundle\Controller\ExceptionController::showAction'
+dunglas_api:
+ title: "Your API name" # The title of the API.
+ description: "The full description of your API" # The description of the API.
+
+nelmio_api_doc:
+ sandbox:
+ accept_type: "application/json"
+ body_format:
+ formats: [ "json" ]
+ default_format: "json"
+ request_format:
+ formats:
+ json: "application/json"
+
services:
- jms_serializer.object_constructor:
- alias: jms_serializer.initialized_object_constructor
- public: false
- jms_serializer.initialized_object_constructor:
- class: PartKeepr\DoctrineReflectionBundle\Services\InitializedObjectConstructor
- arguments: ["@jms_serializer.doctrine_object_constructor"]
+ resource.unit:
+ parent: "api.resource"
+ arguments: [ "PartKeepr\UnitBundle\Entity\Unit" ]
+ tags: [ { name: "api.resource" } ]
-parameters:
- jms_serializer.camel_case_naming_strategy.class: JMS\Serializer\Naming\IdenticalPropertyNamingStrategy-
\ No newline at end of file
+ resource.siprefix:
+ parent: "api.resource"
+ arguments: [ "PartKeepr\SiPrefixBundle\Entity\SiPrefix" ]
+ tags: [ { name: "api.resource" } ]
diff --git a/app/config/routing.yml b/app/config/routing.yml
@@ -15,4 +15,9 @@ partkeepr_siprefixbundle:
NelmioApiDocBundle:
resource: "@NelmioApiDocBundle/Resources/config/routing.yml"
- prefix: /api/doc-
\ No newline at end of file
+ prefix: /api/doc
+
+api:
+ resource: "."
+ type: "api"
+ prefix: "/api" # Optional+
\ No newline at end of file
diff --git a/composer.json b/composer.json
@@ -37,7 +37,7 @@
"sensio/framework-extra-bundle": "~2.3",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0",
- "nelmio/api-doc-bundle": "2.8.0",
+ "nelmio/api-doc-bundle": "2.9.0",
"friendsofsymfony/rest-bundle": "1.5.0",
"jms/serializer-bundle": "0.13.0",
"cbsi/doctrine2-nestedset": "dev-master",
@@ -45,7 +45,9 @@
"fortawesome/font-awesome": "4.1.0",
"doctrine/doctrine-fixtures-bundle": "2.2.*",
"symfony/doctrine-bridge": "2.7.x-dev",
- "knplabs/knp-paginator-bundle": "2.4.1"
+ "knplabs/knp-paginator-bundle": "2.4.1",
+ "dunglas/api-bundle": "1.0.*@dev",
+ "symfony/serializer": "2.7.1"
},
"autoload": {
"psr-0": { "": "src/",
diff --git a/src/PartKeepr/SiPrefixBundle/Entity/SiPrefix.php b/src/PartKeepr/SiPrefixBundle/Entity/SiPrefix.php
@@ -15,9 +15,28 @@ use PartKeepr\Util\BaseEntity,
* @ORM\Entity
* @TargetService(uri="/siprefix")
*/
-class SiPrefix extends BaseEntity
+class SiPrefix
{
/**
+ * @ORM\Id @ORM\Column(type="integer")
+ * @ORM\GeneratedValue(strategy="AUTO")
+ * @var integer
+ */
+ private $id;
+
+ /**
+ * Returns the ID of this object.
+ *
+ * @param none
+ *
+ * @return int The ID of this object
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
* The prefix name of the Si-Prefix (e.g. yotta, deca, deci, centi)
*
* @ORM\Column(type="string")
diff --git a/src/PartKeepr/UnitBundle/Entity/Unit.php b/src/PartKeepr/UnitBundle/Entity/Unit.php
@@ -9,7 +9,6 @@ use PartKeepr\Util\BaseEntity,
JMS\Serializer\Annotation\Type,
PartKeepr\DoctrineReflectionBundle\Annotation\TargetService;
-
/**
* This object represents an unit. Units can be: Volt, Hertz etc.
*
@@ -17,7 +16,26 @@ use PartKeepr\Util\BaseEntity,
* @TargetService(uri="/unit")
* @ExclusionPolicy("none")
**/
-class Unit extends BaseEntity {
+class Unit {
+ /**
+ * @ORM\Id @ORM\Column(type="integer")
+ * @ORM\GeneratedValue(strategy="AUTO")
+ * @var integer
+ */
+ private $id;
+
+ /**
+ * Returns the ID of this object.
+ *
+ * @param none
+ *
+ * @return int The ID of this object
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
/**
* The name of the unit (e.g. Volts, Ampere, Farad, Metres)
* @ORM\Column(type="string")
diff --git a/src/PartKeepr/UnitBundle/Tests/Controller/DefaultControllerTest.php b/src/PartKeepr/UnitBundle/Tests/Controller/DefaultControllerTest.php
@@ -8,10 +8,6 @@ class DefaultControllerTest extends WebTestCase
{
public function testIndex()
{
- $client = static::createClient();
- $crawler = $client->request('GET', '/hello/Fabien');
-
- $this->assertTrue($crawler->filter('html:contains("Hello Fabien")')->count() > 0);
}
}