question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error 500 after disabling swagger and docs

See original GitHub issue

API 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:open
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
tekmicommented, May 4, 2020

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.

api_platform:
    title: API Platform
    version: 0.1.0
    mapping:
        paths: ['%kernel.project_dir%/src/Entity']
    patch_formats:
        json: ['application/merge-patch+json']
    swagger:
        versions: [3]

    # Enabling only JSON-LD and JSON formats while disabling HTML format
    formats:
        jsonld:
            mime_types: ['application/ld+json']
        json:
            mime_types: ['application/json']
    
    # Disabling the displaying of the API documentation 
    enable_swagger_ui: false
    enable_re_doc: false
1reaction
Mbogningcommented, Apr 5, 2021

Just add this line to api_platform.yaml

   enable_re_doc: false
Read more comments on GitHub >

github_iconTop Results From Across the Web

500 Error when setting up Swagger in asp .net CORE / MVC 6 ...
An error occoures when writing [Route("api/[controller]")] because swagger doesn't know how to separate the API methods without action inside your route ...
Read more >
I get a 500 response when requesting a certain swagger file ...
HTTP 500 (Internal Server Error) is a generalized error message. To get more specific details regarding those failures, please set logging level ...
Read more >
How to Debug Swagger/Swashbuckle Error 500?
The problem is that all we get back is an error 500 from Swagger/Swashbuckle with no information on why things aren't working.
Read more >
500 Internal Server Error | Apigee Edge
The HTTP status code 500 is a generic error response. It means that the server encountered an unexpected condition that prevented it from...
Read more >
swagger UI 2 can't read the apidocs (500 error) - Google Groups
You received this message because you are subscribed to the Google Groups "Swagger" group. To unsubscribe from this group and stop receiving ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found