reactiveui / refit

The automatic type-safe REST library for .NET Core, Xamarin and .NET. Heavily inspired by Square's Retrofit library, Refit turns your REST API into a live interface.
https://reactiveui.github.io/refit/
MIT License
8.65k stars 744 forks source link

[Bug]: [AliasAs(null)] does not omit property anymore #1878

Closed Exellion closed 1 month ago

Exellion commented 1 month ago

Describe the bug 🐞

Previously, I can use AliasAs(null) to mark some properties that shouldn't be included in query parameters. For now (v.7.2.1) it does not work anymore.

Step to reproduce

  1. Mark some property with attribute AliasAs(null)

    public class QueryParams
    {
     [AliasAs("data")]
     public string Data { get; set; }
    
     [AliasAs(null)]
     public string SomeForInternalUse { get; set; }
    }
  2. Make request like similar
    [Post("/api/v1/someEndpoint")]
    Task MakeRequestAsync([Query] QueryParams parameters)
  3. Result url will be:
    /api/v1/someEndpoint?data=<value>&SomeForInternalUse=<value>

Reproduction repository

https://github.com/reactiveui/refit

Expected behavior

The result url should be (and it was previously so)

/api/v1/someEndpoint?data=<value>

Screenshots 🖼️

No response

IDE

No response

Operating system

No response

Version

No response

Device

No response

Refit Version

7.2.1

Additional information ℹ️

No response

TimothyMakkison commented 1 month ago

Hey, it looks like the behaviour of [AliasAs(null)] was unintentional and was unknowingly fixed in 1b452190.

I personally think that Refit could benefit from a feature like this. I don't know if a new attribute should be created or perhaps this quirk should be reintroduced but documented. Would you be open to creating a feature request for this?

Exellion commented 1 month ago

Feature request created

github-actions[bot] commented 2 weeks ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.