We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I had to use versioning-bundle on ApliPlatform so I had to create simple normalizer for that.
use ApiPlatform\Core\Documentation\Documentation; use ApiPlatform\Core\Swagger\Serializer\DocumentationNormalizer; use Shivas\VersioningBundle\Service\VersionManager; use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface; use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; class SwaggerVersionNormalizer implements NormalizerInterface, NormalizerAwareInterface { use NormalizerAwareTrait; public const ALREADY_CALLED = 'SWAGGER_DECORATOR_NORMALIZER_ALREADY_CALLED'; /** @var VersionManager */ private $versionManager; public function __construct(VersionManager $versionManager) { $this->versionManager = $versionManager; } /** * @param Documentation $object * @param string $format * @param array $context * @return array * @throws \Psr\Cache\InvalidArgumentException * @throws \Symfony\Component\Serializer\Exception\ExceptionInterface */ public function normalize($object, $format = null, array $context = []): array { $context[self::ALREADY_CALLED] = true; $result = $this->normalizer->normalize($object, $format, $context); if (isset($result['info'])) { $result['info']['version'] = $this->versionManager->getVersion()->getVersionString(); } return $result; } /** * {@inheritdoc} */ public function supportsNormalization($data, $format = null, array $context = []) { if (isset($context[self::ALREADY_CALLED])) { return false; } return DocumentationNormalizer::FORMAT === $format && $data instanceof Documentation; } }
I think it can be helpful for someone.
The text was updated successfully, but these errors were encountered:
@michnaadam33 thanks I was looking for something like this :)
Sorry, something went wrong.
No branches or pull requests
I had to use versioning-bundle on ApliPlatform so I had to create simple normalizer for that.
I think it can be helpful for someone.
The text was updated successfully, but these errors were encountered: