Download the PHP package krak/api-platform-extra without Composer
On this page you can find all versions of the php package krak/api-platform-extra. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download krak/api-platform-extra
More information about krak/api-platform-extra
Files in krak/api-platform-extra
Package api-platform-extra
Short Description API Platform Extra Goodies.
License MIT
Homepage https://github.com/krakphp/api-platform-extra
Informations about the package api-platform-extra
API Platform Extra
API Platform Extra includes additional features or bug fixes into API Platform that haven't been released or won't be released.
Installation
Install with composer at krak/api-platform-extra
.
Usage
By default all functionality provided by this library is opt-in, so you'll need to explicitly enable each feature in the config to make use of the features.
MessageBusDataPersister
The message bus data persister is enabled by default and controlled via the following config:
The MessageBusDataPersister
will push any messages that aren't handled by the standard data persisters into the message bus.
So the only thing you need to do is simply just register message handlers for the ApiPlatform resources you want to handle via the message bus.
Additional Swagger Documentation
This allows you to merge and override in any additional swagger documentation to the generated swagger documentation from API Platform. This is useful if you need to provide any custom endpoints outside of your defined API Platform resources.
The configuration for defining the swagger file is here:
If that file exists, the additional swagger documentation will be merged. Else, nothing will happen.
Plural Data Path Segment Name Generator
By default, API Platform's inflector will transport any resource ending with Data
as Datas
. This fixes this specific use case, and could possibly extended to adjust multiple inflection fixes.
Constructor Denormalizer
This issue has actually been fixed but is pending release https://github.com/api-platform/core/pull/2178. This library will include that patch until api platform 2.4.0 is released.
This basically allows you to use constructor arguments with nested entities like so:
The actual POST API request for this would look like:
Operation Resource Classes
This feature is controlled via the following configuration:
When enabled, this will allow with very simple configuration, the ability to define a specific resource class per operation. This is especially useful on POST collection operations where you want to use a special DTO resource instead of the actual Entity resource.
Here's how you'd set it up:
Then, you can configure the resources with the following yaml. You could use annotations or xml, but I find it more manageable to use yaml than either:
This will make sure the documentation and the API use the schema of the CreateBookRequest
instead of the normal Book
entity schema. Using the schema_only
attribute for the DTO ensures that no paths will be generated for that resource.
You'll need to make sure the Message Bus Data Persister is enabled so that the wiring of the Request to the CreateBook
Service is done properly.
Definition Only Resources
There may be certain Resources that you want to only use for definitions, but use custom endpoints/swagger docs around them, to do that, you can just use the schema_only: true
attribute.
ApiProperty Override
Any definitions in the ApiProperty annotation do not override changes made from the Serializer Property Metadata Factory. You can control the ability for ApiProperty to override with the following option:
All versions of api-platform-extra with dependencies
symfony/config Version ^4.4|^5.0
symfony/dependency-injection Version ^4.4|^5.0
symfony/http-kernel Version ^4.4|^5.0
symfony/yaml Version ^4.4|^5.0