Fixed API Platform deprecations

This commit is contained in:
Jan Böhmer 2023-10-25 20:40:41 +02:00
parent d0a5b4dcd7
commit 717a9fb0a3
18 changed files with 72 additions and 29 deletions

View file

@ -1 +1 @@
1.8.2 1.9.0-dev

View file

@ -70,6 +70,7 @@
"symfony/runtime": "6.3.*", "symfony/runtime": "6.3.*",
"symfony/security-bundle": "6.3.*", "symfony/security-bundle": "6.3.*",
"symfony/serializer": "6.3.*", "symfony/serializer": "6.3.*",
"symfony/string": "6.3.*",
"symfony/translation": "6.3.*", "symfony/translation": "6.3.*",
"symfony/twig-bundle": "6.3.*", "symfony/twig-bundle": "6.3.*",
"symfony/ux-translator": "^2.10", "symfony/ux-translator": "^2.10",

2
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "a3d850bada24e7349d2181693a50c637", "content-hash": "258be26a5e5d25abc80062849a2a948e",
"packages": [ "packages": [
{ {
"name": "api-platform/core", "name": "api-platform/core",

View file

@ -8,6 +8,8 @@ api_platform:
# eager_loading: # eager_loading:
# max_joins: 100 # max_joins: 100
keep_legacy_inflector: false
swagger: swagger:
api_keys: api_keys:
# overridden in OpenApiFactoryDecorator # overridden in OpenApiFactoryDecorator

View file

@ -26,6 +26,7 @@ namespace App\ApiResource;
use ApiPlatform\Metadata\ApiFilter; use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\Get;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\Serializer\Filter\PropertyFilter; use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\State\PartDBInfoProvider; use App\State\PartDBInfoProvider;
@ -35,7 +36,7 @@ use App\State\PartDBInfoProvider;
#[ApiResource( #[ApiResource(
uriTemplate: '/info.{_format}', uriTemplate: '/info.{_format}',
description: 'Basic information about Part-DB like version, title, etc.', description: 'Basic information about Part-DB like version, title, etc.',
operations: [new Get(openapiContext: ['summary' => 'Get basic information about the installed Part-DB instance.'])], operations: [new Get(openapi: new Operation(summary: 'Get basic information about the installed Part-DB instance.'))],
provider: PartDBInfoProvider::class provider: PartDBInfoProvider::class
)] )]
#[ApiFilter(PropertyFilter::class)] #[ApiFilter(PropertyFilter::class)]

View file

@ -33,6 +33,7 @@ use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link; use ApiPlatform\Metadata\Link;
use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\Serializer\Filter\PropertyFilter; use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\ApiPlatform\Filter\LikeFilter; use App\ApiPlatform\Filter\LikeFilter;
use App\Entity\Parts\Footprint; use App\Entity\Parts\Footprint;
@ -70,7 +71,7 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ApiResource( #[ApiResource(
uriTemplate: '/attachment_types/{id}/children.{_format}', uriTemplate: '/attachment_types/{id}/children.{_format}',
operations: [ operations: [
new GetCollection(openapiContext: ['summary' => 'Retrieves the children elements of an attachment type.'], new GetCollection(openapi: new Operation(summary: 'Retrieves the children elements of an attachment type.'),
security: 'is_granted("@attachment_types.read")') security: 'is_granted("@attachment_types.read")')
], ],
uriVariables: [ uriVariables: [

View file

@ -34,6 +34,7 @@ use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link; use ApiPlatform\Metadata\Link;
use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\Serializer\Filter\PropertyFilter; use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\ApiPlatform\Filter\LikeFilter; use App\ApiPlatform\Filter\LikeFilter;
use App\Entity\Attachments\Attachment; use App\Entity\Attachments\Attachment;
@ -72,8 +73,10 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ApiResource( #[ApiResource(
uriTemplate: '/categories/{id}/children.{_format}', uriTemplate: '/categories/{id}/children.{_format}',
operations: [ operations: [
new GetCollection(openapiContext: ['summary' => 'Retrieves the children elements of a category.'], new GetCollection(
security: 'is_granted("@categories.read")') openapi: new Operation(summary: 'Retrieves the children elements of a category.'),
security: 'is_granted("@categories.read")'
)
], ],
uriVariables: [ uriVariables: [
'id' => new Link(fromProperty: 'children', fromClass: Category::class) 'id' => new Link(fromProperty: 'children', fromClass: Category::class)

View file

@ -34,6 +34,7 @@ use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link; use ApiPlatform\Metadata\Link;
use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\Serializer\Filter\PropertyFilter; use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\ApiPlatform\Filter\LikeFilter; use App\ApiPlatform\Filter\LikeFilter;
use App\Entity\Attachments\Attachment; use App\Entity\Attachments\Attachment;
@ -72,8 +73,10 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ApiResource( #[ApiResource(
uriTemplate: '/footprints/{id}/children.{_format}', uriTemplate: '/footprints/{id}/children.{_format}',
operations: [ operations: [
new GetCollection(openapiContext: ['summary' => 'Retrieves the children elements of a footprint.'], new GetCollection(
security: 'is_granted("@footprints.read")') openapi: new Operation(summary: 'Retrieves the children elements of a footprint.'),
security: 'is_granted("@footprints.read")'
)
], ],
uriVariables: [ uriVariables: [
'id' => new Link(fromProperty: 'children', fromClass: Footprint::class) 'id' => new Link(fromProperty: 'children', fromClass: Footprint::class)

View file

@ -33,6 +33,7 @@ use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link; use ApiPlatform\Metadata\Link;
use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\Serializer\Filter\PropertyFilter; use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\ApiPlatform\Filter\LikeFilter; use App\ApiPlatform\Filter\LikeFilter;
use App\Entity\Attachments\Attachment; use App\Entity\Attachments\Attachment;
@ -71,8 +72,10 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ApiResource( #[ApiResource(
uriTemplate: '/manufacturers/{id}/children.{_format}', uriTemplate: '/manufacturers/{id}/children.{_format}',
operations: [ operations: [
new GetCollection(openapiContext: ['summary' => 'Retrieves the children elements of a manufacturer.'], new GetCollection(
security: 'is_granted("@manufacturers.read")') openapi: new Operation(summary: 'Retrieves the children elements of a manufacturer.'),
security: 'is_granted("@manufacturers.read")'
)
], ],
uriVariables: [ uriVariables: [
'id' => new Link(fromProperty: 'children', fromClass: Manufacturer::class) 'id' => new Link(fromProperty: 'children', fromClass: Manufacturer::class)

View file

@ -33,6 +33,7 @@ use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link; use ApiPlatform\Metadata\Link;
use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\Serializer\Filter\PropertyFilter; use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\ApiPlatform\Filter\LikeFilter; use App\ApiPlatform\Filter\LikeFilter;
use App\Entity\Attachments\Attachment; use App\Entity\Attachments\Attachment;
@ -75,8 +76,10 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ApiResource( #[ApiResource(
uriTemplate: '/footprints/{id}/children.{_format}', uriTemplate: '/footprints/{id}/children.{_format}',
operations: [ operations: [
new GetCollection(openapiContext: ['summary' => 'Retrieves the children elements of a MeasurementUnit.'], new GetCollection(
security: 'is_granted("@measurement_units.read")') openapi: new Operation(summary: 'Retrieves the children elements of a MeasurementUnit.'),
security: 'is_granted("@measurement_units.read")'
)
], ],
uriVariables: [ uriVariables: [
'id' => new Link(fromProperty: 'children', fromClass: MeasurementUnit::class) 'id' => new Link(fromProperty: 'children', fromClass: MeasurementUnit::class)

View file

@ -33,6 +33,7 @@ use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link; use ApiPlatform\Metadata\Link;
use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\Serializer\Filter\PropertyFilter; use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\ApiPlatform\Filter\LikeFilter; use App\ApiPlatform\Filter\LikeFilter;
use App\Entity\Attachments\Attachment; use App\Entity\Attachments\Attachment;
@ -71,8 +72,10 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ApiResource( #[ApiResource(
uriTemplate: '/storage_locations/{id}/children.{_format}', uriTemplate: '/storage_locations/{id}/children.{_format}',
operations: [ operations: [
new GetCollection(openapiContext: ['summary' => 'Retrieves the children elements of a storage location.'], new GetCollection(
security: 'is_granted("@storelocations.read")') openapi: new Operation(summary: 'Retrieves the children elements of a storage location.'),
security: 'is_granted("@storelocations.read")'
)
], ],
uriVariables: [ uriVariables: [
'id' => new Link(fromProperty: 'children', fromClass: Manufacturer::class) 'id' => new Link(fromProperty: 'children', fromClass: Manufacturer::class)

View file

@ -33,6 +33,7 @@ use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link; use ApiPlatform\Metadata\Link;
use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\Serializer\Filter\PropertyFilter; use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\ApiPlatform\Filter\LikeFilter; use App\ApiPlatform\Filter\LikeFilter;
use App\Entity\Attachments\Attachment; use App\Entity\Attachments\Attachment;
@ -75,8 +76,10 @@ use Symfony\Component\Validator\Constraints as Assert;
)] )]
#[ApiResource( #[ApiResource(
uriTemplate: '/suppliers/{id}/children.{_format}', uriTemplate: '/suppliers/{id}/children.{_format}',
operations: [new GetCollection(openapiContext: ['summary' => 'Retrieves the children elements of a supplier'], operations: [new GetCollection(
security: 'is_granted("@manufacturers.read")')], openapi: new Operation(summary: 'Retrieves the children elements of a supplier.'),
security: 'is_granted("@manufacturers.read")'
)],
uriVariables: [ uriVariables: [
'id' => new Link(fromClass: Supplier::class, fromProperty: 'children') 'id' => new Link(fromClass: Supplier::class, fromProperty: 'children')
], ],

View file

@ -33,6 +33,7 @@ use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link; use ApiPlatform\Metadata\Link;
use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\Serializer\Filter\PropertyFilter; use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\ApiPlatform\Filter\LikeFilter; use App\ApiPlatform\Filter\LikeFilter;
use App\Entity\Attachments\Attachment; use App\Entity\Attachments\Attachment;
@ -75,8 +76,10 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ApiResource( #[ApiResource(
uriTemplate: '/currencies/{id}/children.{_format}', uriTemplate: '/currencies/{id}/children.{_format}',
operations: [ operations: [
new GetCollection(openapiContext: ['summary' => 'Retrieves the children elements of a currency.'], new GetCollection(
security: 'is_granted("@currencies.read")') openapi: new Operation(summary: 'Retrieves the children elements of a currency.'),
security: 'is_granted("@currencies.read")'
)
], ],
uriVariables: [ uriVariables: [
'id' => new Link(fromProperty: 'children', fromClass: Currency::class) 'id' => new Link(fromProperty: 'children', fromClass: Currency::class)

View file

@ -34,6 +34,7 @@ use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link; use ApiPlatform\Metadata\Link;
use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\Serializer\Filter\PropertyFilter; use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\ApiPlatform\Filter\LikeFilter; use App\ApiPlatform\Filter\LikeFilter;
use Doctrine\DBAL\Types\Types; use Doctrine\DBAL\Types\Types;
@ -73,8 +74,10 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ApiResource( #[ApiResource(
uriTemplate: '/parts/{id}/orderdetails.{_format}', uriTemplate: '/parts/{id}/orderdetails.{_format}',
operations: [ operations: [
new GetCollection(openapiContext: ['summary' => 'Retrieves the orderdetails of a part.'], new GetCollection(
security: 'is_granted("@parts.read")') openapi: new Operation(summary: 'Retrieves the orderdetails of a part.'),
security: 'is_granted("@parts.read")'
)
], ],
uriVariables: [ uriVariables: [
'id' => new Link(toProperty: 'part', fromClass: Part::class) 'id' => new Link(toProperty: 'part', fromClass: Part::class)

View file

@ -33,6 +33,7 @@ use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link; use ApiPlatform\Metadata\Link;
use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\Serializer\Filter\PropertyFilter; use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\ApiPlatform\Filter\LikeFilter; use App\ApiPlatform\Filter\LikeFilter;
use App\Entity\Attachments\Attachment; use App\Entity\Attachments\Attachment;
@ -74,8 +75,10 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
#[ApiResource( #[ApiResource(
uriTemplate: '/projects/{id}/children.{_format}', uriTemplate: '/projects/{id}/children.{_format}',
operations: [ operations: [
new GetCollection(openapiContext: ['summary' => 'Retrieves the children elements of a project.'], new GetCollection(
security: 'is_granted("@projects.read")') openapi: new Operation(summary: 'Retrieves the children elements of a project.'),
security: 'is_granted("@projects.read")'
)
], ],
uriVariables: [ uriVariables: [
'id' => new Link(fromProperty: 'children', fromClass: Project::class) 'id' => new Link(fromProperty: 'children', fromClass: Project::class)

View file

@ -32,6 +32,7 @@ use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link; use ApiPlatform\Metadata\Link;
use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\Serializer\Filter\PropertyFilter; use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\ApiPlatform\Filter\LikeFilter; use App\ApiPlatform\Filter\LikeFilter;
use App\Validator\UniqueValidatableInterface; use App\Validator\UniqueValidatableInterface;
@ -69,8 +70,10 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
#[ApiResource( #[ApiResource(
uriTemplate: '/projects/{id}/bom.{_format}', uriTemplate: '/projects/{id}/bom.{_format}',
operations: [ operations: [
new GetCollection(openapiContext: ['summary' => 'Retrieves the BOM entries of the given project.'], new GetCollection(
security: 'is_granted("@projects.read")') openapi: new Operation(summary: 'Retrieves the BOM entries of the given project.'),
security: 'is_granted("@projects.read")'
)
], ],
uriVariables: [ uriVariables: [
'id' => new Link(fromProperty: 'bom_entries', fromClass: Project::class) 'id' => new Link(fromProperty: 'bom_entries', fromClass: Project::class)

View file

@ -26,6 +26,7 @@ namespace App\Entity\UserSystem;
use ApiPlatform\Metadata\ApiFilter; use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\Get;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\Serializer\Filter\PropertyFilter; use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\Entity\Base\AbstractNamedDBElement; use App\Entity\Base\AbstractNamedDBElement;
use App\Entity\Base\TimestampTrait; use App\Entity\Base\TimestampTrait;
@ -46,7 +47,9 @@ use Symfony\Component\Validator\Constraints\NotBlank;
#[ApiResource( #[ApiResource(
uriTemplate: '/tokens/current.{_format}', uriTemplate: '/tokens/current.{_format}',
description: 'A token used to authenticate API requests.', description: 'A token used to authenticate API requests.',
operations: [new Get(openapiContext: ['summary' => 'Get information about the API token that is currently used.'])], operations: [new Get(
openapi: new Operation(summary: 'Get information about the API token that is currently used.'),
)],
normalizationContext: ['groups' => ['token:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'], normalizationContext: ['groups' => ['token:read', 'api:basic:read'], 'openapi_definition_name' => 'Read'],
provider: CurrentApiTokenProvider::class, provider: CurrentApiTokenProvider::class,
)] )]

View file

@ -31,6 +31,7 @@ use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Post;
use ApiPlatform\OpenApi\Model\Operation;
use ApiPlatform\Serializer\Filter\PropertyFilter; use ApiPlatform\Serializer\Filter\PropertyFilter;
use App\ApiPlatform\Filter\LikeFilter; use App\ApiPlatform\Filter\LikeFilter;
use App\Entity\Attachments\Attachment; use App\Entity\Attachments\Attachment;
@ -86,10 +87,14 @@ use Jbtronics\TFAWebauthn\Model\TwoFactorInterface as WebauthnTwoFactorInterface
#[ApiResource( #[ApiResource(
shortName: 'User', shortName: 'User',
operations: [ operations: [
new Get(openapiContext: ['summary' => 'Get a specific user.'], new Get(
security: 'is_granted("read", object)'), openapi: new Operation(summary: 'Get information about the current user.'),
new GetCollection(openapiContext: ['summary' => 'Get all users defined in the system.'], security: 'is_granted("read", object)'
security: 'is_granted("@users.read")'), ),
new GetCollection(
openapi: new Operation(summary: 'Get all users defined in the system.'),
security: 'is_granted("@users.read")'
),
], ],
normalizationContext: ['groups' => ['user:read'], 'openapi_definition_name' => 'Read'], normalizationContext: ['groups' => ['user:read'], 'openapi_definition_name' => 'Read'],
)] )]