mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Optimized REST API and tests
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
# REST API Controller
|
||||
The controllers use the [FOSRestBundle](https://symfony.com/doc/master/bundles/FOSRestBundle/index.html).
|
||||
## Workflow
|
||||
The abstract workflow of the REST API controllers for a singular entity looks like this:
|
||||

|
||||
Special actions, e.g. lists are not shown in this diagram. This diagram also shows downstream procedures, to remember to implement them. Feel free to remove them from the diagram, as soon as they are documented somewhere else.
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 108 KiB |
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Controller\API\Meta;
|
||||
namespace Infinito\Controller\API\Rest;
|
||||
|
||||
use Infinito\Controller\API\AbstractAPIController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
*
|
||||
* @todo Implement!
|
||||
*/
|
||||
class RightApiController extends AbstractAPIController
|
||||
final class HeredityController extends AbstractAPIController
|
||||
{
|
||||
public function read(Request $request, $identifier): Response
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Controller\API\Meta;
|
||||
namespace Infinito\Controller\API\Rest;
|
||||
|
||||
use Infinito\Controller\API\AbstractAPIController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
*
|
||||
* @todo Implement!
|
||||
*/
|
||||
class LawApiController extends AbstractAPIController
|
||||
final class LawController extends AbstractAPIController
|
||||
{
|
||||
public function read(Request $request, $identifier): Response
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Controller\API\Meta;
|
||||
namespace Infinito\Controller\API\Rest;
|
||||
|
||||
use Infinito\Controller\API\AbstractAPIController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
*
|
||||
* @todo Implement!
|
||||
*/
|
||||
class MemberApiController extends AbstractAPIController
|
||||
final class MemberController extends AbstractAPIController
|
||||
{
|
||||
public function read(Request $request, $identifier): Response
|
||||
{
|
24
application/symfony/src/Controller/API/Rest/README.md
Normal file
24
application/symfony/src/Controller/API/Rest/README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# REST API Controller
|
||||
The controllers use the [FOSRestBundle](https://symfony.com/doc/master/bundles/FOSRestBundle/index.html).
|
||||
## Url Scheme
|
||||
The scheme for the rest api is the following:
|
||||
|
||||
| Url | Methods | Function |
|
||||
|---|---|---|
|
||||
| api/rest/{entity}.{format} | HEAD | Returns the create information for a specific entity |
|
||||
| api/rest/{entity}.{format} | POST | Creates a specific entity and returns it. |
|
||||
| api/rest/{entity}/{uri}.{format} | GET | Returns a specific entity. Including all actions |
|
||||
| api/rest/{entity}/{uri}/{action}.{format} | GET | Returns the result for an action of an specific entity. |
|
||||
| api/rest/{entity}/{uri}.{format} | PUT, PATCH | Updates a specific entity and returns it. |
|
||||
| api/rest/{entity}/{uri}.{format} | DELETE | Deletes a specific entity|
|
||||
|
||||
If an concrete entity doesn't implement an method it should redirect to the connected entity which is responsible for this method.
|
||||
|
||||
In the future it would make sense to implement [more methods](https://de.wikipedia.org/wiki/Representational_State_Transfer#Umsetzung).
|
||||
|
||||
The standard format of an entity MUST be JSON.
|
||||
|
||||
## Workflow
|
||||
The abstract workflow of the REST API controllers for a singular entity looks like this:
|
||||

|
||||
Special actions, e.g. lists are not shown in this diagram. This diagram also shows downstream procedures, to remember to implement them. Feel free to remove them from the diagram, as soon as they are documented somewhere else.
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Controller\API\Meta;
|
||||
namespace Infinito\Controller\API\Rest;
|
||||
|
||||
use Infinito\Controller\API\AbstractAPIController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -11,7 +11,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
*
|
||||
* @todo Implement!
|
||||
*/
|
||||
class HeredityApiController extends AbstractAPIController
|
||||
final class RightController extends AbstractAPIController
|
||||
{
|
||||
public function read(Request $request, $identifier): Response
|
||||
{
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Controller\API\Source;
|
||||
namespace Infinito\Controller\API\Rest;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
@@ -18,20 +18,19 @@ use Infinito\DBAL\Types\Meta\Right\LayerType;
|
||||
* @see https://symfony.com/blog/new-in-symfony-4-1-internationalized-routing
|
||||
* @Route(
|
||||
* {
|
||||
* "en":"/source/{identity}.{_format}",
|
||||
* "de":"/quelle/{identity}.{_format}",
|
||||
* "eo":"/fonto/{identity}.{_format}",
|
||||
* "es":"/fontanar/{identity}.{_format}",
|
||||
* "nl":"/bron/{identity}.{_format}"
|
||||
* "en":"/api/rest/source/{identity}.{_format}",
|
||||
* "de":"/api/rest/quelle/{identity}.{_format}",
|
||||
* "eo":"/api/rest/fonto/{identity}.{_format}",
|
||||
* "es":"/api/rest/fontanar/{identity}.{_format}",
|
||||
* "nl":"/api/rest/bron/{identity}.{_format}"
|
||||
* },
|
||||
* defaults={
|
||||
* "identity"="",
|
||||
* "_format"="json"
|
||||
* } ,
|
||||
* name="source_"
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class SourceApiController extends AbstractAPIController
|
||||
final class SourceController extends AbstractAPIController
|
||||
{
|
||||
/**
|
||||
* @Route(
|
Reference in New Issue
Block a user