在API Platform更新后,可能会出现Swagger页面无法加载或无法执行动作的问题。解决方法是在项目根目录下运行以下命令来安装missing swagger-ui依赖项:
$ composer require swagger-api/swagger-ui "^3.28"
然后在项目配置文件中添加以下内容:
# config/packages/api_platform.yaml
api_platform:
swagger:
api_keys:
apiKey: { }
ui:
enabled: true
# Uncomment to set a specific url for the Swagger UI bundle
# url: '%swagger_ui_url%'
# Uncomment to enable a specific Swagger specification url (by default, all Swagger specifications are enabled)
# show_swagger_uit here: '%kernel.environment%'
保存更改并重新启动项目,应该可以正常访问Swagger页面。