php - API 平台 : Change description of an endpoint

标签 php symfony annotations api-platform.com

我已经使用 API 平台创建了一个自定义端点。这是我使用的注释:

/**
 * We only want the POST option for now.
 *
 * @ApiResource(
 *      itemOperations={},
 *      collectionOperations={"post"={
 *           "method"="POST",
 *           "controller"=PairingController::class,
 *           "path"="/devices/pairing",
 *           "defaults"={"_api_receive"=false}
 *     }},
 * )
 *
 *
 */
class Pairing
{
...

我调用的 Controller 执行一些自定义逻辑。我对到目前为止的工作方式感到满意。但是 API 平台生成的文档现在是不准确的。它说:

/devices/pairing Creates a Pairing resource.

... 这不再正确,因为我的 Controller 不生成配对。 (它改为调用不同的 API,要求该 API 做一些事情。)

所以这是我的问题:如何更改注释以允许我为此端点编写自定义文档?

最佳答案

您可以使用 swagger_context 键更改任何 Swagger 字段,包括 description(您要查找的那个):https://api-platform.com/docs/core/swagger/#changing-operations-in-the-swagger-documentation

关于php - API 平台 : Change description of an endpoint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52162706/

相关文章:

upload - symfony2文件上传

swift - 将数据从 Annotation 传递到下一个 VC

php - 将数据从一种形式自动填充到另一种形式,托管在另一个站点上

symfony - 如何从 Controller 访问Twig path()函数?

arrays - Twig 中的输出数组

java - Android - 可以将@IntDef 值放在@interface 中吗?

spring-boot - 如何按顺序检查多个 Spring DTO 验证?

php - ussd的设计模式建议

php - Silex ActiveRecord 模型加载

php - 来自多个数据库表的Mysql联合