api-platform / core

The server component of API Platform: hypermedia and GraphQL APIs in minutes
https://api-platform.com
MIT License
2.45k stars 875 forks source link

Configuration `enable_docs: false` trigger a RouteNotFoundException #6018

Closed webda2l closed 11 months ago

webda2l commented 11 months ago

API Platform version(s) affected: 3.2.7

Description
Configuration enable_docs: false trigger a RouteNotFoundException.

Symfony\Component\Routing\Exception\RouteNotFoundException
Unable to generate a URL for the named route "api_doc" as such route does not exist.

How to reproduce

api_platform:
    version: 1.0.0
    formats:
        json: ['application/json']
        jsonld: ['application/ld+json']
    docs_formats:
        jsonld: ['application/ld+json']
        jsonopenapi: ['application/vnd.openapi+json']
        html: ['text/html']
    defaults:
        stateless: true
        graphql_operations: []
        operations: []
        pagination_items_per_page: 10
        pagination_client_items_per_page: true
        cache_headers:
            vary: ['Content-Type', 'Authorization', 'Origin']
        extra_properties:
            standard_put: true
            rfc_7807_compliant_errors: true
    event_listeners_backward_compatibility_layer: false
    keep_legacy_inflector: false
    graphql:
        graphql_playground:
            enabled: false

when@prod:
    api_platform:
        enable_docs: false
        graphql:
            graphiql:
                enabled: false

Possible Solution
For now, until better

api_platform:
    version: 1.0.0
    formats:
        json: ['application/json']
        jsonld: ['application/ld+json']
    docs_formats:
        jsonld: ['application/ld+json']
        jsonopenapi: ['application/vnd.openapi+json']
        html: ['text/html']
    defaults:
        stateless: true
        graphql_operations: []
        operations: []
        pagination_items_per_page: 10
        pagination_client_items_per_page: true
        cache_headers:
            vary: ['Content-Type', 'Authorization', 'Origin']
        extra_properties:
            standard_put: true
            rfc_7807_compliant_errors: true
    event_listeners_backward_compatibility_layer: false
    keep_legacy_inflector: false
    graphql:
        graphql_playground:
            enabled: false

when@prod:
    api_platform:
        enable_swagger: false
        enable_swagger_ui: false
        enable_re_doc: false
        enable_entrypoint: false
        # enable_docs: false
        graphql:
            graphiql:
                enabled: false

Additional Context

webda2l commented 11 months ago

Duplicate https://github.com/api-platform/core/issues/5528 https://github.com/api-platform/core/pull/5862