首页  >  问答  >  正文

在 API 平台上停用 Swagger UI

我试图禁用 Swagger UI,或更准确地说,因为我希望我们仅为非产品环境提供它。

我引用了此链接,但是没有任何反应。

我的 api_platform.yaml 文件:

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 天前315

全部回复(1)我来回复

  • 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

    你的 api_platform.yaml 看起来像这样。如果您正确使用环境,那么您的 swagger 仅在您的产品环境中被禁用。

    回复
    0
  • 取消回复