Home  >  Q&A  >  body text

Disable Swagger UI on API Platform

I'm trying to disable the Swagger UI, or more precisely, because I want us to provide it only for non-production environments.

I referenced this link, but nothing happened.

My api_platform.yaml File:

api_platform:
  defaults:
    route_prefix: '/%env(API_ROUTE)%'
    enable_docs: false
    enable_entrypoint: false
    enable_swagger_ui: false
  swagger:
    api_keys:
      JWT:
        name: Authorization
        type: header
  collection:
    pagination:
      enabled: true

P粉176151589P粉176151589171 days ago314

reply all(1)I'll reply

  • P粉729436537

    P粉7294365372024-04-05 10:12:42

    api_platform:
      defaults:
        route_prefix: '/%env(API_ROUTE)%'
      swagger:
        api_keys:
          JWT:
            name: Authorization
            type: header
      collection:
        pagination:
          enabled: true
        
    when@prod:
        api_platform:
            enable_docs: false
            enable_entrypoint: false
            enable_swagger_ui: false

    Your api_platform.yaml will look like this. If you use the environment correctly then your swagger will only be disabled in your production environment.

    reply
    0
  • Cancelreply