[英]How to post array in swagger api
我已经整合了swagger php api outr rest-api所有服务工作正常,但我在api中的post json数组中遇到问题。 这不行,请你帮忙。
在这里我的swagger api代码
/**
* @SWG\Post(path="/createbetsnap/get_all_game_data",
* tags={"Create Betsnaps Section"},
* summary="This function used to get selected tournament schedule date and other master data like size, prize structure and entry fee",
* description="",
* operationId="get_all_game_data",
* produces={"application/json"},
* consumes={"application/json"},
* @SWG\Parameter(
* name="Login_Session_Key",
* in="header",
* description="The Login Session Key of logged in user.",
* required=true,
* type="string"
* ),
* @SWG\Parameter(
* name="game_tournament",
* in="formData",
* description="The game tournament ids array field.",
* required=true,
* type="array",
* @SWG\Items(type="string")
* ),
* @SWG\Response(response=200, description="success message with data array"),
* @SWG\Response(response=500, description="Invalid username/password supplied")
* )
*/
我在api之前添加的关于swagger的完整代码。
我想发布game_tournament字段
{"game_tournament":["18","8"]}
但是从以下格式的swagger-ui面板帖子
game_tournament=8,18
你可以帮我解决我的代码有什么问题,我需要改变什么。
提前致谢。
要POST JSON数据,您需要使用in: body
参数并使用@SWG\\Schema
指定数据类型:
* @SWG\Parameter(
* name="game_tournament",
* in="body",
* description="The game tournament ids array field.",
* required=true,
* @SWG\Schema(
* type="array",
* @SWG\Items(type="string")
* )
* ),
使用例如Swrager Lume包为Laravel / Lumen,您可以获得您的要求:
* @OA\Parameter(
* name="game_tournament[]",
* in="query",
* description="The game tournament ids array field",
* required=true,
* @OA\Schema(type="array", @OA\Items(type="string")),
* ),
去尝试一下:
* @SWG\Parameter(
* name="game_tournament[]",
* type="array",
* items="string",
* collectionFormat="multi",
* required=true,
* in="query",
* ),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.