我试图禁用 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 Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
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 仅在您的产品环境中被禁用。