OpenAPITools / OpenAPITools/openapi-generator
[BUG] C# Client: Usage of Newtonsoft.Json
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
Description
When I try to use my SDK generated with the following code: 0 value is not taken in account. But going deeper, I found the SDK always use SerializeObject of Newtonsoft.Json so I directly try it.
ParameterObj param_obj = new ParameterObj(
description: "parameter description",
highValue: 1,
lowValue: 0,
name: "param_a",
type: ParameterType.Continuous
);
Console.WriteLine(JsonConvert.SerializeObject(param_obj));
The output provides me:
{"high_value":1.0,"name":"param_a"}
and the expected output should be:
{"high_value":1.0, "low_value":0, "name":"param_a"}
openapi-generator version
How I generated my C# SDK with the following command:
openapi-generator-cli generate -i openapi_server/openapi/openapi.yml -g csharp -o csharp_sdk
openapi-generator-cli version : 5.3.0
OpenAPI declaration file content or url
ParameterObj:
type: object
required:
- name
additionalProperties: false
properties:
high_value:
type: number
description: (Continuous/Discrete attribute) Upper bound value of this parameter.
minimum: -100000
maximum: 100000
format: double
low_value:
type: number
description: (Continuous/Discrete attribute) Lower bound value of this parameter.
minimum: -100000
maximum: 100000
format: double
name:
$ref: '#/components/schemas/Name'
example:
name: x1
low_value: 0
high_value: 90
Steps to reproduce
Try to provide a value which is 0 of low_value or high_value.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generated csharp_sdk output and the ParameterObj schema in openapi_server/openapi/openapi.yml, then trace how the C# client uses Newtonsoft.Json serialization. Reproduce the case with low_value set to 0 and compare the generated output with the expected JSON. Done means an explicitly provided zero value is serialized.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100