symfony - 缺少 Swagger/api 文档的参数
问题描述
在我的 symfony 项目 4.1 上将 nelmio api doc 从 3.0 更新到 3.1/3.3 时出现问题。我无法访问可以在请求中发送到 API 服务的参数,我不明白。不管是用$request->attributes->all()、$request->query->all()还是$request->request->all(),我从来没有我的参数,但是在3.0版本中,它可以工作
我尝试清除缓存,更改参数类型,它不起作用:(
我的 symfony 项目中的 nelmio api doc 包有这个配置
nelmio_api_doc:
documentation:
info:
title: Project
description: description
version: 1.0.0
securityDefinitions:
api_key:
type: apiKey
description: Json Web Token
name: Authorization
in: header
security:
- api_key: []
models: { use_jms: true }
我的控制器中的示例注释:
@SWG\Parameter(
* name="email",
* in="formData",
* description="The user email",
* required=true,
* type="string"
* ),
* @SWG\Parameter(
* name="password",
* in="formData",
* description="The user password",
* required=true,
* type="string"
* ),
请问有人有解决办法吗?谢谢 !
解决方案
你可以试试这个注释:
/**
* @SWG\Post(
* path="/api/path",
* summary="Post to URL",
* @SWG\Parameter(
* name="body",
* in="body",
* required=true,
* @SWG\Schema(
* @SWG\Property(
* property="email",
* type="string"
* ),
* @SWG\Property(
* property="password",
* type="string"
* )
* )
* )
* )
*/
推荐阅读
- parsing - Prolog - 使用一元减号时解析器失败
- java - Java 8 Stream 将列表转换为映射,其中映射键是从列表的两个字段派生的对象?
- javascript - 单击外部菜单时关闭下拉菜单
- python - Python; 解析文本文件
- python - Python 3.7 不能使用 DOCPLEX
- python - pip 无法导入 Cython 但 python setup.py install 可以
- python - 如何将基于数据驱动的基于位置的热图添加到某些图像?
- ip - 如何从服务器获取 Arduino esp 8266 的答案
- python - Groupby 在 pandas 中聚合和转置
- r - 数据提取到excel文件