swagger-api / swagger-api/swagger-codegen

[CSharp] Issue with double numbers if local is not US

Open
#6,785 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: C-Sharp General: Discussion Issue: Platform
Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Hi,

I am using codegen 2.3.0.

In file ApiClient, the Method
public string ParameterToString(object obj)
contains an error at row:
https://github.com/swagger-api/swagger-codegen/blob/c6b6249f1c792be804b2fb991cd0e104ce169536/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache#L311

If I use a localization different from "US" and I have a double value this row returns a number with a comma "," instead dot "."

I think it should be better to return always the "dotted" number adding another "else if" condition:

    else if (obj is double || obj is decimal)
    {
        return Convert.ToString(obj, new CultureInfo("en-US"));
    }

Thanks,

lunat

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache at the linked ParameterToString implementation. Reproduce the formatting under a non-US locale and verify that double and decimal values are returned with a dot as the decimal separator.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.