首页 > 解决方案 > 描述如何在swagger yii2中获取特定用户?

问题描述

我有一个方法(显示),我可以通过它获取有关特定用户的信息。如何在一个招摇的链接(localhost/users/12)中描述它?

 /**
     * @SWG\Get(path="/api/users/id",
     *     tags={"User"},
     *     summary="",
     *     @SWG\Parameter(
     *         name="Authorization",
     *         in="header",
     *         description="",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response = 200,
     *         description = "Ok",
     *         @SWG\Schema(ref = "#/")
     *     ),
     *     @SWG\Response(
     *         response = 400,
     *         description = "Bad Request",
     *         @SWG\Schema(ref = "#/")
     *     ),
     *     @SWG\Response(
     *         response = 404,
     *         description = "Not Found",
     *         @SWG\Schema(ref = "#/")
     *     ),
     *     @SWG\Response(
     *         response = 500,
     *         description = "Internal Server Error"
     *     )
     * )
     */

标签: yii2swagger

解决方案


    /**
         * @SWG\Get(path="/api/users/{id}",
         *     tags={"User"},
         *     summary="",
         *     @SWG\Parameter(
         *         name="Authorization",
         *         in="header",
         *         description="",
         *         required=true,
         *         type="string"
         *     ),
         *     @SWG\Parameter(
         *         name="id",
         *         in="path",
         *         description="Укажите ID",
         *         required=true,
         *         type="string"
         *     ),
         *     @SWG\Response(
         *         response = 200,
         *         description = "Ok",
         *         @SWG\Schema(ref = "#/")
         *     ),
         *     @SWG\Response(
         *         response = 400,
         *         description = "Bad Request",
         *         @SWG\Schema(ref = "#/")
         *     ),
         *     @SWG\Response(
         *         response = 404,
         *         description = "Not Found",
         *         @SWG\Schema(ref = "#/")
         *     ),
         *     @SWG\Response(
         *         response = 500,
         *         description = "Internal Server Error"
         *     )
         * )
         */

推荐阅读