Dreamescaper / GenerateAspNetCoreClient

DotNet tool to generate HTTP client classes from ASP.NET Core api controllers.
MIT License
63 stars 5 forks source link

2.0.0 enum converts to string #23

Closed valentasm1 closed 8 months ago

valentasm1 commented 9 months ago

Controller

[Route("test")]
[ApiController]
[Authorize]
public class TestController : ControllerBase
{
    [HttpGet]
    [ProducesResponseType(typeof(ProductListResponse), (int)HttpStatusCode.OK)]
    public async Task<ProductListResponse> Products([FromQuery(Name = "sort_type")] ProductSortType? sortType)
    {
        return new ProductListResponse();
    }
}

Result where ProductSortType enum becomes string

 public partial interface ITestApi
 {
     [Get("/test")]
     Task<ProductListResponse> Products([AliasAs("sort_type")] string sorttype = null);
 }

It should be something related to .net8

valentasm1 commented 8 months ago

Ok. Error happened only when it comes from model. I tried debug to see where error is but after 1h left. How do you do? Would be great to have test. Maybe one day will come back Enum val is always serialized as string

public enum SomeEnum
{
    Value1,
    Value2,
    Value3
}

public class SomeQueryModel
{
    public SomeEnum EnumVal { get; set; }
    public string Param1 { get; set; }
    public Guid? Param2 { get; set; }
    public int Param3 { get; set; }
}
Dreamescaper commented 8 months ago

@valentasm1 I have published an updated version: https://www.nuget.org/packages/GenerateAspNetCoreClient.Refit/2.1.0

Hopefully everything works fine now!

valentasm1 commented 8 months ago

It works. Thank you.