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

Handling of Double data type seems not to be correct #14

Closed
yonojoy opened this issue Sep 30, 2023 · 3 comments
Closed

Handling of Double data type seems not to be correct #14

yonojoy opened this issue Sep 30, 2023 · 3 comments

Comments

@yonojoy
Copy link
Contributor

yonojoy commented Sep 30, 2023

Given a OpenAPI parameter like this:

      {
        "name": "fee",
        "in": "query",
        "description": "",
        "required": false,
        "type": "number"
      }

the generated code uses the Double data type for Fee. This is than called in the following way:

Request.AddQueryParam('fee', Fee);

with

procedure AddQueryParam(const Name, Value: string);

This does not seem to be correct. The code should not rely on implicit conversion as this will use the system locale.
At least in XE4 this wont even compile.

A resolution would be to have an explicit conversion.

@wlandgraf
Copy link
Contributor

Fixed in 795688a

@yonojoy
Copy link
Contributor Author

yonojoy commented Nov 14, 2023

The fix 795688a generates different code for Double params. Instead of

Request.AddQueryParam('fee', Fee);

the new generated code will read:

Request.AddQueryParam('fee', DoubleToParam(Fee));

So my already generated (and modified) code had to be adopted manually. But I think, I will be the only one affected. It is the correct way, to fix the problem.

@wlandgraf
Copy link
Contributor

Yes, it followed the same convention as parameters of type Integer or TDateTime. The conversion should happen in the generated code, it's not the job of AddQueryParam to do type conversion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants