指尖上的记忆指尖上的记忆
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub

symfony7给swagger字段添加描述信息:

use OpenApi\Attributes as OA;
  
class AffiliationDto implements ResponsibleInterface
{
    #[OA\Property(description: "The unique identifier of the affiliation", example: 123)]
    private int $id;
  
    #[OA\Property(description: "The name of the affiliation", example: "hh")]
    private string $department;
  
    #[OA\Property(description: "The description of the affiliation", example: "gg")]
    private string $institution;
}
再补充一下信息,在控制器下直接使用DTO自动生成
use OpenApi\Attributes as OA;

#[Route('/submissions/summary', name: 'submissions_summary', methods: ['GET'])]
#[OA\Get(
description: "返回事件的提交统计数据摘要",
summary: "获取提交统计摘要"
)]
#[OA\Response(
response: 200,
description: 'Return submissions summary',
content: new Model(type: Dto\Query\Submission\Statistic\SubmissionSummaryStatisticsDataDto::class)
)]
#[OA\Response(
response: 404,
description: 'Event not found'
)]
public function getSubmissionSummary(
Sciforum\Event $event,
Statistic\SubmissionSessionDistributionService $submissionSessionDistributionService,
): JsonResponse {
return $this->apiResponse->response($submissionSessionDistributionService->getSubmissionSummary($event));
}

可以通过 OA\Get 对这个Get方法进行说明,通过 OA\Response 定义多个 response code 下的信息