2019-07-29 14:33:28 +02:00
|
|
|
{******************************************************************************}
|
|
|
|
{ }
|
|
|
|
{ Delphi SwagDoc Library }
|
|
|
|
{ Copyright (c) 2018 Marcelo Jaloto }
|
|
|
|
{ https://github.com/marcelojaloto/SwagDoc }
|
|
|
|
{ }
|
|
|
|
{******************************************************************************}
|
|
|
|
{ }
|
|
|
|
{ Licensed under the Apache License, Version 2.0 (the "License"); }
|
|
|
|
{ you may not use this file except in compliance with the License. }
|
|
|
|
{ You may obtain a copy of the License at }
|
|
|
|
{ }
|
|
|
|
{ http://www.apache.org/licenses/LICENSE-2.0 }
|
|
|
|
{ }
|
|
|
|
{ Unless required by applicable law or agreed to in writing, software }
|
|
|
|
{ distributed under the License is distributed on an "AS IS" BASIS, }
|
|
|
|
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
|
|
|
|
{ See the License for the specific language governing permissions and }
|
|
|
|
{ limitations under the License. }
|
|
|
|
{ }
|
|
|
|
{******************************************************************************}
|
|
|
|
|
|
|
|
unit Sample.Main;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
System.SysUtils,
|
|
|
|
System.Types,
|
|
|
|
System.UITypes,
|
|
|
|
System.Classes,
|
|
|
|
System.Variants,
|
|
|
|
FMX.Types,
|
|
|
|
FMX.Controls,
|
|
|
|
FMX.Forms,
|
|
|
|
FMX.Graphics,
|
|
|
|
FMX.Dialogs,
|
|
|
|
FMX.Controls.Presentation,
|
|
|
|
FMX.StdCtrls,
|
|
|
|
FMX.ScrollBox,
|
|
|
|
FMX.Memo,
|
|
|
|
FMX.TabControl
|
|
|
|
;
|
|
|
|
|
|
|
|
type
|
|
|
|
TForm1 = class(TForm)
|
|
|
|
Memo1: TMemo;
|
|
|
|
btnGenerateDelphiMVCController: TButton;
|
|
|
|
TabControl1: TTabControl;
|
|
|
|
TabItem1: TTabItem;
|
|
|
|
TabItem2: TTabItem;
|
|
|
|
Memo2: TMemo;
|
|
|
|
procedure btnGenerateDelphiMVCControllerClick(Sender: TObject);
|
|
|
|
private
|
|
|
|
{ Private declarations }
|
|
|
|
public
|
|
|
|
{ Public declarations }
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
Form1: TForm1;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
{$R *.fmx}
|
|
|
|
|
|
|
|
uses
|
|
|
|
Swag.Doc,
|
2019-07-30 08:29:31 +02:00
|
|
|
Sample.SwagDoc.DelphiMVCFramework,
|
2019-08-06 02:54:23 +02:00
|
|
|
System.IOUtils
|
2019-07-29 14:33:28 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
procedure TForm1.btnGenerateDelphiMVCControllerClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
mvcFramework : TSwagDocToDelphiMVCFrameworkBuilder;
|
2019-08-06 02:54:23 +02:00
|
|
|
swagDoc : TSwagDoc;
|
|
|
|
filename : string;
|
2019-07-29 14:33:28 +02:00
|
|
|
begin
|
|
|
|
mvcFramework := nil;
|
|
|
|
try
|
2019-08-06 02:54:23 +02:00
|
|
|
swagDoc := TSwagDoc.Create;
|
2019-08-06 02:59:02 +02:00
|
|
|
swagDoc.LoadFromFile(TPath.Combine(TPath.GetDirectoryName(ParamStr(0)), '..\..\swagger.json'));
|
2019-08-06 02:54:23 +02:00
|
|
|
mvcFramework := TSwagDocToDelphiMVCFrameworkBuilder.Create(swagDoc);
|
2019-07-29 14:33:28 +02:00
|
|
|
memo2.Lines.Text := mvcFramework.Generate;
|
2019-08-06 02:54:23 +02:00
|
|
|
filename := TPath.Combine(TPath.GetDirectoryName(ParamStr(0)), '..\..\mvccontroller.pas');
|
|
|
|
TFile.WriteAllText(filename, memo2.Lines.Text);
|
2019-07-29 14:33:28 +02:00
|
|
|
finally
|
|
|
|
FreeAndNil(mvcFramework);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
initialization
|
|
|
|
ReportMemoryLeaksOnShutdown := True;
|
|
|
|
|
|
|
|
end.
|