如何使用swagger 2.0在laravel中的对象内部创建适当的对象swagger?

时间:2019-02-04 11:05:10

标签: json laravel swagger-ui swagger-2.0

我有一个类似以下的JSON。我试图创建摇摇欲坠的Laravel版本,但没有成功。我从这个How to generate set array of object in post request in Swagger with Laravel?

那里获得了帮助

这是我的JSON,我需要Laravel中的模式

{
    "website_title": "http://apinew.testsite",
    "settings": {
        "website_footer_subtitle": "Copyright is copied",
        "website_footer_description": null,
    },
    "website_logo_available": "https://s3.amazonaws.com/saas-dashboard/websiteData/1547811743mountains1.jpg",
    "website_fav_icon_available": "https://s3.amazonaws.com/saas-dashboard/websiteData/1547811751SS Favicon @2x.png",
    "templateSetId": "9",
    "tenancyDatabase": "038e4744da294f2db8680a0a4016470b"
}

我尝试了很多模式,但是最接近的模式是这样

/**
 * @SWG\Post(
 *     path="/update-general-settings/{tenancyDatabase}/{general_settings}",
 *     description="Update the general settings for the website.",
 *     produces={"application/json"},
 *     consumes={"application/json"},
 *     tags={"Website"},
 *     security={
 *         {
 *             "Bearer": {},
 *               
 *         },
 *     },
 *     @SWG\Parameter(
 *         name="Update the settings of the website",
 *         in="body",
 *         description="",
 *          @SWG\Schema(
 *              type="array",
 *      @SWG\Items(
 *          type="object",
 *          @SWG\Property(type="string", property="website_title", description="user_name"),
 *          @SWG\Property(type="string", property="website_logo_available", description="website_logo_available"),
 *          @SWG\Property(type="string", property="website_fav_icon_available", description="website_fav_icon_available"),
 *          @SWG\Property(type="string", property="templateSetId", description="templateSetId"),
 *          @SWG\Property(type="string", property="tenancyDatabase", description="tenancyDatabase"),
 *          @SWG\Property(type="array", property="settings", description="settings",
 *              @SWG\Items(
 *                  @SWG\Property(property="settings", type="object",
 *                      type="array",
 *                      @SWG\Items(
 *                          @SWG\Property(property="website_desc", type="website_desc"),
 *                          @SWG\Property(property="website_email", type="website_email"),
 *                      ),
 *                  ),
 *                  
 *                  ),
 *              ),
 *          ),
 *      ),
 *      ),
 *     ),
 *     @SWG\Response(
 *         response=200,
 *         description="OK",
 *     ),
 *     @SWG\Response(
 *         response=404,
 *         description="Not Found"
 *     ),
 *     @SWG\Response(
 *         response=401,
 *         description="unauthorized"
 *     )
 * )
 */

0 个答案:

没有答案