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,12 +89,19 @@ begin
end; end;
function TJsonFieldObject.GetFieldByName(const pName: string): TJsonField; function TJsonFieldObject.GetFieldByName(const pName: string): TJsonField;
var
I: Integer;
begin begin
Result := nil; Result := nil;
for Result in fFields do for I := 0 to Pred(fFields.Count) do
if (UpperCase(Result.Name) = UpperCase(pName)) then begin
if (UpperCase(fFields[I].Name) = UpperCase(pName)) then
begin
Result := fFields[I];
Break; Break;
end; end;
end;
end;
function TJsonFieldObject.GetFieldsCount: Integer; function TJsonFieldObject.GetFieldsCount: Integer;
begin begin

View File

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