"Serialization for the format "html" is not supported" when loading the API doc

Viewed 939

I created a new Symfony 5.3 project and installed API-Platform. When I load the API Doc at /api, I get an error :

Symfony\Component\Serializer\Exception\NotEncodableValueException : Serialization for the format "html" is not supported.

I tried to add the html format to the api_platform.yml config file:

api_platform:
    mapping:
        paths: ['%kernel.project_dir%/src/Entity']
    patch_formats:
        json: ['application/merge-patch+json']
    formats:
        json:   ['application/json']
        html: ['text/html']
    swagger:
        versions: [3]

I don't know what to do to access the API Documentation.

1 Answers

Do you have twig bundle enabled

// config/bundles.php
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],

and maybe you didn't enabled doc generation so in your

// config/packages/api_platform.yaml
  enable_swagger: true
  enable_swagger_ui: true
  enable_re_doc: true
  enable_entrypoint: true
  enable_docs: true

this resolved my problem

Related