Allow JSON media type + POST for Building (WIP)
This commit is contained in:
parent
32ad965139
commit
09ebe7dded
@ -2,6 +2,11 @@ api_platform:
|
|||||||
title: Architetture Roma - API
|
title: Architetture Roma - API
|
||||||
version: beta
|
version: beta
|
||||||
show_webby: false
|
show_webby: false
|
||||||
|
formats:
|
||||||
|
json:
|
||||||
|
mime_types: ['application/json']
|
||||||
|
jsonld:
|
||||||
|
mime_types: ['application/ld+json']
|
||||||
defaults:
|
defaults:
|
||||||
stateless: true
|
stateless: true
|
||||||
cache_headers:
|
cache_headers:
|
||||||
|
@ -4,6 +4,7 @@ namespace App\Entity;
|
|||||||
|
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
use ApiPlatform\Metadata\Get;
|
use ApiPlatform\Metadata\Get;
|
||||||
|
use ApiPlatform\Metadata\Post;
|
||||||
use ApiPlatform\Metadata\GetCollection;
|
use ApiPlatform\Metadata\GetCollection;
|
||||||
use App\Repository\BuildingRepository;
|
use App\Repository\BuildingRepository;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
@ -14,7 +15,9 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
|||||||
#[ApiResource(
|
#[ApiResource(
|
||||||
operations: [
|
operations: [
|
||||||
new Get(normalizationContext: ['groups' => 'building:item']),
|
new Get(normalizationContext: ['groups' => 'building:item']),
|
||||||
new GetCollection(normalizationContext: ['groups' => 'building:list'])
|
new GetCollection(normalizationContext: ['groups' => 'building:list']),
|
||||||
|
// TODO Security!!
|
||||||
|
new Post(),
|
||||||
],
|
],
|
||||||
order: ['name' => 'DESC'],
|
order: ['name' => 'DESC'],
|
||||||
paginationEnabled: false,
|
paginationEnabled: false,
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace App\Entity;
|
namespace App\Entity;
|
||||||
|
|
||||||
use ApiPlatform\Metadata\ApiResource;
|
use ApiPlatform\Metadata\ApiResource;
|
||||||
|
use ApiPlatform\Metadata\ApiProperty;
|
||||||
use ApiPlatform\Metadata\Get;
|
use ApiPlatform\Metadata\Get;
|
||||||
use ApiPlatform\Metadata\GetCollection;
|
use ApiPlatform\Metadata\GetCollection;
|
||||||
use App\Repository\ElementRepository;
|
use App\Repository\ElementRepository;
|
||||||
@ -42,8 +43,9 @@ class Element
|
|||||||
|
|
||||||
#[ORM\Column(name: 'materiale', type: Types::BIGINT, nullable: true)]
|
#[ORM\Column(name: 'materiale', type: Types::BIGINT, nullable: true)]
|
||||||
#[ORM\ManyToOne(targetEntity: Material::class)]
|
#[ORM\ManyToOne(targetEntity: Material::class)]
|
||||||
#[JoinColumn(name: 'materiale', referencedColumnName: 'id')]
|
#[ORM\JoinColumn(name: 'materiale', referencedColumnName: 'id')]
|
||||||
#[Groups(['element:list', 'element:item'])]
|
#[Groups(['element:list', 'element:item'])]
|
||||||
|
#[ApiProperty(uriTemplate: '/materials/{id}')]
|
||||||
private ?string $material = null;
|
private ?string $material = null;
|
||||||
|
|
||||||
#[ORM\Column(name: 'lavorazione', type: Types::BIGINT, nullable: true)]
|
#[ORM\Column(name: 'lavorazione', type: Types::BIGINT, nullable: true)]
|
||||||
|
Loading…
Reference in New Issue
Block a user