github api-platform/core v5.1.0-alpha.1

pre-releaseone hour ago

API Platform 5.1 contains every change shipped in the v5.0.x releases, plus the changes below.

Notes

  • JSON:API: a PATCH or PUT whose data.id does not match the endpoint now returns 409 Conflict, as the specification requires; it used to be applied to the endpoint's resource (#8752). With jsonapi.strict_resource_type enabled, a mismatched data.type also returns 409 on PATCH and PUT, not only on POST.
  • JSON:API: jsonapi.strict_member_names (off by default) exposes the id and type properties as resourceId and resourceType attributes instead of _id and _type, which are not valid member names, and stops renaming links, relationships and included (#8752).
  • Resource polymorphism: with serializer.discriminator_map enabled (Laravel: api-platform.serializer.discriminator_map), the subtypes declared in the serializer #[DiscriminatorMap] of a resource are read, written and documented. An update never changes the subtype: a PUT or PATCH with another type, or a JSON-LD @type contradicting the type property, returns a 422. A subtype that is not a resource is named after its class short name in JSON-LD and Hydra: declare it as a resource (e.g. #[ApiResource(operations: [])]) to give it another name or types. GraphQL is not supported yet for these resources: the default GraphQL operations are dropped, explicit graphQlOperations throw. Off by default (#8874).
  • GraphQL: properties typed as a list of bool, int, float or string are now exposed as [Boolean], [Int], [Float] and [String] instead of the Iterable scalar; dictionaries and lists of other types still use Iterable, so schemas and clients using these fields must be updated (#8619).
  • JSON Schema: properties typed with a PHPDoc array{...} shape are now documented as objects with properties and required instead of a generic object or array (#8767).
  • JSON Schema: api_platform.json_schema.generator (off by default, Symfony only) builds JSON Schemas with the symfony/json-schema component, which must be installed. It is experimental and also covers Hydra schemas and discriminator maps. See the upgrade guide (#8683).
  • Serializer: the api_merge_patch_maps denormalization context option (off by default) merges the string-keyed map properties of a resource on PATCH instead of replacing them: a null value removes the key and nested maps are merged recursively (#8921).
  • Mercure: mercure.resolve_resource_objects (off by default) publishes one update per resource that exposes the persisted object, for example resources using stateOptions. The resource objects are found by api_platform.state.resource_object_resolver. The HTTP cache purge listener resolves them without any option (#8868).
  • OpenAPI: an operation that sets a uriTemplate and shares a route can opt in to documenting its uriTemplate as the path instead of the path of the route, with the openapi_use_uri_template extra property set to true. It is off by default (#8920).
  • Doctrine ORM, Doctrine ODM and Laravel: DateFilter values are now validated by the parameter validation. A request with a DateFilter parameter that has an unknown operator, no operator, an array value, or a null or empty value now returns a 422 with a violation on the parameter, where the value used to be accepted or ignored. The filter schema is a closed object listing after, before, strictly_after and strictly_before (Laravel: eq, gt, lt, gte and lte), and each OpenAPI parameter now declares a scalar schema. This applies whenever parameter validation is enabled (#8927, #8926).
  • Laravel: api-platform.swagger_ui.extra_configuration merges options into the Swagger UI configuration object. It is commented out in the published configuration (#8890).
  • Swagger UI: scripts running before the load event can push plugins to window.apiPlatformSwaggerUiPlugins, and Laravel includes the optional api-platform::swagger-ui-stylesheet and api-platform::swagger-ui-javascript views when they exist (#8891).
  • HTTP cache: when http_cache.invalidation and doctrine_mongodb_odm are enabled, a purge listener for Doctrine MongoDB ODM is registered, as the ORM one already was (#8733).

Breaking changes

  • eb915e2a1 fix(jsonapi)!: drop non-spec type member from error objects (#8732)
  • JSON:API error objects no longer carry a top-level type member; read links.type instead (#8732).

Deprecations

  • Parameters are now immutable: Parameter::setValue() and Parameters::add(), remove() and sort() are deprecated and will be removed in 6.0. Use Parameter::withValue() and Parameters::with(), without() and sorted(), which return a new instance. A parameter provider returns the resolved Parameter (or an operation holding it) instead of mutating the one it receives; ParameterProviderInterface::provide() may now return Operation|Parameter|null.
  • The compositeIdentifier argument of ApiResource has no effect and is deprecated, it will be removed in 6.0. Set compositeIdentifier on a Link instead (#8695).
  • The queryParameterValidate resource and operation option has no effect and is deprecated, it will be removed in 6.0. Use queryParameterValidationEnabled instead (#8763).

Features

  • 60468f194 feat(jsonschema): generate schemas with symfony/json-schema (#8683)
  • a78f351f6 feat(serializer): resource polymorphism (#8884)
  • 2ef1b418e feat(metadata): add SubtypeResolver (#8883)
  • 2c01934f8 feat(jsonschema): document discriminator maps as oneOf (#8885)
  • 7e92ef19b feat(graphql): skip resources with a discriminator map (#8888)
  • 68d3133e0 feat(jsonld): expand IRIs in @type discriminators (#8878)
  • 05dc10c3b feat(doctrine): add SubtypeFilter to filter on subclass properties (ORM) (#8651)
  • d430f9afd feat(symfony): ApiOperation attribute on controllers (#8628)
  • 5dd8bcd36 feat(metadata): immutable parameters (#8855)
  • de7751eec feat(metadata): add canonicalUriTemplate to resources and HTTP operations (#8479)
  • 61b0fc4d8 feat(httpcache): introduce PurgeTagProviderInterface extension point (#7970)
  • d4afa5857 feat(symfony,laravel): hook to register Swagger UI plugins (#8891)
  • 7412ee884 feat(jsonld): operations as schema.org actions
  • 2d692a6f8 feat(jsonld): potentialAction operation option
  • 9090a0dbd feat(jsonapi): spec-compliant PATCH conflicts and member names (#8752)
  • bcb592abe feat(jsonapi): opt-in strict resource type check on write (#8739)
  • 23c4876d1 feat(doctrine): add an input format to DateFilter (#8678)
  • 70abf9361 feat(metadata): add ScalarHeaderParameter (#8679)
  • 6f77a4d70 feat(openapi): accept Tag objects in operation tags (#8618)
  • d067679df feat(hydra): hydra:title from property jsonldContext (#8616)
  • 2c956d173 feat(metadata): ResponseHeaderParameter for declaring HTTP response headers (#7875)
  • 557623c16 feat(hydra): normalize Hydra\Collection objects (#8539)
  • e22e9210e feat(symfony): map ForeignKeyConstraintViolationException to 409 by default (#8548)
  • 16fdcd82b feat(openapi): add openapi_use_uri_template for shared routes (#8920)
  • b8f4d7e08 feat(serializer): merge-patch string-keyed maps (api_merge_patch_maps) (#8921)
  • aeb298249 feat(state): resolve resource objects for purge and Mercure (#8868)
  • 6767a7d1a feat(laravel): validate DateFilter values (#8926)
  • 0f9a6a075 feat(doctrine): validate DateFilter values (#8927)
  • 4c95cfeb1 feat(laravel): swagger_ui.extra_configuration option (#8890)
  • b42652b95 feat(httpcache): add doctrine mongodb odm purge listener (#8733)
  • 721a90a41 feat(hal): templated item links in the entrypoint (#8795)
  • 1d4592b37 feat(symfony): preserve voter reasons for link security denials (#8682)
  • 6513bd1d8 feat(jsonschema): describe PHPDoc array shapes as objects (#8767)
  • af3437556 feat(graphql): map scalar arrays to typed lists (#8619)
  • cec0a65a4 feat(metadata): deprecate the compositeIdentifier argument of ApiResource (#8695)

Bug fixes

Don't miss a new core release

NewReleases is sending notifications on new releases.