2022-01-04 15:44:47 +01:00
|
|
|
unit ControllersU;
|
2021-12-31 18:00:54 +01:00
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
MVCFramework,
|
|
|
|
MVCFramework.Commons,
|
|
|
|
MVCFramework.Swagger.Commons,
|
|
|
|
BaseControllerU,
|
|
|
|
EntitiesU;
|
|
|
|
|
|
|
|
type
|
2022-01-11 15:30:40 +01:00
|
|
|
[MVCPath('/mypeople')]
|
|
|
|
[MVCSWAGDefaultModel(TPersonModel, 'MyPerson', 'MyPeople')] {commenting this line you get an exception}
|
|
|
|
[MVCSWAGDefaultSummaryTags('MyPeople')] {commenting this line you get an exception}
|
|
|
|
TMyPeopleController = class(TBaseController<TPerson, TPersonRec>)
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2021-12-31 18:00:54 +01:00
|
|
|
[MVCPath('/people')]
|
2022-01-04 15:44:47 +01:00
|
|
|
[MVCSWAGDefaultModel(TPersonModel, 'Person', 'People')] {commenting this line you get an exception}
|
2021-12-31 18:00:54 +01:00
|
|
|
[MVCSWAGDefaultSummaryTags('People')] {commenting this line you get an exception}
|
|
|
|
TPeopleController = class(TBaseController<TPerson, TPersonRec>)
|
|
|
|
public
|
|
|
|
{this action is defined only in the child controller but uses the "DefaultModel"}
|
|
|
|
[MVCPath('/all2')]
|
|
|
|
[MVCHTTPMethod([httpGET])]
|
2022-01-04 15:44:47 +01:00
|
|
|
[MVCSwagSummary(TSwaggerConst.USE_DEFAULT_SUMMARY_TAGS,
|
2022-01-11 15:30:40 +01:00
|
|
|
'List all ' + TSwaggerConst.PLURAL_MODEL_NAME +
|
|
|
|
' (using route /all2, with model specified in controller)',
|
2022-01-04 15:44:47 +01:00
|
|
|
'getAll2' + TSwaggerConst.PLURAL_MODEL_NAME)]
|
2021-12-31 18:00:54 +01:00
|
|
|
[MVCSwagResponses(200, 'Success', SWAGUseDefaultControllerModel, True)]
|
|
|
|
[MVCSwagResponses(500, 'Internal Server Error')]
|
|
|
|
procedure GetAll2; virtual;
|
|
|
|
|
|
|
|
{this action is defined only in the child controller but doesn't use the "DefaultModel"}
|
|
|
|
[MVCPath('/all3')]
|
|
|
|
[MVCHTTPMethod([httpGET])]
|
2022-01-04 15:44:47 +01:00
|
|
|
[MVCSwagSummary(TSwaggerConst.USE_DEFAULT_SUMMARY_TAGS,
|
|
|
|
'List all PersonWithNickNameModel (using route /all3, custom model specified on action)',
|
|
|
|
'getAllPeopleWithNickName')]
|
2021-12-31 18:00:54 +01:00
|
|
|
[MVCSwagResponses(200, 'Success', TPersonWithNickNameModel, True)]
|
|
|
|
[MVCSwagResponses(500, 'Internal Server Error')]
|
|
|
|
procedure GetAll3; virtual;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
[MVCPath('/tallpeople')]
|
2022-08-05 12:20:20 +02:00
|
|
|
[MVCPath('/tallpeoplexxx')]
|
2022-01-04 15:44:47 +01:00
|
|
|
[MVCSWAGDefaultModel(TTallPersonModel, 'TallPerson', 'TallPeople')] {commenting this line you get an exception}
|
2021-12-31 18:00:54 +01:00
|
|
|
[MVCSWAGDefaultSummaryTags('Tall People')] {commenting this line you get an exception}
|
|
|
|
TTallPeopleController = class(TPeopleController)
|
|
|
|
public
|
|
|
|
{this action is defined only in the child controller but uses the "DefaultModel"}
|
|
|
|
[MVCPath('/all2')]
|
|
|
|
[MVCHTTPMethod([httpGET])]
|
2022-01-11 15:30:40 +01:00
|
|
|
[MVCSwagSummary(TSwaggerConst.USE_DEFAULT_SUMMARY_TAGS,
|
|
|
|
'List all ' + TSwaggerConst.PLURAL_MODEL_NAME +
|
|
|
|
' (child controller, default controller model)', 'getAll2' + TSwaggerConst.PLURAL_MODEL_NAME)]
|
2021-12-31 18:00:54 +01:00
|
|
|
[MVCSwagResponses(200, 'Success', SWAGUseDefaultControllerModel, True)]
|
|
|
|
[MVCSwagResponses(500, 'Internal Server Error')]
|
|
|
|
procedure GetAll2; override;
|
|
|
|
|
|
|
|
[MVCPath('/all3')]
|
|
|
|
[MVCHTTPMethod([httpGET])]
|
2022-01-04 15:44:47 +01:00
|
|
|
[MVCSwagSummary(TSwaggerConst.USE_DEFAULT_SUMMARY_TAGS, 'List all PersonWithNickNameModel', 'getAllPersonWithNickNameModel')]
|
2021-12-31 18:00:54 +01:00
|
|
|
[MVCSwagResponses(200, 'Success', TPersonWithNickNameModel, True)]
|
|
|
|
[MVCSwagResponses(500, 'Internal Server Error')]
|
|
|
|
procedure GetAll3; override;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
JsonDataObjects,
|
|
|
|
System.SysUtils,
|
|
|
|
System.DateUtils,
|
|
|
|
MVCFramework.Controllers.Register;
|
|
|
|
|
|
|
|
{ TPeopleController }
|
|
|
|
|
|
|
|
procedure TPeopleController.GetAll2;
|
|
|
|
begin
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TPeopleController.GetAll3;
|
|
|
|
begin
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ TTallPeopleController }
|
|
|
|
|
|
|
|
procedure TTallPeopleController.GetAll2;
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
end;
|
2022-01-04 15:44:47 +01:00
|
|
|
//
|
2021-12-31 18:00:54 +01:00
|
|
|
procedure TTallPeopleController.GetAll3;
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|