question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: how to make an enum-value lowercase when used as [Path] ?

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:19 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
Sharparamcommented, Apr 25, 2019

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 at DisplayAttribute? but still pretty situational).

1reaction
Sharparamcommented, Apr 25, 2019

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 if Serialized is specified it will use the EnumMemberAttribute serializer, or a custom one if overridden in the RestClient properties.

Edit: And you were correct, I added an Emit for the enum value in AddPathParam and now all tests pass. Didn’t see that method.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found