我的 Symfony 4 应用程序中有一个 API 端点,我想用 NelmioApiDocBundle 和 Swagger 记录它。端点将 JSON 作为请求数据并返回一些自定义 JSON 作为响应。如何使用注释将它们的示例添加到文档中?我在文档页面上看不到任何示例,只有描述。
/**
* @Route("/order/import", methods={"POST"}, name="order_import")
* @OA\RequestBody (
* request="order",
* description="Order data in JSON format",
* @OA\Schema(
* type="object",
* example={"hello": "world"}
* )
* )
* @OA\Response(
* response=200,
* description="Returns the JSON data after import",
* @OA\Schema(
* type="object",
* example={"foo": "bar"}
* )
* )
* @OA\Tag(name="import")