Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] C# Client: Usage of Newtonsoft.Json #11008

Open
atinary-screoff opened this issue Dec 1, 2021 · 0 comments
Open

[BUG] C# Client: Usage of Newtonsoft.Json #11008

atinary-screoff opened this issue Dec 1, 2021 · 0 comments

Comments

@atinary-screoff
Copy link

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.

dhedey added a commit to dhedey/openapi-generator that referenced this issue Feb 14, 2022
Partial fix for OpenAPITools#11008. A full fix requires using nullable value types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant