RicoSuter/NSwag

Consider using JSON convertion for path and query parameters

Open

#675 opened on Mar 14, 2017

View on GitHub
 (5 comments) (0 reactions) (0 assignees)C# (6,291 stars) (1,189 forks)batch import
help wantedproject: NSwag.SwaggerGeneration.WebApitype: bug

Description

When an enum value is passed in the path or query, the EnumMemberAttribute is ignored because the value is serialized with ToString().

public enum Operation
{
    [EnumMember("set")]
    Set,
    [EnumMember("update")]
    Update,
}

public enum Value
{
    [EnumMember("one")]
    First,
    [EnumMember("two")]
    Second,
}

public async Task DoAsync(Operation operation, Value value)
{
    // path = {operation}
    // value is a query parameter
}

Called with DoAsync(Operation.Set, Value.First) will result in the Set?First URL instead of set?one.

It would be great if the JSON serializer was used to serialize values to path and query.

Contributor guide