diff --git a/samples/swaggerdoc/MyController2U.pas b/samples/swaggerdoc/MyController2U.pas index 39ae73cd3..dfddca2e1 100644 --- a/samples/swaggerdoc/MyController2U.pas +++ b/samples/swaggerdoc/MyController2U.pas @@ -8,7 +8,8 @@ interface MVCFramework.Commons, MVCFramework.Swagger.Commons, MVCFramework.Serializer.Commons, - MVCFramework.Middleware.Authentication.RoleBasedAuthHandler; + MVCFramework.Middleware.Authentication.RoleBasedAuthHandler, + MVCFramework.Nullables; type @@ -18,10 +19,12 @@ TAddress = class FStreet: string; FNumber: Integer; FCity: string; + FPostalCode: NullableString; public property Street: string read FStreet write FStreet; property Number: Integer read FNumber write FNumber; property City: string read FCity write FCity; + property PostalCode: NullableString read FPostalCode write FPostalCode; end; [MVCNameCase(ncLowerCase)] diff --git a/sources/MVCFramework.Swagger.Commons.pas b/sources/MVCFramework.Swagger.Commons.pas index f86e0940c..170926439 100644 --- a/sources/MVCFramework.Swagger.Commons.pas +++ b/sources/MVCFramework.Swagger.Commons.pas @@ -244,6 +244,7 @@ implementation System.RegularExpressions, System.TypInfo, MVCFramework, + MVCFramework.Nullables, MVCFramework.Serializer.Abstract, MVCFramework.Serializer.Commons, Swag.Doc.Path.Operation.Response, @@ -638,6 +639,36 @@ class function TMVCSwagger.TypeKindToMVCSwagSchemaType(APropType: TRttiType): TM begin if APropType.Handle = TypeInfo(TGUID) then Result := stGuid + else if APropType.Handle = TypeInfo(NullableString) then + Result := stString + else if APropType.Handle = TypeInfo(NullableCurrency) then + Result := stNumber + else if APropType.Handle = TypeInfo(NullableBoolean) then + Result := stBoolean + else if APropType.Handle = TypeInfo(NullableTDate) then + Result := stDate + else if APropType.Handle = TypeInfo(NullableTTime) then + Result := stTime + else if APropType.Handle = TypeInfo(NullableTDateTime) then + Result := stDateTime + else if APropType.Handle = TypeInfo(NullableSingle) then + Result := stNumber + else if APropType.Handle = TypeInfo(NullableDouble) then + Result := stNumber + else if APropType.Handle = TypeInfo(NullableExtended) then + Result := stNumber + else if APropType.Handle = TypeInfo(NullableInt16) then + Result := stInteger + else if APropType.Handle = TypeInfo(NullableUInt16) then + Result := stInteger + else if APropType.Handle = TypeInfo(NullableInt32) then + Result := stInteger + else if APropType.Handle = TypeInfo(NullableUInt32) then + Result := stInteger + else if APropType.Handle = TypeInfo(NullableInt64) then + Result := stInt64 + else if APropType.Handle = TypeInfo(NullableUInt64) then + Result := stInt64; end; tkInteger: Result := stInteger;