Laravel php:如何更改POST请求头内容类型
我使用lib:(包含swagger-php+swagger-ui),我需要在上传文件的POST请求中更改标题内容类型(在Laravel-Input::file('photo')中读取它)。我读到我应该在我的招摇过市中添加Laravel php:如何更改POST请求头内容类型,laravel,swagger,swagger-ui,swagger-2.0,swagger-php,Laravel,Swagger,Swagger Ui,Swagger 2.0,Swagger Php,我使用lib:(包含swagger-php+swagger-ui),我需要在上传文件的POST请求中更改标题内容类型(在Laravel-Input::file('photo')中读取它)。我读到我应该在我的招摇过市中添加消耗和产生参数-这就是我所拥有的: /** * * Create Building Photo * * @SWG\Post( * path="/api/v1/buildings/{buildingId}/photo", * security={{"oa
消耗
和产生
参数-这就是我所拥有的:
/**
*
* Create Building Photo
*
* @SWG\Post(
* path="/api/v1/buildings/{buildingId}/photo",
* security={{"oauth2": {"*"}}},
* tags={"building"},
* consumes={"text/plain", "application/json"},
* produces={"text/plain", "application/json"},
* description="Update building",
* @SWG\Parameter(
* name="buildingId",
* in="path",
* description="Building id",
* required=true,
* type="number",
* ),
* @SWG\Parameter(
* name="photo",
* in="formData",
* required=true,
* description="Building photo",
* type="file",
* ),
* @SWG\Response( response=200, description="ok"),
* @SWG\Response( response=404, description="Building not found"),
* )
*
*/
但是在requestContent-type
和Accept
中,我总是得到application/json
,而laravel无法读取上传的文件(当我使用swagger ui生成请求时)。我应该如何更改上述swagger以允许laravel读取由swagger ui生成的输入::文件(“照片”)表单POST请求 这是一个解决方案:
* consumes={"multipart/form-data"},
* produces={"text/plain, application/json"},
:)请在此处找到解决方案 您应该遵循此指导原则,在Laravel中使用Passport身份验证等设置Swagger 下面列出了在实施过程中可能遇到的一些问题
一月份,我自己找到了答案。你能找到另一个答案吗?如果是-请在此处描述我需要一个使用@OA(开放API注释)的解决方案。。它一直在说“意外的字段”会消耗“资源”。