Question: how to make an enum-value lowercase when used as [Path] ?
See original GitHub issueI’ve defined this API method:
[Get("/{network}/methods")]
Task<string> GetMethodsAsync([Path] NetworkType network);
Where NetworkType is an enum defined as:
[JsonConverter(typeof(StringEnumConverter))]
public enum NetworkType
{
[JsonProperty(PropertyName = "a")]
A,
[JsonProperty(PropertyName = "b")]
B
}
When sending a request, the full url which is created by RestEase is like:
https://test.com/A/methods
instead of
https://test.com/a/methods
Issue Analytics
- State:
- Created 5 years ago
- Comments:19 (15 by maintainers)
Top Results From Across the Web
Print Java enum to lower case by default keeping ...
I have an enum in Java I'd like to serialize, so that when I call it from anywhere in the code, I get...
Read more >Can I alter ENUM value from lowercase to studlyCase ...
Here we create a table with one column of enumeration. mysql> create table mathisr.test (c1 enum ('webmasters', 'stackexchange' ...
Read more >Enum Types - Learning the Java Language
An enum type is a special data type that enables for a variable to be a set of predefined constants. The variable must...
Read more >Enum constants: UPPERCASE or CameCase?
For enum constants, it's OK to use either uppercase underscore-separated names ( enum class Color { RED, GREEN } ) or regular camel-humps ......
Read more >Build Enumerations of Constants With Python's Enum
In this tutorial, you'll learn how to: Create enumerations of constants using Python's Enum class; Work with enumerations and their members in ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Honestly, as long as I can set a serializer in some way, I’m happy 😃
Whether
Serialized
will default to something or be null and require setting a value manually, it will work for my usecase.And as you say, it could be weird to automatically make
Serialized
use something that is intended for enums (unless it also looks atDisplayAttribute
? but still pretty situational).Adding an EnumMemberSerializer would maybe be optimal yeah. It shouldn’t need to be set as the default, it could default to
ToString
behaviour just like query parameter serialization does? And ifSerialized
is specified it will use the EnumMemberAttribute serializer, or a custom one if overridden in theRestClient
properties.Edit: And you were correct, I added an
Emit
for the enum value inAddPathParam
and now all tests pass. Didn’t see that method.