使用必填字段生成Swagger API SDK

y4ekin9u  于 2023-10-18  发布在  其他
关注(0)|答案(1)|浏览(147)

我想使用swagger生成器制作一个SDK,但我需要将其标记为必填字段。

/**
             * @SWG\Get(path="/articles",
             *   tags={"Article"},
             *   summary="Get all Articles",
             *   description="Show list of Articles",
             *   operationId="all",
             *   produces={"application/json"},
             *   @SWG\Parameter(
             *     name="name",
             *     in="form",
             *     type="string",
             *   ),
             *   @SWG\Parameter(
             *     name="description",
             *     in="form",
             *     type="string",
             *   ),
             *   @SWG\Response(response="200")
             *   ),
             * )
             */
r1zhe5dt

r1zhe5dt1#

您需要添加字段required

/**
                 * @SWG\Get(path="/articles",
                 *   tags={"Article"},
                 *   summary="Get all Articles",
                 *   description="Show list of Articles",
                 *   operationId="all",
                 *   produces={"application/json"},
                 *   @SWG\Parameter(
                 *     name="name",
                 *     in="form",
                 *     type="string",
                 *     required=true
                 *   ),
                 *   @SWG\Parameter(
                 *     name="description",
                 *     in="form",
                 *     type="string",
                 *     required=true
                 *   ),
                 *   @SWG\Response(response="200")
                 *   ),
                 * )
                 */

相关问题