-
-
Notifications
You must be signed in to change notification settings - Fork 747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: JsonPropertyName attribute is ignored (does not rename properties as expected) #1541
Comments
Hello, any help? |
@7amou3 it's not a bug, it's by design, i've prepared pr, but i think it's odd to use |
I don't want to use |
I'm running into the same issue where I want to remove Refit from my core package and reuse the models between my library which I want to support trimming and AOT and a child library which adds a Refit client separately. |
@7amou3 @damidhagor oh i get it, i forgot about that case, PR still on review so we have to wait 😄 |
@clairernovotny can you check and merge this fix please? |
The issue arises because query strings aren't JSON and thus aren't processed in the same way as JSON serialization. While JSON serialization has its own conventions and rules, query strings follow a different set of standards and encoding mechanisms. The two are distinct and require different handling approaches. |
Any updates on this? |
You have to use the
|
@tcortega, Question: Would it be possible to also add in support for using the formatters for bodies since they also ignore the [JsonPropertyName] attribute? Having one interface for both would cut down on the clutter. Edit: There was an error with my code, please ignore |
@ChrisPulman this should be closed |
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. |
Describe the bug 🐞
Hello
the [JsonPropertyName("mycustomePropName")]
doesn't seems to work, the serializer always output the property name,for example: in the DummyRequest class below, the url is:
http://localhost/myendpoint/json?All=True&Limit=10
instead of
http://localhost/myendpoint/json?all=True&otherText=10
the [AliasAs("othertext")] works fine, but I don't want to use it
Any Idea?
Thanks
Step to reproduce
create a new .Net 7 project and paste the following code in program.cs
Reproduction repository
https://github.com/reactiveui/refit
Expected behavior
Serialized properties that have the [JsonPropertyName("myPropName")] should be renamed accordingly
Screenshots 🖼️
bellow the sent request
IDE
Visual Studio 2022
Operating system
Windows
Version
11
Device
No response
Refit Version
7.0.0
Additional information ℹ️
No response
The text was updated successfully, but these errors were encountered: