php - 如何在 Api-Platform 上使用带有 Messanger 输入的路径中的 {id}?
问题描述
我有这样的事情:
/**
* @ORM/Entity
* @ApiResource(
* itemOperations={
* "put_cancel": {
* "method": "PUT",
* "path": "/task/{id}/cancel",
* "messenger": "input",
* "input": CancelTaskCommand::class,
* "output": false
* },
* }
* )
*/
class Foo {}
CancelFooCommand.php
final class CancelFooCommand
{
/**
* @var string
* @ApiProperty(
* identifier=true,
* )
*/
public string $id = '';
/**
* @var string
* @ApiProperty(
* attributes={
* "openapi_context"={
* "type": "string"
* }
* }
* )
*/
public string $note = '';
}
所以我必须在有效载荷和路径中输入两次 id。是否可以跳过添加id
到有效负载并从路径获取它?
解决方案
推荐阅读
- nginx - Nginx 使用反向代理重定向太多次
- mysql - 使用 Spring data jpa 读取数据自动将时间戳转换为当前时区
- matplotlib - matplotlib 的 subplots() 中的 [1] 是什么意思?
- javascript - 什么是 vendor.min.js?
- python-3.x - 未找到端口:在 python 中列出所有端口时出错
- javascript - 当 Google Places API 自动完成授权失败时,输入会被禁用
- python - 查找列表中的相邻值计数
- javascript - Javascript函数获取从1到100递增顺序的随机数
- amazon-web-services - 如何使用 Amazon SNS 发送 SMS 消息
- javascript - 将 JSON 数据从 Azure SQL DB 迁移到 Cosmos DB 会产生字符串值