14
14
namespace ApiPlatform \Core \Swagger \Serializer ;
15
15
16
16
use Symfony \Component \Serializer \Normalizer \CacheableSupportsMethodInterface ;
17
- use Symfony \Component \Serializer \Normalizer \ContextAwareNormalizerInterface ;
18
17
use Symfony \Component \Serializer \Normalizer \NormalizerInterface ;
19
18
20
19
/**
26
25
*
27
26
* @author Vincent Chalamon <[email protected] >
28
27
*/
29
- final class ApiGatewayNormalizer implements ContextAwareNormalizerInterface , CacheableSupportsMethodInterface
28
+ final class ApiGatewayNormalizer implements NormalizerInterface , CacheableSupportsMethodInterface
30
29
{
31
30
const API_GATEWAY = 'api_gateway ' ;
32
31
@@ -44,8 +43,10 @@ public function __construct(NormalizerInterface $documentationNormalizer, $defau
44
43
*/
45
44
public function normalize ($ object , $ format = null , array $ context = [])
46
45
{
47
- unset($ context [self ::API_GATEWAY ]);
48
46
$ data = $ this ->documentationNormalizer ->normalize ($ object , $ format , $ context );
47
+ if (!($ context [self ::API_GATEWAY ] ?? $ this ->defaultContext [self ::API_GATEWAY ])) {
48
+ return $ data ;
49
+ }
49
50
50
51
if (empty ($ data ['basePath ' ])) {
51
52
$ data ['basePath ' ] = '/ ' ;
@@ -108,9 +109,9 @@ public function normalize($object, $format = null, array $context = [])
108
109
/**
109
110
* {@inheritdoc}
110
111
*/
111
- public function supportsNormalization ($ data , $ format = null , array $ context = [] )
112
+ public function supportsNormalization ($ data , $ format = null )
112
113
{
113
- return $ this ->documentationNormalizer ->supportsNormalization ($ data , $ format ) && ( $ context [ self :: API_GATEWAY ] ?? ( $ this -> defaultContext [ self :: API_GATEWAY ] ?? false )) ;
114
+ return $ this ->documentationNormalizer ->supportsNormalization ($ data , $ format );
114
115
}
115
116
116
117
/**
0 commit comments