You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ASP.NET Core 6 Web API:如何修改Swagger中BirthDate字段示例值

问题描述

在使用Swashbuckle/Swagger的ASP.NET Core 6 Web API项目中,我对接Oracle数据库,其中BirthDate字段以VARCHAR类型(字符串形式)返回。现有RequestDto定义如下:

namespace Transactions.Application.DTOs.Request
{
    public class RequestDto
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string BirthDate { get; set; }
    }
}

要求不将public string BirthDate { get; set; }修改为public DateTime BirthDate { get; set; },在Swagger的请求体示例中,让birthDate显示为"YYYY-MM-DD"而非默认的"string"。

内容的提问来源于stack exchange,提问作者Ayobamilaye

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 21:20:07