Error 500 after disabling swagger and docs
See original GitHub issueAPI Platform version(s) affected: 1.2.1
Description
After disabling the swagger on prod I receive error 500 with the following written to logs:
[2020-04-16 07:45:57] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Serializer\Exception\NotEncodableValueException: "Serialization for the format html is not supported" at /app/vendor/symfony/serializer/Serializer.php line 121 {"exception":"[object] (Symfony\\Component\\Serializer\\Exception\\NotEncodableValueException(code: 0): Serialization for the format html is not supported at /app/vendor/symfony/serializer/Serializer.php:121)"} []
How to reproduce
here’s my config/packages/prod/api_platform.yml config for prod:
api_platform:
enable_swagger: false
enable_swagger_ui: false
enable_re_doc: false
show_webby: false
enable_docs: false
enable_profiler: false
graphql:
enabled: false
collection:
pagination:
items_per_page: 30
mapping:
paths: ['%kernel.project_dir%/src/Entity']
patch_formats:
json: ['application/merge-patch+json']
Here’s conig/routes.yml:
index:
path: /
controller: App\Controller\DefaultController::index
register:
path: /register
controller: App\Controller\AuthController::register
methods: POST
api:
path: /auth
controller: App\Controller\AuthController::api
login_check:
path: /login_check
methods: [POST]
swagger_ui:
path: /docs
controller: api_platform.swagger.action.ui
config/routes/api_platform.yml
api_platform:
resource: .
type: api_platform
prefix: /
Additional Context
I’ve seen
https://github.com/api-platform/core/pull/841
https://github.com/api-platform/api-platform/issues/195
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
I have just experienced a similar issue playing with API Platform Distribution version 2.5.5.
I’ve followed the @dunglas recommendation to disable the HTML format and it started to work! Thank you.
Here is my YAML configuration.
Just add this line to api_platform.yaml