我正在尝试为使用synfony4开发的应用程序实现Rest API。 在安装诸如 nelmio / api-doc-bundle (我的composer.json粘贴波纹管)之类的软件包之后,出现以下错误:
InvalidConfigurationException“ nelmio_api_doc”下的无法识别的选项“沙箱,摇摇欲坠”。可用的选项是“区域”, “文档”,“模型”。。
我正试图弄清楚现在发生的事情。 请帮助。
这是我的composer.json:
{
"type": "project",
"license": "proprietary",
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"cocur/slugify": "^3.2",
"dompdf/dompdf": "^0.8.3",
"friendsofsymfony/oauth-server-bundle": "^1.6",
"friendsofsymfony/rest-bundle": "^2.5",
"friendsofsymfony/user-bundle": "~2.0",
"inacho/php-credit-card-validator": "^1.0",
"jms/serializer-bundle": "^3.3",
"nelmio/api-doc-bundle": "^3.4",
"sensio/framework-extra-bundle": "^5.3",
"symfony/apache-pack": "^1.0",
"symfony/asset": "4.2.*",
"symfony/console": "4.2.*",
"symfony/dotenv": "4.2.*",
"symfony/expression-language": "4.2.*",
"symfony/filesystem": "4.2.*",
"symfony/finder": "4.2.*",
"symfony/flex": "^1.1",
"symfony/form": "4.2.*",
"symfony/framework-bundle": "4.2.*",
"symfony/monolog-bundle": "^3.1",
"symfony/orm-pack": "*",
"symfony/process": "4.2.*",
"symfony/security-bundle": "4.2.*",
"symfony/serializer-pack": "*",
"symfony/swiftmailer-bundle": "^3.2",
"symfony/translation": "4.2.*",
"symfony/twig-bundle": "4.2.*",
"symfony/validator": "4.2.*",
"symfony/web-link": "4.2.*",
"symfony/yaml": "4.2.*",
"twig/extensions": "^1.5",
"zircote/swagger-php": "*"
},
"require-dev": {
"symfony/debug-pack": "*",
"symfony/maker-bundle": "^1.0",
"symfony/profiler-pack": "*",
"symfony/test-pack": "*",
"symfony/web-server-bundle": "4.2.*"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"paragonie/random_compat": "2.*",
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "4.2.*"
}
}
}
这是我的neimio_aoi_doc.yaml
nelmio_api_doc:
sandbox:
enabled: true
authentication:
delivery: http
type: bearer
body_format:
formats: [json, form] # array of enabled body formats,
default_format: json
swagger:
api_base_path: /api
swagger_version: "1.2"
api_version: "0.1"
info:
title: API
description: "REST API"
我尝试过:作曲家更新和作曲家安装
答案 0 :(得分:0)
您必须将nelmio/api-doc-bundle
从2.x更新到3.x。
对于2.x版本,您的配置似乎不错。 确保遵循此guide for migration to 3.x。
对于遇到的类似问题,我将sandbox
替换为documentation
。
类似地,通过遵循指南,您可以替换其余部分。
最有可能与以下类似的东西起作用。
nelmio_api_doc:
documentation: #<-- notice this change.
enabled: true
authentication:
delivery: http
type: bearer
body_format:
formats: [json, form] # array of enabled body formats,
default_format: json
api_base_path: /api
swagger_version: "1.2"
info:
title: API
description: "REST API"
version: "0.1" # <-- notice this has been moved.