简体   繁体   中英

Visual Studio and Swagger/Swashbuckle - Deploy WebAPI that has DateTimeOffset

When I deploy my WebAPI that has DateTimeOffset as a parameter it just treats it like DateTime type when I use Add REST API client... in Visual Studio project.

** WebAPI:

public IHttpActionResult GetCustomer(DateTimeOffset myDate) { ... }

** Swagger: 
SwaggerUI show type as a datetime..


** Client Project:
Add REST API Client...

Comes down as a DateTime instead of DateTimeOffset.

Any ideas?

Here's a snippet of what works for me

Web:

    public async Task<IHttpActionResult> CreateFollowUp(string uniqueid, DateTimeOffset? workStart, ....){....}

Mobile:

  public async Task CreateFollowUP(string uniqueid, DateTimeOffset? workStart, ...)
    {
        try
        {
            await RetryPolicy().ExecuteAsync(async () =>
            {
                using (client)
                {
                    var fullurl = RestUrl + $"followups/CreateFollowUp?uniqueid={uniqueid}&workStart={workStart.Value.ToString("MM/dd/yyyy HH:mm:ss tt")}...";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM