【问题标题】:empty response from a swagger post call with RequestBody来自带有 RequestBody 的招摇后呼叫的空响应
【发布时间】:2022-01-27 02:27:19
【问题描述】:

我正在尝试使用 DarkaOnLine 在帖子中大摇大摆地打电话 / L5-大摇大摆。这是我控制器中的代码:

/**
 * @OA\Post(
 *     path="/api/send",
 *     summary="Use to sign",
 *     description="Use send a contract to sign with eSign",
 *     operationId="MpProjects.active",
 *     tags={"Projects"},
 *     security={{"passport":{}}},
 * 
 *     @OA\RequestBody(
 *         @OA\MediaType(
 *             mediaType="raw",
 *             @OA\Schema(
 *                 type="object",
 * 
 *                 @OA\Property(
 *                     property="Name",
 *                     description="Contract name",
 *                     example="Prova Contratto",
 *                     type="string"
 *                 ),
 *                 @OA\Property(
 *                     property="EmailSubject",
 *                     description="EmailSubject",
 *                     example="Firma contratto di prova",
 *                     type="string"
 *                 ),
 *                 @OA\Property(
 *                     property="RecipientEmail",
 *                     description="RecipientEmail",
 *                     example="email@gmail.com",
 *                     type="string"
 *                 ),
 *                 @OA\Property(
 *                     property="FirstName",
 *                     description="FirstName",
 *                     example="Gabriele",
 *                     type="string"
 *                 ),
 *                 @OA\Property(
 *                     property="LastName",
 *                     description="LastName",
 *                     example="Alessi",
 *                     type="string"
 *                 ),
 *                 @OA\Property(
 *                     property="PhoneMobile",
 *                     description="PhoneMobile",
 *                     example="+393333333333",
 *                     type="string"
 *                 ),
 *                 @OA\Property(
 *                     property="Pdf",
 *                     description="Pdf",
 *                     example="base64PDF",
 *                     type="string"
 *                 )
 *             )
 *          )
 *     ),
 *     @OA\Response(
 *         response=200,
 *         description="Operation successful",
 *         @OA\MediaType(
 *             mediaType="application/json"
 *         )
 *     ),
 *
 *     @OA\Response(
 *         response=204,
 *         description="Empty response",
 *         @OA\MediaType(
 *             mediaType="application/json"
 *         )
 *     )
 * )
 */
  public function sendDoc(Request $request){
    return $request;
 }

这是正文在 /documentation 上的显示方式: 但它返回一个带有此响应标头的空数组:

我认为问题出在 Curl 上,但我不明白究竟在哪里。 请求正文是否以正确的方式制作? 我尝试了与 postaman 相同的调用,使用与 body 相同的 json,它可以工作...

我只需要查看身体是否到达控制器以及它是如何制作的,以便我可以处理它。

【问题讨论】:

  • 我不知道如何使用 laravel 和 swagger,前段时间我用 symfony 实现了 swagger。无论如何,我认为您需要阅读请求正文并返回响应对象。 stackoverflow.com/a/28587288/2209876
  • 你可能是对的,但这里的问题是请求看起来是空的,所以我无法返回它的响应。

标签: php laravel swagger


【解决方案1】:

已排序。 我只需要改变

mediaType="raw",

进入

mediaType="application/json",

即使在邮递员上它是原始的

【讨论】:

    猜你喜欢
    • 2019-01-22
    • 2017-01-27
    • 1970-01-01
    • 1970-01-01
    • 2019-04-05
    • 1970-01-01
    • 2021-05-08
    • 2017-08-30
    • 2017-12-24
    相关资源
    最近更新 更多