This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Controller; | |
use App\Service\DocumentSchemaService; | |
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | |
use Symfony\Component\HttpFoundation\JsonResponse; | |
use Symfony\Component\Routing\Annotation\Route; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Service; | |
use App\Annotation\DocumentField; | |
use App\DocumentType\IDocument; | |
use Doctrine\Common\Annotations\AnnotationReader; | |
final class DocumentSchemaService |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
#... | |
_instanceof: | |
App\DocumentType\IDocument: | |
tags: ['app.idocument'] | |
#... | |
App\Service\DocumentSchemaService: | |
arguments: | |
- !tagged_iterator app.idocument |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\DocumentType; | |
use App\Annotation\DocumentField; | |
final class Passport implements IDocument | |
{ | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Annotation; | |
use Doctrine\Common\Annotations\Annotation; | |
use Doctrine\Common\Annotations\Annotation\Target; | |
/** | |
* @Annotation | |
* @Target("PROPERTY") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST http://localhost:8000/api/documents | |
Content-Type: application/json | |
{ | |
"payload": { | |
"type": "passport", | |
"firstName": "Ivan", | |
"lastName": "Ivanov", | |
"citizenship": "Russia", | |
"series": "XC", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
use Doctrine\ORM\Mapping\Entity; | |
/** | |
* @Entity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "Person", | |
"firstName": "Ivan", | |
"lastName": "Ivanov" | |
} | |
{ | |
"type": "Company", | |
"name": "ACME Consulting", | |
"city": "Moscow" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// REQUEST | |
{ | |
"year":2017, | |
"vin":"134513879", | |
"plate":"A123AA777", | |
"powerHp":"146.1", | |
"model":"/api/vehicle_models/000b69fa-a335-49d6-b7be-49fbe570376a", | |
"ownerPerson": { | |
"firstName":"Egor" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Entity; | |
use ApiPlatform\Core\Annotation\ApiResource; | |
use DateTimeImmutable; | |
use Doctrine\Common\Collections\ArrayCollection; | |
use Doctrine\Common\Collections\Collection; |
NewerOlder