首页 > 解决方案 > 用openapi_context(Swagger)中的自定义参数替换“id”参数 - api-platform

问题描述

我有一个实体的自定义操作,它使用PUT方法,我想在我的招摇(OpenApi)文档中记录参数。

这是定义

/*
 * itemOperations={
 *                  "get",
 *                  "patch",
 *                  "put",
 *                  "delete",
 *                  "activate"={
 *                      "method"="PUT",
 *                      "path"="/user/{token}/activate",
 *                      "requirements"={"token"="^\w{32}$"},
 *                      "controller"=ActivateUser::class,
 *                      "normalization_context"={"groups"={"user:read"}},
 *                      "denormalization_context"={"groups"={"user:activation"}},
 *                      "read"=false,
 *                      "validation_groups"={"Activate"},
 *                      "openapi_context"={
 *                          "summary"="Attiva un utente tramite token dopo la registrazione.",
 *                          "description"="Cambia lo stato dell'utente in 'attivo' permettendo così il login.",
 *                          "parameters"={
 *                              {
 *                                "in"="path",
 *                                "name"="token",
 *                                "required"=true,
 *                                "type"="string",
 *                                "description"="Il token generato al momento della registrazione."
 *                              }
 *                          }
 *                      }
 *                  },
 *              },
*/

感兴趣的部分是"openapi_context"关键"parameters"。此描述不会更改有关参数定义的任何内容,ID 要求仍然存在并且没有令牌描述(我在此处阅读文档以了解开放 api 上下文中的路径参数

我的实际结果

我哪里错了?有没有办法做到这一点?

标签: swaggeropenapiapi-platform.com

解决方案


推荐阅读