Skip to content

Commit 795688a

Browse files
committed
Fixed issue with double params in URL
1 parent 343dafa commit 795688a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Dist/OpenApiUtils.pas

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function DateToISO(const Value: TDate): string;
2222
function ISOToDateTime(const Value: string): TDateTime;
2323
function ISOToDate(const Value: string): TDate;
2424
function BoolToParam(const Value: Boolean): string;
25+
function DoubleToParam(const Value: Double): string;
2526

2627
resourcestring
2728
SInvalidDateFormat = 'Value %s is not a valid datetime';
@@ -44,6 +45,9 @@ TTimeZoneInfo = record
4445
IsUTC: Boolean;
4546
end;
4647

48+
var
49+
InternalFormatSettings: TFormatSettings;
50+
4751
function NewTimeZoneInfo: TTimeZoneInfo;
4852
begin
4953
Result.HourOff := 0;
@@ -628,4 +632,13 @@ function BoolToParam(const Value: Boolean): string;
628632
Result := 'false';
629633
end;
630634

635+
function DoubleToParam(const Value: Double): string;
636+
begin
637+
Result := FloatToStr(Value, InternalFormatSettings);
638+
end;
639+
640+
641+
initialization
642+
InternalFormatSettings := TFormatSettings.Create;
643+
InternalFormatSettings.DecimalSeparator := '.';
631644
end.

Source/OpenApiGen.Metadata.pas

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ TStringMetaType = class(TMetaType)
4949
TDoubleMetaType = class(TMetaType)
5050
public
5151
function TypeName: string; override;
52+
function CodeToParam(const ParamName: string): string; override;
5253
end;
5354

5455
TIntegerMetaType = class(TMetaType)
@@ -388,6 +389,11 @@ function TObjectMetaType.TypeName: string;
388389

389390
{ TDoubleMetaType }
390391

392+
function TDoubleMetaType.CodeToParam(const ParamName: string): string;
393+
begin
394+
Result := Format('DoubleToParam(%s)', [ParamName]);
395+
end;
396+
391397
function TDoubleMetaType.TypeName: string;
392398
begin
393399
Result := 'Double';

0 commit comments

Comments
 (0)