Squashed 'lib/swagdoc/' changes from 5734fb7c..8f81a28f

8f81a28f Merge pull request #20 from joaoduarte19/master
81d2a18b Compatibility fix for compiling for Linux on Delphi Tokyo

git-subtree-dir: lib/swagdoc
git-subtree-split: 8f81a28fcdbb0e62e1468757af8f3caa80d2ea38
This commit is contained in:
Daniele Teti 2024-03-19 16:28:05 +01:00
parent 7d89412152
commit a33e84b988
2 changed files with 15 additions and 8 deletions

View File

@ -89,11 +89,18 @@ begin
end;
function TJsonFieldObject.GetFieldByName(const pName: string): TJsonField;
var
I: Integer;
begin
Result := nil;
for Result in fFields do
if (UpperCase(Result.Name) = UpperCase(pName)) then
for I := 0 to Pred(fFields.Count) do
begin
if (UpperCase(fFields[I].Name) = UpperCase(pName)) then
begin
Result := fFields[I];
Break;
end;
end;
end;
function TJsonFieldObject.GetFieldsCount: Integer;

View File

@ -100,7 +100,7 @@ begin
case vSchemaKind of
skObject:
begin
vClass := FindClass(string(PTypeInfo(System.TypeInfo(T))^.Name));
vClass := FindClass(string(PTypeInfo(System.TypeInfo(T))^.NameFld.ToString));
if not vClass.InheritsFrom(TJsonField) then
raise ETypeNotSupportedByAField.Create(c_ErrorTypeNotSupportedByAField);
Result := TJsonFieldClass(vClass);
@ -142,25 +142,25 @@ begin
tkString, tkUString, tkChar: Result := skString;
tkRecord:
begin
if (LowerCase(string(vTypeInfo^.Name)) = 'tguid') then
if vTypeInfo = System.TypeInfo(TGuid) then
Result := skGuid
end;
tkInteger: Result := skInteger;
tkInt64: Result := skInt64;
tkEnumeration:
begin
if (LowerCase(string(vTypeInfo^.Name)) = 'boolean') then
if vTypeInfo = System.TypeInfo(Boolean) then
Result := skBoolean
else
Result := skEnumeration;
end;
tkFloat:
begin
if (LowerCase(string(vTypeInfo^.Name)) = 'tdatetime') then
if vTypeInfo = System.TypeInfo(TDateTime) then
Result := skDateTime
else if (LowerCase(string(vTypeInfo^.Name)) = 'tdate') then
else if vTypeInfo = System.TypeInfo(TDate) then
Result := skDate
else if (LowerCase(string(vTypeInfo^.Name)) = 'ttime') then
else if vTypeInfo = System.TypeInfo(TTime) then
Result := skTime
else
Result := skNumber;