mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 15:55:54 +01:00
This commit is contained in:
parent
b1f838ece9
commit
4a25c05811
@ -1488,6 +1488,8 @@ The current beta release is named 3.2.3-radium-beta. If you want to stay on the-
|
||||
#### Bug Fix in 3.2.3-radium-beta
|
||||
- Fixed a rendering problem in swagger interface format in case of specific JSON structure
|
||||
- Fix [issue 594](https://github.com/danieleteti/delphimvcframework/issues/594) (Thanks to [biware-repo](https://github.com/biware-repo))
|
||||
- Fix [issue 595](https://github.com/danieleteti/delphimvcframework/issues/595)
|
||||
- Fix [issue 590](https://github.com/danieleteti/delphimvcframework/issues/590)
|
||||
|
||||
|
||||
## Trainings, consultancy or custom development service
|
||||
|
@ -40,7 +40,8 @@ uses
|
||||
System.Rtti,
|
||||
System.Generics.Collections,
|
||||
MVCFramework.Serializer.Commons,
|
||||
MVCFramework.Serializer.JsonDataObjects, System.SysUtils;
|
||||
MVCFramework.Serializer.JsonDataObjects,
|
||||
System.SysUtils;
|
||||
|
||||
const
|
||||
JSONRPC_VERSION = '2.0';
|
||||
@ -459,6 +460,11 @@ type
|
||||
|
||||
TJSONRPCProxyGeneratorClass = class of TJSONRPCProxyGenerator;
|
||||
|
||||
TJSONUtilsHelper = record helper for TJSONUtils
|
||||
class function JSONObjectToRecord<T: record >(const JSONRPCResponse: IInterface): T; overload; static;
|
||||
class function JSONArrayToArrayOfRecord<T: record >(const JSONRPCResponse: IInterface): TArray<T>; overload; static;
|
||||
end;
|
||||
|
||||
procedure RegisterJSONRPCProxyGenerator(const aLanguage: string; const aClass: TJSONRPCProxyGeneratorClass);
|
||||
|
||||
implementation
|
||||
@ -2813,6 +2819,38 @@ begin
|
||||
fErrMessage := ErrMessage;
|
||||
end;
|
||||
|
||||
{ TJSONUtilsHelper }
|
||||
|
||||
class function TJSONUtilsHelper.JSONArrayToArrayOfRecord<T>(
|
||||
const JSONRPCResponse: IInterface): TArray<T>;
|
||||
var
|
||||
lIntf: IJSONRPCResponse;
|
||||
begin
|
||||
if Supports(JSONRPCResponse, IJSONRPCResponse, lIntf) then
|
||||
begin
|
||||
Result := TJSONUtils.JSONArrayToArrayOfRecord<T>(lIntf.ResultAsJSONArray);
|
||||
end
|
||||
else
|
||||
begin
|
||||
RaiseSerializationError('Parameter doesn''t support IJSONRPCResponse');
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TJSONUtilsHelper.JSONObjectToRecord<T>(
|
||||
const JSONRPCResponse: IInterface): T;
|
||||
var
|
||||
lIntf: IJSONRPCResponse;
|
||||
begin
|
||||
if Supports(JSONRPCResponse, IJSONRPCResponse, lIntf) then
|
||||
begin
|
||||
Result := TJSONUtils.JSONObjectToRecord<T>(lIntf.ResultAsJSONObject);
|
||||
end
|
||||
else
|
||||
begin
|
||||
RaiseSerializationError('Parameter doesn''t support IJSONRPCResponse');
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
finalization
|
||||
|
@ -240,9 +240,7 @@ type
|
||||
public
|
||||
// records
|
||||
class function JSONObjectToRecord<T: record >(const JSONObject: TJsonObject): T; overload; static;
|
||||
class function JSONObjectToRecord<T: record >(const JSONRPCResponse: IInterface): T; overload; static;
|
||||
class function JSONArrayToArrayOfRecord<T: record >(const JSONArray: TJsonArray): TArray<T>; overload; static;
|
||||
class function JSONArrayToArrayOfRecord<T: record >(const JSONRPCResponse: IInterface): TArray<T>; overload; static;
|
||||
// objects
|
||||
class function JsonObjectToObject<T: class, constructor>(const JSONObject: TJsonObject): T; overload; static;
|
||||
class function JSONArrayToListOf<T: class, constructor>(const JSONArray: TJsonArray): TObjectList<T>;
|
||||
@ -266,7 +264,6 @@ implementation
|
||||
|
||||
uses
|
||||
MVCFramework.Serializer.JsonDataObjects.CustomTypes,
|
||||
MVCFramework.JSONRPC,
|
||||
MVCFramework.Logger,
|
||||
MVCFramework.DataSet.Utils,
|
||||
MVCFramework.Nullables;
|
||||
@ -3951,20 +3948,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TJSONUtils.JSONArrayToArrayOfRecord<T>(const JSONRPCResponse: IInterface): TArray<T>;
|
||||
var
|
||||
lIntf: IJSONRPCResponse;
|
||||
begin
|
||||
if Supports(JSONRPCResponse, IJSONRPCResponse, lIntf) then
|
||||
begin
|
||||
Result := TJSONUtils.JSONArrayToArrayOfRecord<T>(lIntf.ResultAsJSONArray);
|
||||
end
|
||||
else
|
||||
begin
|
||||
RaiseSerializationError('Parameter doesn''t support IJSONRPCResponse');
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TJSONUtils.JSONArrayToListOf<T>(const JSONArray: TJsonArray): TObjectList<T>;
|
||||
var
|
||||
I: Integer;
|
||||
@ -4006,20 +3989,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TJSONUtils.JSONObjectToRecord<T>(const JSONRPCResponse: IInterface): T;
|
||||
var
|
||||
lIntf: IJSONRPCResponse;
|
||||
begin
|
||||
if Supports(JSONRPCResponse, IJSONRPCResponse, lIntf) then
|
||||
begin
|
||||
Result := TJSONUtils.JSONObjectToRecord<T>(lIntf.ResultAsJSONObject);
|
||||
end
|
||||
else
|
||||
begin
|
||||
RaiseSerializationError('Parameter doesn''t support IJSONRPCResponse');
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TJSONUtils.JSONObjectToRecord<T>(const JSONObject: TJsonObject): T;
|
||||
var
|
||||
lSer: TMVCJsonDataObjectsSerializer;
|
||||
|
@ -57,7 +57,7 @@ uses
|
||||
MVCFramework.ApplicationSession,
|
||||
MVCFramework.Serializer.Intf,
|
||||
|
||||
{$IFDEF WEBAPACHEHTTP}
|
||||
{$IF Defined(WEBAPACHEHTTP)}
|
||||
Web.ApacheHTTP,
|
||||
// Apache Support since XE6 http://docwiki.embarcadero.com/Libraries/XE6/de/Web.ApacheHTTP
|
||||
|
||||
@ -66,7 +66,7 @@ uses
|
||||
// Delphi XE4 (all update) and XE5 (with no update) don't contains this unit. Look for the bug in QC
|
||||
// https://quality.embarcadero.com/browse/RSP-17216
|
||||
|
||||
{$IFNDEF MOBILE} // file upload is not supported on mobile
|
||||
{$IF NOT Defined(MOBILE)} // file upload is not supported on mobile
|
||||
{$IF Defined(SeattleOrBetter)}
|
||||
Web.ReqMulti,
|
||||
{$ELSE}
|
||||
@ -75,14 +75,13 @@ uses
|
||||
{$ENDIF}
|
||||
Web.HTTPApp,
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
{$IF Defined(MSWINDOWS)}
|
||||
Web.Win.IsapiHTTP,
|
||||
{$ENDIF}
|
||||
Web.WebReq,
|
||||
LoggerPro,
|
||||
IdGlobal,
|
||||
IdGlobalProtocols,
|
||||
// IdHTTPWebBrokerBridge,
|
||||
Swag.Doc,
|
||||
Swag.Common.Types,
|
||||
MVCFramework.Commons,
|
||||
@ -425,7 +424,7 @@ type
|
||||
property Files: TAbstractWebRequestFiles read GetFiles;
|
||||
end;
|
||||
|
||||
{$IFDEF WEBAPACHEHTTP}
|
||||
{$IF Defined(WEBAPACHEHTTP)}
|
||||
|
||||
TMVCApacheWebRequest = class(TMVCWebRequest)
|
||||
private
|
||||
@ -1301,7 +1300,7 @@ begin
|
||||
lEncoding := TEncoding.GetEncoding(lCurrCharset);
|
||||
try
|
||||
|
||||
{$IFDEF BERLINORBETTER}
|
||||
{$IF Defined(BERLINORBETTER)}
|
||||
FWebRequest.ReadTotalContent; // Otherwise ISAPI Raises "Empty BODY"
|
||||
FBody := lEncoding.GetString(FWebRequest.RawContent);
|
||||
{$ELSE}
|
||||
@ -1977,20 +1976,20 @@ begin
|
||||
end
|
||||
else
|
||||
begin
|
||||
{$IFDEF WEBAPACHEHTTP}
|
||||
{$IF Defined(WEBAPACHEHTTP)}
|
||||
if ARequest.ClassType = TApacheRequest then
|
||||
begin
|
||||
FRequest := TMVCApacheWebRequest.Create(ARequest, ASerializers)
|
||||
end
|
||||
else
|
||||
{$IFNDEF LINUX}
|
||||
{$IF Defined(MSWINDOWS)}
|
||||
if ARequest.ClassType = TISAPIRequest then
|
||||
begin
|
||||
FRequest := TMVCISAPIWebRequest.Create(ARequest, ASerializers)
|
||||
end
|
||||
else
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF} //MSWINDOWS
|
||||
{$ENDIF} //WEBAPACHEHTTP
|
||||
begin
|
||||
FRequest := TMVCIndyWebRequest.Create(ARequest, ASerializers);
|
||||
end;
|
||||
@ -2044,13 +2043,13 @@ end;
|
||||
|
||||
function TWebContext.GetHostingFrameworkType: TMVCHostingFrameworkType;
|
||||
begin
|
||||
{$IFDEF WEBAPACHEHTTP}
|
||||
{$IF Defined(WEBAPACHEHTTP)}
|
||||
if FRequest.ClassType = TApacheRequest then
|
||||
begin
|
||||
Exit(hftApache);
|
||||
end;
|
||||
{$ENDIF}
|
||||
{$IFDEF MSWINDOWS}
|
||||
{$IF Defined(MSWINDOWS)}
|
||||
if FRequest.ClassType = TISAPIRequest then
|
||||
begin
|
||||
Exit(hftISAPI);
|
||||
@ -2091,13 +2090,6 @@ begin
|
||||
FMessage := AMessage;
|
||||
end;
|
||||
|
||||
{ TMVCIndyWebRequest }
|
||||
|
||||
// function TMVCIndyWebRequest.RawHeaders: TStrings;
|
||||
// begin
|
||||
// Result := TMVCHackHTTPAppRequest(FWebRequest).GetHeaders;
|
||||
// end;
|
||||
|
||||
function TWebContext.GetLoggedUser: TUser;
|
||||
begin
|
||||
if not Assigned(FLoggedUser) then
|
||||
@ -2197,7 +2189,6 @@ begin
|
||||
begin
|
||||
raise EMVCSessionExpiredException.Create('Session not started');
|
||||
end;
|
||||
//SId := TMVCEngine.ExtractSessionIdFromWebRequest(FRequest.RawWebRequest);
|
||||
GlobalSessionList.Remove(SId);
|
||||
if SId <> '' then
|
||||
begin
|
||||
@ -2416,7 +2407,7 @@ begin
|
||||
[(FConfigCache_MaxRequestSize div 1024)]);
|
||||
end;
|
||||
|
||||
{$IFDEF BERLINORBETTER}
|
||||
{$IF Defined(BERLINORBETTER)}
|
||||
ARequest.ReadTotalContent;
|
||||
|
||||
// Double check for malicious content-length header
|
||||
|
Loading…
Reference in New Issue
Block a user