@@ -43,8 +43,6 @@ final class SchemaFactory implements SchemaFactoryInterface, SchemaFactoryAwareI
4343 use ResourceMetadataTrait;
4444 use SchemaUriPrefixTrait;
4545
46- private const JSON_MERGE_PATCH_SCHEMA_POSTFIX = '.jsonMergePatch ' ;
47-
4846 private ?SchemaFactoryInterface $ schemaFactory = null ;
4947 // Edge case where the related resource is not readable (for example: NotExposed) but we have groups to read the whole related object
5048 public const OPENAPI_DEFINITION_NAME = 'openapi_definition_name ' ;
@@ -83,7 +81,6 @@ public function buildSchema(string $className, string $format = 'json', string $
8381
8482 $ validationGroups = $ operation ? $ this ->getValidationGroups ($ operation ) : [];
8583 $ version = $ schema ->getVersion ();
86- $ definitionName = $ this ->definitionNameFactory ->create ($ className , $ format , $ inputOrOutputClass , $ operation , $ serializerContext );
8784 $ method = $ operation instanceof HttpOperation ? $ operation ->getMethod () : 'GET ' ;
8885 if (!$ operation ) {
8986 $ method = Schema::TYPE_INPUT === $ type ? 'POST ' : 'GET ' ;
@@ -95,9 +92,12 @@ public function buildSchema(string $className, string $format = 'json', string $
9592 }
9693
9794 $ isJsonMergePatch = 'json ' === $ format && 'PATCH ' === $ method && Schema::TYPE_INPUT === $ type ;
98- if ($ isJsonMergePatch ) {
99- $ definitionName .= self ::JSON_MERGE_PATCH_SCHEMA_POSTFIX ;
100- }
95+ $ definitionFormat = match (true ) {
96+ default => $ format ,
97+ $ isJsonMergePatch => 'merge-patch+json ' ,
98+ };
99+
100+ $ definitionName = $ this ->definitionNameFactory ->create ($ className , $ definitionFormat , $ inputOrOutputClass , $ operation , $ serializerContext );
101101
102102 if (!isset ($ schema ['$ref ' ]) && !isset ($ schema ['type ' ])) {
103103 $ ref = $ this ->getSchemaUriPrefix ($ version ).$ definitionName ;
0 commit comments