source upload
This commit is contained in:
186
contrib/mORMot/CrossPlatform/templates/API.adoc.mustache
Normal file
186
contrib/mORMot/CrossPlatform/templates/API.adoc.mustache
Normal file
@@ -0,0 +1,186 @@
|
||||
== API Documentation
|
||||
|
||||
NOTE: API Documentation {{exeVersion}} retrieved {{#protocol}}from {{protocol}}://{{host}}/{{uri}} {{/protocol}}at {{time}}.
|
||||
|
||||
This documentation has been generated by {{exeInfo}}, running mORMot {{mORMotVersion}}.
|
||||
|
||||
WARNING: Any manual modification of this file may be lost after regeneration.
|
||||
|
||||
=== Services
|
||||
|
||||
This server does publish the following RESTful services:
|
||||
|
||||
{{#soa.services}}
|
||||
* <<{{uri}}>>.
|
||||
{{/soa.services}}
|
||||
|
||||
It will also use some <<Objects>>{{#withArrays}}, <<Arrays>>{{/withArrays}}{{#withEnumerates}}, <<Enumerations>>{{/withEnumerates}}{{#withsets}}, <<Sets>>{{/withsets}} type definitions, which will be transmitted as JSON objects, arrays or integers. The expected MIME transmission type, at HTTP level, is `application/json; charset=UTF-8`. Communication protocol may be either `http://` or `https://`, depending on the server configuration.
|
||||
|
||||
The following documentation will detail each service, and the input/output JSON content, as expected by each command.
|
||||
|
||||
|
||||
{{#soa.services}}
|
||||
=== {{uri}}
|
||||
|
||||
[.lead]
|
||||
{{serviceDescription}}
|
||||
|
||||
This `{{uri}}` service does publish the following methods (aka commands):
|
||||
|
||||
{{#methods}}
|
||||
* <<{{methodName}}>>.
|
||||
{{/methods}}
|
||||
{{<typeList}}{{#typePascal}}{{#isArray}}* <<{{typePascal}}>>.
|
||||
{{/isArray}}
|
||||
{{#isRecord}}* <<{{typePascal}}>>.
|
||||
{{/isRecord}}
|
||||
{{#isEnum}}* <<{{typePascal}}>>.
|
||||
{{/isEnum}}{{/typePascal}}{{/typeList}}
|
||||
|
||||
{{#methods}}
|
||||
==== {{methodName}}
|
||||
|
||||
[.lead]
|
||||
{{methodDescription}}
|
||||
|
||||
.URI (alternatives)
|
||||
POST {{protocol}}://servername:port/{{root}}/{{uri}}.{{methodName}}
|
||||
POST {{protocol}}://servername:port/{{root}}/{{uri}}/{{methodName}}
|
||||
|
||||
.Input Body
|
||||
----
|
||||
{{#hasInParams}}
|
||||
{
|
||||
{{#args}}
|
||||
{{#dirInput}}
|
||||
{{jsonQuote argName}}: {{typePascal}}{{commaInSingle}}
|
||||
{{/dirInput}}
|
||||
{{/args}}
|
||||
}
|
||||
{{/hasInParams}}
|
||||
{{^hasInParams}}
|
||||
No input expected.
|
||||
{{/hasInParams}}
|
||||
----
|
||||
|
||||
.Output Body
|
||||
----
|
||||
{{#hasOutParams}}
|
||||
{
|
||||
{{#args}}
|
||||
{{#dirOutput}}
|
||||
{{jsonQuote argName}}: {{typePascal}}{{#commaOutResult}},{{/commaOutResult}}
|
||||
{{/dirOutput}}
|
||||
{{/args}}
|
||||
}
|
||||
{{/hasOutParams}}
|
||||
{{^hasOutParams}}
|
||||
No output expected.
|
||||
{{/hasOutParams}}
|
||||
----
|
||||
|
||||
See also:
|
||||
|
||||
{{#args}}
|
||||
{{>typeList}}
|
||||
{{/args}}
|
||||
* Other <<{{uri}}>> Services.
|
||||
|
||||
{{/methods}}
|
||||
|
||||
{{/soa.services}}
|
||||
|
||||
{{#withRecords}}
|
||||
=== Objects
|
||||
|
||||
The following objects are used during data transmission:
|
||||
{{<writerec}}{
|
||||
{{#fields}}
|
||||
{{nestedIdentation}} {{jsonQuote propName}}: {{typePascal}}{{#nestedRecord}}{{>writerec}}{{nestedIdentation}} }{{/nestedRecord}}{{#nestedSimpleArray}}array of {{typePascal}}{{/nestedSimpleArray}}{{#nestedRecordArray}}array of {{>writerec}}{{nestedIdentation}} }{{/nestedRecordArray}}{{^-last}},{{/-last}}
|
||||
{{/fields}}{{/writerec}}
|
||||
|
||||
{{#records}}
|
||||
==== {{name}}
|
||||
|
||||
[.lead]
|
||||
{{recordDescription}}
|
||||
|
||||
.Definition
|
||||
----
|
||||
{{>writerec}}
|
||||
}
|
||||
----
|
||||
See also:
|
||||
|
||||
{{#fields}}
|
||||
{{>typeList}}
|
||||
{{/fields}}
|
||||
* Other <<Objects>>.
|
||||
{{#withArrays}}
|
||||
* Other <<Arrays>>.
|
||||
{{/withArrays}}
|
||||
{{#withEnumerates}}
|
||||
* Other <<Enumerations>>.
|
||||
{{/withEnumerates}}
|
||||
{{#withsets}}
|
||||
* Other <<Sets>>.
|
||||
{{/withsets}}
|
||||
|
||||
{{/records}}
|
||||
|
||||
{{/withRecords}}
|
||||
{{#withArrays}}
|
||||
=== Arrays
|
||||
|
||||
The following arrays are used during data transmission:
|
||||
|
||||
{{#arrays}}
|
||||
==== {{name}}
|
||||
|
||||
This is a JSON array of <<{{typeSource}}>>.
|
||||
|
||||
{{/arrays}}
|
||||
|
||||
{{/withArrays}}
|
||||
{{#withEnumerates}}
|
||||
|
||||
=== Enumerations
|
||||
|
||||
When transmitted within other <<Services>>, <<Objects>> or <<Arrays>> content, enumerations are represented by their `integer` JSON value. Any other value will be ignored.
|
||||
|
||||
The following enumerations have been defined:
|
||||
|
||||
{{#enumerates}}
|
||||
==== {{name}}
|
||||
|
||||
[.lead]
|
||||
{{enumDescription}}
|
||||
|
||||
{{#values}}
|
||||
{{-index0}} = {{EnumTrim .}}
|
||||
{{/values}}
|
||||
|
||||
{{/enumerates}}
|
||||
{{/withEnumerates}}
|
||||
|
||||
{{#withsets}}
|
||||
|
||||
=== Sets
|
||||
|
||||
When transmitted within other <<Services>>, <<Objects>> or <<Arrays>> content, sets are represented by their `integer` JSON value, matching binary bit storage. The `integer` values below may be added, to compute the set of individual flags - a value of `0` meaning a void set.
|
||||
|
||||
The following sets have been defined:
|
||||
|
||||
{{#sets}}
|
||||
==== {{name}}
|
||||
|
||||
[.lead]
|
||||
{{setDescription}}
|
||||
|
||||
{{#values}}
|
||||
{{PowerOfTwo -index0}} = {{EnumTrim .}}
|
||||
{{/values}}
|
||||
|
||||
{{/sets}}
|
||||
|
||||
{{/withsets}}
|
@@ -0,0 +1,309 @@
|
||||
/// remote access to a mORMot server using SynCrossPlatform* units
|
||||
{{#uri}}
|
||||
// - retrieved from {{protocol}}://{{host}}/{{uri}}
|
||||
// at {{time}} using "{{templateName}}" template
|
||||
{{/uri}}
|
||||
{{^uri}}
|
||||
// - generated at {{time}}
|
||||
{{/uri}}
|
||||
unit {{fileName}};
|
||||
|
||||
{
|
||||
WARNING:
|
||||
This unit has been generated by a mORMot {{mORMotVersion}} server.
|
||||
Any manual modification of this file may be lost after regeneration.
|
||||
|
||||
Synopse mORMot framework. Copyright (C) {{year}} Arnaud Bouchez
|
||||
Synopse Informatique - http://synopse.info
|
||||
|
||||
This unit is released under a MPL/GPL/LGPL tri-license,
|
||||
and therefore may be freely included in any application.
|
||||
|
||||
This unit would work on Delphi 6 and later, under all supported platforms
|
||||
(including MacOSX, and NextGen iPhone/iPad), and the Free Pascal Compiler.
|
||||
}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
SynCrossPlatformJSON,
|
||||
SynCrossPlatformSpecific,
|
||||
SynCrossPlatformREST;
|
||||
|
||||
{{! recursive partials used to write records type definition}}
|
||||
{{<writerec}}record
|
||||
{{#fields}}
|
||||
{{nestedIdentation}} {{propName}}: {{#typePascal}}{{typePascal}};{{/typePascal}}{{#nestedRecord}}{{>writerec}}{{nestedIdentation}} end;{{/nestedRecord}}{{#nestedSimpleArray}}array of {{typePascal}};{{/nestedSimpleArray}}{{#nestedRecordArray}}array of {{>writerec}}{{nestedIdentation}} end;{{/nestedRecordArray}}
|
||||
{{/fields}}{{/writerec}}
|
||||
{{#withEnumerates}}
|
||||
type // define some enumeration types, used below
|
||||
{{#enumerates}}
|
||||
{{name}} = ({{#values}}{{.}}{{^-last}}, {{/-last}}{{/values}});
|
||||
{{/enumerates}}
|
||||
|
||||
{{/withEnumerates}}
|
||||
{{#withSets}}
|
||||
type // define some set types, used below
|
||||
{{#sets}}
|
||||
{{name}} = set of({{#values}}{{.}}{{^-last}}, {{/-last}}{{/values}});
|
||||
{{/sets}}
|
||||
|
||||
{{/withSets}}
|
||||
{{#withRecords}}
|
||||
type // define some record types, used as properties below
|
||||
{{#records}}
|
||||
{{name}} = {{>writerec}} end;
|
||||
|
||||
{{/records}}
|
||||
{{/withRecords}}
|
||||
{{#withArrays}}
|
||||
type // define some dynamic array types, used as properties below
|
||||
{{#arrays}}
|
||||
{{name}} = array of {{typeSource}};
|
||||
{{/arrays}}
|
||||
|
||||
{{/withArrays}}
|
||||
{{<method}}{{methodName}}({{#args}}{{^dirResult}}{{dirName}} {{argName}}: {{typePascal}}{{commaArg}}{{/dirResult}}{{/args}}){{#args}}{{#dirResult}}: {{typePascal}}{{/dirResult}}{{/args}};{{/method}}
|
||||
type
|
||||
{{#orm}}
|
||||
{{^isInMormotPas}}
|
||||
/// map "{{tableName}}" table
|
||||
{{className}} = class(TSQLRecord)
|
||||
protected
|
||||
{{#fields}}
|
||||
f{{name}}: {{typePascal}};
|
||||
{{/fields}}
|
||||
{{#hasRecords}}
|
||||
public
|
||||
{{#fields}}
|
||||
{{#isrecord}}
|
||||
property {{name}}: {{typePascal}} read f{{name}} write f{{name}}{{#unique}} stored AS_UNIQUE{{/unique}};
|
||||
{{/isrecord}}
|
||||
{{/fields}}
|
||||
{{/hasRecords}}
|
||||
published
|
||||
{{#fields}}
|
||||
{{^isrecord}}
|
||||
{{#isSQLRecord}} // defined as {{name}}: {{typeDelphi}} on the server
|
||||
{{/isSQLRecord}}
|
||||
property {{name}}: {{typePascal}}{{#width}} index {{width}}{{/width}} read f{{name}} write f{{name}}{{#unique}} stored AS_UNIQUE{{/unique}};
|
||||
{{/isrecord}}
|
||||
{{/fields}}
|
||||
end;
|
||||
|
||||
{{/isInMormotPas}}
|
||||
{{/orm}}
|
||||
{{#soa.services}}
|
||||
/// service implemented by TService{{interfaceURI}}
|
||||
// - you can access this service as such:
|
||||
// !var a{{interfaceURI}}: I{{interfaceURI}};
|
||||
// !begin
|
||||
// ! a{{interfaceURI}} := TService{{interfaceURI}}.Create(aClient);
|
||||
// ! // now you can use a{{interfaceURI}} methods
|
||||
// !...
|
||||
I{{interfaceURI}} = interface(IServiceAbstract)
|
||||
['{{GUID}}']
|
||||
{{#methods}}
|
||||
{{verb}} {{>method}}
|
||||
{{/methods}}
|
||||
end;
|
||||
|
||||
/// implements I{{interfaceURI}} {{#uri}}from {{protocol}}://{{host}}/{{root}}/{{uri}}{{/uri}}
|
||||
// - this service will run in sic{{instanceCreationName}} mode
|
||||
TService{{interfaceURI}} = class(TServiceClientAbstract{{#isClientDriven}}ClientDriven{{/isClientDriven}},I{{interfaceURI}})
|
||||
public
|
||||
constructor Create(aClient: TSQLRestClientURI); override;
|
||||
{{#methods}}
|
||||
{{verb}} {{>method}}
|
||||
{{/methods}}
|
||||
end;
|
||||
|
||||
{{/soa.services}}
|
||||
const
|
||||
/// the server port{{#uri}}, corresponding to {{protocol}}://{{host}}{{/uri}}
|
||||
SERVER_PORT = {{port}};
|
||||
/// the server model root name{{#uri}}, corresponding to {{protocol}}://{{host}}{{/uri}}
|
||||
SERVER_ROOT = '{{root}}';
|
||||
|
||||
|
||||
/// return the database Model corresponding to this server
|
||||
function GetModel(const aRoot: string=SERVER_ROOT): TSQLModel;
|
||||
|
||||
/// create a TSQLRestClientHTTP instance and connect to the server
|
||||
// - it will use by default port {{port}} over root '{{root}}'{{#host}}, corresponding
|
||||
// to {{protocol}}://{{host}}/{{root}}{{/host}}
|
||||
{{#authClass}}
|
||||
// - secure connection will be established via {{.}}
|
||||
// with the supplied credentials - on connection or authentication error,
|
||||
// this function will raise a corresponding exception
|
||||
{{/authClass}}
|
||||
function GetClient(const aServerAddress{{#authClass}}, aUserName,aPassword{{/authClass}}: string;
|
||||
aServerPort: integer=SERVER_PORT; const aServerRoot: string=SERVER_ROOT;
|
||||
aHttps: boolean={{#https}}true{{/https}}{{^https}}false{{/https}}): TSQLRestClientHTTP;
|
||||
|
||||
{{#withHelpers}}
|
||||
// publish some low-level helpers for variant conversion
|
||||
// - used internally: you should not need those functions in your end-user code
|
||||
{{#enumerates}}
|
||||
function Variant2{{name}}(const _variant: variant): {{name}};
|
||||
{{/enumerates}}
|
||||
{{#records}}
|
||||
function Variant2{{name}}(_variant: variant): {{name}};
|
||||
function {{name}}2Variant(const _record: {{name}}): variant;
|
||||
{{/records}}
|
||||
{{#arrays}}
|
||||
function Variant2{{name}}(const _variant: variant): {{name}};
|
||||
function {{name}}2Variant(const _array: {{name}}): variant;
|
||||
{{/arrays}}
|
||||
|
||||
{{/withHelpers}}
|
||||
|
||||
implementation
|
||||
|
||||
{$HINTS OFF} // for H2164 hints of unused variables
|
||||
|
||||
{{#withEnumerates}}
|
||||
|
||||
{ Some helpers for enumerates types }
|
||||
|
||||
{{#enumerates}}
|
||||
function Variant2{{name}}(const _variant: variant): {{name}};
|
||||
begin
|
||||
result := {{name}}(VariantToEnum(_variant,[{{#values}}'{{.}}'{{^-last}},{{/-last}}{{/values}}]));
|
||||
end;
|
||||
|
||||
{{/enumerates}}
|
||||
{{/withEnumerates}}
|
||||
{{#withRecords}}
|
||||
{{<setrec}}{{#fields}}
|
||||
{{#isSimple}} result.{{fullPropName}} := _variant.{{fullPropName}};
|
||||
{{/isSimple}}{{#nestedRecord}}{{>setrec}}{{/nestedRecord}}{{#fromVariant}} result.{{fullPropName}} := {{fromVariant}}(_variant.{{fullPropName}});
|
||||
{{/fromVariant}}{{#nestedSimpleArray}} _arr := JSONVariantDataSafe(_variant.{{fullPropName}},jvArray);
|
||||
SetLength(result.{{fullPropName}},_arr^.Count);
|
||||
for _a := 0 to high(result.{{fullPropName}}) do
|
||||
result.{{fullPropName}}[_a] := {{#fromVariant}}{{fromVariant}}({{/fromVariant}}_arr^.Values[_a]{{#fromVariant}}){{/fromVariant}};
|
||||
{{/nestedSimpleArray}}{{#nestedRecordArray}} _arr := JSONVariantDataSafe(_variant.{{fullPropName}},jvArray);
|
||||
SetLength(result.{{fullPropName}},_arr^.Count);
|
||||
for _a := 0 to high(result.{{fullPropName}}) do
|
||||
with result.{{fullPropName}}[_a] do begin
|
||||
{{#fields}}
|
||||
{{propName}} := {{#fromVariant}}{{fromVariant}}({{/fromVariant}}_arr^.Values[_a].{{propName}}{{#fromVariant}}){{/fromVariant}};
|
||||
{{/fields}}
|
||||
end;
|
||||
{{/nestedRecordArray}}{{/fields}}{{/setrec}}
|
||||
{{<getrec}}{{#fields}}
|
||||
{{#isSimple}} res.SetPath('{{fullPropName}}',_record.{{fullPropName}});
|
||||
{{/isSimple}}{{#nestedRecord}}{{>getrec}}{{/nestedRecord}}{{#toVariant}} res.SetPath('{{fullPropName}}',{{toVariant}}(_record.{{fullPropName}}));
|
||||
{{/toVariant}}{{#nestedSimpleArray}} with res.EnsureData('{{fullPropName}}')^ do
|
||||
for i := 0 to high(_record.{{fullPropName}}) do
|
||||
AddValue({{#toVariant}}{{toVariant}}({{/toVariant}}_record.{{fullPropName}}[i]{{#toVariant}}){{/toVariant}});
|
||||
{{/nestedSimpleArray}}{{#nestedRecordArray}} with res.EnsureData('{{fullPropName}}')^ do
|
||||
for i := 0 to high(_record.{{fullPropName}}) do
|
||||
with AddItem^, _record.{{fullPropName}}[i] do begin
|
||||
{{#fields}}
|
||||
AddNameValue('{{propName}}',{{#toVariant}}{{toVariant}}({{/toVariant}}{{propName}}{{#toVariant}}){{/toVariant}});
|
||||
{{/fields}}
|
||||
end;
|
||||
{{/nestedRecordArray}}{{/fields}}{{/getrec}}{ Some helpers for record types }
|
||||
{{#records}}
|
||||
|
||||
function Variant2{{name}}(_variant: variant): {{name}};
|
||||
var _a: integer;
|
||||
_arr: PJSONVariantData;
|
||||
begin
|
||||
{{>setrec}}
|
||||
end;
|
||||
|
||||
function {{name}}2Variant(const _record: {{name}}): variant;
|
||||
var i: integer;
|
||||
res: TJSONVariantData;
|
||||
begin
|
||||
res.Init;
|
||||
{{>getrec}}
|
||||
result := variant(res);
|
||||
end;
|
||||
{{/records}}
|
||||
|
||||
{{/withRecords}}
|
||||
{{#withArrays}}
|
||||
|
||||
{ Some helpers for dynamic array types }
|
||||
|
||||
{{#arrays}}
|
||||
function Variant2{{name}}(const _variant: variant): {{name}};
|
||||
var i: integer;
|
||||
arr: PJSONVariantData;
|
||||
begin
|
||||
arr := JSONVariantDataSafe(_variant,jvArray);
|
||||
SetLength(result,arr^.Count);
|
||||
for i := 0 to arr^.Count-1 do
|
||||
result[i] := {{#fromVariant}}{{fromVariant}}{{/fromVariant}}(arr^.Values[i]);
|
||||
end;
|
||||
|
||||
function {{name}}2Variant(const _array: {{name}}): variant;
|
||||
var i: integer;
|
||||
res: TJSONVariantData;
|
||||
begin
|
||||
res.Init;
|
||||
for i := 0 to high(_array) do
|
||||
res.AddValue({{#toVariant}}{{toVariant}}{{/toVariant}}(_array[i]));
|
||||
result := variant(res);
|
||||
end;
|
||||
|
||||
{{/arrays}}
|
||||
{{/withArrays}}
|
||||
|
||||
{$HINTS ON} // for H2164 hints of unused variables
|
||||
|
||||
function GetModel(const aRoot: string): TSQLModel;
|
||||
begin
|
||||
result := TSQLModel.Create([{{#orm}}{{className}}{{comma}}{{/orm}}],aRoot);
|
||||
end;
|
||||
|
||||
function GetClient(const aServerAddress{{#authClass}}, aUserName,aPassword{{/authClass}}: string;
|
||||
aServerPort: integer; const aServerRoot: string; aHttps: boolean): TSQLRestClientHTTP;
|
||||
begin
|
||||
result := TSQLRestClientHTTP.Create(aServerAddress,aServerPort,
|
||||
GetModel(aServerRoot),true,aHttps); // aOwnModel=true
|
||||
try
|
||||
if (not result.Connect) or (result.ServerTimeStamp=0) then
|
||||
raise ERestException.CreateFmt('Impossible to connect to %s:%d server',
|
||||
[aServerAddress,aServerPort]);
|
||||
{{#authClass}}
|
||||
if not result.SetUser({{.}},aUserName,aPassword) then
|
||||
raise ERestException.CreateFmt('%s:%d server rejected "%s" credentials',
|
||||
[aServerAddress,aServerPort,aUserName]);
|
||||
{{/authClass}}
|
||||
except
|
||||
result.Free;
|
||||
raise;
|
||||
end;
|
||||
end;
|
||||
|
||||
{{#soa.services}}
|
||||
|
||||
{ TService{{interfaceURI}} }
|
||||
|
||||
constructor TService{{interfaceURI}}.Create(aClient: TSQLRestClientURI);
|
||||
begin
|
||||
fServiceName := '{{interfaceURI}}';
|
||||
fServiceURI := '{{uri}}';
|
||||
fInstanceImplementation := sic{{instanceCreationName}};
|
||||
fContractExpected := '{{contractExpected}}';
|
||||
inherited Create(aClient);
|
||||
end;
|
||||
|
||||
{{#methods}}
|
||||
{{verb}} TService{{interfaceURI}}.{{>method}}
|
||||
var res: TVariantDynArray;
|
||||
begin
|
||||
fClient.CallRemoteService(self,'{{methodName}}',{{ArgsOutputCount}}, // raise EServiceException on error
|
||||
[{{#args}}{{#dirInput}}{{#toVariant}}{{toVariant}}({{argName}}){{/toVariant}}{{^toVariant}}{{argName}}{{/toVariant}}{{commaInSingle}}{{/dirInput}}{{/args}}],res{{#resultIsServiceCustomAnswer}},true{{/resultIsServiceCustomAnswer}});
|
||||
{{#args}}{{#dirOutput}}{{#isObject}} {{argName}}.Free; // avoid memory leak
|
||||
{{/isObject}} {{argName}} := {{#fromVariant}}{{fromVariant}}({{/fromVariant}}res[{{indexOutResult}}{{#fromVariant}}){{/fromVariant}};
|
||||
{{/dirOutput}}{{/args}}end;
|
||||
|
||||
{{/methods}}
|
||||
{{/soa.services}}
|
||||
|
||||
end.
|
174
contrib/mORMot/CrossPlatform/templates/Delphi.pas.mustache
Normal file
174
contrib/mORMot/CrossPlatform/templates/Delphi.pas.mustache
Normal file
@@ -0,0 +1,174 @@
|
||||
/// remote access to a mORMot server using mORMot units
|
||||
{{#uri}}
|
||||
// - retrieved from http://{{host}}/{{uri}}
|
||||
// at {{time}} using "{{templateName}}" template
|
||||
{{/uri}}
|
||||
{{^uri}}
|
||||
// - generated at {{time}}
|
||||
{{/uri}}
|
||||
unit {{fileName}};
|
||||
|
||||
{
|
||||
WARNING:
|
||||
This unit has been generated by a mORMot {{mORMotVersion}} server.
|
||||
Any manual modification of this file may be lost after regeneration.
|
||||
|
||||
Synopse mORMot framework. Copyright (C) {{year}} Arnaud Bouchez
|
||||
Synopse Informatique - http://synopse.info
|
||||
|
||||
This unit is released under a MPL/GPL/LGPL tri-license,
|
||||
and therefore may be freely included in any application.
|
||||
|
||||
This unit would work on Delphi 6 and later, under Win32 and Win64 platforms,
|
||||
and with FPC 2.7/trunk revision, under Win32 and Linux32.
|
||||
}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
SynCommons,
|
||||
mORMot;
|
||||
{{! recursive partials used to write records type definition}}
|
||||
{{<writerec}}packed record
|
||||
{{#fields}}
|
||||
{{nestedIdentation}} {{propName}}: {{#typeDelphi}}{{typeDelphi}};{{/typeDelphi}}{{#nestedRecord}}{{>writerec}}{{nestedIdentation}} end;{{/nestedRecord}}{{#nestedSimpleArray}}array of {{typeDelphi}};{{/nestedSimpleArray}}{{#nestedRecordArray}}array of {{>writerec}}{{nestedIdentation}} end;{{/nestedRecordArray}}
|
||||
{{/fields}}{{/writerec}}
|
||||
{{<textrec}}{{#fields}}{{propName}} {{#typeDelphi}}{{typeDelphi}}{{/typeDelphi}}{{#nestedRecord}}{ {{>textrec}} }{{/nestedRecord}}{{#nestedSimpleArray}}array of {{typeDelphi}}{{/nestedSimpleArray}}{{#nestedRecordArray}}[ {{>textrec}} ]{{/nestedRecordArray}} {{/fields}}{{/textrec}}
|
||||
{{#withEnumerates}}
|
||||
type // define some enumeration types, used below
|
||||
{{#enumerates}}
|
||||
{{name}} = ({{#values}}{{.}}{{^-last}}, {{/-last}}{{/values}});
|
||||
{{/enumerates}}
|
||||
|
||||
{{/withEnumerates}}
|
||||
{{#withSets}}
|
||||
type // define some set types, used below
|
||||
{{#sets}}
|
||||
{{name}} = set of({{#values}}{{.}}{{^-last}}, {{/-last}}{{/values}});
|
||||
{{/sets}}
|
||||
|
||||
{{/withSets}}
|
||||
{{#withRecords}}
|
||||
type // define some record types, used as properties below
|
||||
{{#records}}
|
||||
{{name}} = {{>writerec}} end;
|
||||
|
||||
{{/records}}
|
||||
{{/withRecords}}
|
||||
{{#withArrays}}
|
||||
type // define some dynamic array types, used as properties below
|
||||
{{#arrays}}
|
||||
{{name}} = array of {{typeSource}};
|
||||
{{/arrays}}
|
||||
|
||||
{{/withArrays}}
|
||||
{{<method}}{{verb}} {{methodName}}({{#args}}{{^dirResult}}{{dirName}} {{argName}}: {{typeDelphi}}{{commaArg}}{{/dirResult}}{{/args}}){{#args}}{{#dirResult}}: {{typeDelphi}}{{/dirResult}}{{/args}};{{/method}}
|
||||
type
|
||||
{{#orm}}
|
||||
{{^isInMormotPas}}
|
||||
/// map "{{tableName}}" table
|
||||
{{className}} = class({{classParent}})
|
||||
protected
|
||||
{{#fields}}
|
||||
f{{name}}: {{typeDelphi}};
|
||||
{{/fields}}
|
||||
{{#hasRecords}}
|
||||
public
|
||||
class procedure InternalRegisterCustomProperties(Props: TSQLRecordProperties); override;
|
||||
{{#fields}}
|
||||
{{#isrecord}}
|
||||
property {{name}}: {{typeDelphi}} read f{{name}} write f{{name}}{{#unique}} stored AS_UNIQUE{{/unique}};
|
||||
{{/isrecord}}
|
||||
{{/fields}}
|
||||
{{/hasRecords}}
|
||||
published
|
||||
{{#fields}}
|
||||
{{^isrecord}}
|
||||
property {{name}}: {{typeDelphi}}{{#width}} index {{width}}{{/width}} read f{{name}} write f{{name}}{{#unique}} stored AS_UNIQUE{{/unique}};
|
||||
{{/isrecord}}
|
||||
{{/fields}}
|
||||
end;
|
||||
|
||||
{{/isInMormotPas}}
|
||||
{{/orm}}
|
||||
{{#soa.services}}
|
||||
/// service accessible {{#uri}}via http://{{host}}/{{root}}/{{uri}}{{/uri}}
|
||||
// - this service will run in sic{{instanceCreationName}} mode
|
||||
I{{interfaceURI}} = interface(IInvokable)
|
||||
['{{GUID}}']
|
||||
{{#methods}}
|
||||
{{>method}}
|
||||
{{/methods}}
|
||||
end;
|
||||
|
||||
{{/soa.services}}
|
||||
|
||||
/// return the database Model corresponding to this server
|
||||
function GetModel: TSQLModel;
|
||||
|
||||
const
|
||||
/// the server port{{#uri}}, corresponding to http://{{host}}{{/uri}}
|
||||
SERVER_PORT = {{port}};
|
||||
|
||||
|
||||
{{#soa.enabled}}
|
||||
/// define the interface-based services to be consummed by the client
|
||||
// - will define the following interfaces:
|
||||
{{#soa.services}}
|
||||
// ! I{{interfaceURI}} sic{{instanceCreationName}} {{GUID}}
|
||||
{{/soa.services}}
|
||||
procedure RegisterServices(Client: TSQLRestClientURI);
|
||||
{{/soa.enabled}}
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{{#orm}}
|
||||
{{#hasRecords}}
|
||||
{ {{className}} }
|
||||
|
||||
class procedure {{className}}.InternalRegisterCustomProperties(
|
||||
Props: TSQLRecordProperties);
|
||||
begin
|
||||
{{#fields}}
|
||||
{{#isrecord}}
|
||||
Props.RegisterCustomPropertyFromRTTI(Self,TypeInfo({{typeDelphi}}),
|
||||
'{{name}}',@{{className}}(nil).f{{name}});
|
||||
{{/isrecord}}
|
||||
{{/fields}}
|
||||
end;
|
||||
|
||||
{{/hasRecords}}
|
||||
{{/orm}}
|
||||
|
||||
function GetModel: TSQLModel;
|
||||
begin
|
||||
result := TSQLModel.Create([{{#orm}}{{className}}{{comma}}{{/orm}}],'{{root}}');
|
||||
end;
|
||||
|
||||
{{#soa.enabled}}
|
||||
procedure RegisterServices(Client: TSQLRestClientURI);
|
||||
begin
|
||||
{{#soa.services}}
|
||||
Client.ServiceRegister(TypeInfo(I{{interfaceURI}}),sic{{instanceCreationName}});
|
||||
{{/soa.services}}
|
||||
end;
|
||||
{{/soa.enabled}}
|
||||
|
||||
{{#withRecords}}
|
||||
const // text-based types definition for records and dynamic arrays
|
||||
{{#records}}
|
||||
__{{name}} = '{{>textrec}}';
|
||||
{{/records}}
|
||||
|
||||
initialization
|
||||
{{#enumerates}}
|
||||
TTextWriter.RegisterCustomJSONSerializerFromTextSimpleType(
|
||||
TypeInfo({{name}}));
|
||||
{{/enumerates}}
|
||||
{{#records}}
|
||||
TTextWriter.RegisterCustomJSONSerializerFromText(
|
||||
TypeInfo({{name}}),__{{name}});
|
||||
{{/records}}
|
||||
{{/withRecords}}
|
||||
end.
|
@@ -0,0 +1,87 @@
|
||||
/// SOA interface methods definition to circumvent FPC missing RTTI
|
||||
{{#uri}}
|
||||
// - retrieved from http://{{host}}/{{uri}}
|
||||
// at {{time}} using "{{templateName}}" template
|
||||
{{/uri}}
|
||||
{{^uri}}
|
||||
// - generated at {{time}}
|
||||
{{/uri}}
|
||||
unit {{fileName}};
|
||||
|
||||
{
|
||||
WARNING:
|
||||
This unit has been generated by a mORMot {{mORMotVersion}} server.
|
||||
Any manual modification of this file may be lost after regeneration.
|
||||
|
||||
Synopse mORMot framework. Copyright (C) {{year}} Arnaud Bouchez
|
||||
Synopse Informatique - http://synopse.info
|
||||
|
||||
This unit is released under a MPL/GPL/LGPL tri-license,
|
||||
and therefore may be freely included in any application.
|
||||
|
||||
This unit is intended to work on older FPC compilers, which lack of RTTI
|
||||
for interfaces - see http://bugs.freepascal.org/view.php?id=26774
|
||||
|
||||
USAGE:
|
||||
|
||||
Add this {{fileName}} unit to your uses clause, so that the following
|
||||
interfaces would be defined as expected by mORMot under FPC:
|
||||
|
||||
{{#soa.services}}
|
||||
- {{interfaceName}}
|
||||
{{/soa.services}}
|
||||
|
||||
}
|
||||
|
||||
interface
|
||||
|
||||
{$I Synopse.inc} // needed for setting HASINTERFACERTTI and proper FPC modes
|
||||
|
||||
uses
|
||||
SysUtils,
|
||||
Classes,
|
||||
SynCommons,
|
||||
SynLog,
|
||||
mORMot{{#units}},
|
||||
{{.}}{{/units}};
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{{#soa.enabled}}
|
||||
{$ifndef HASINTERFACERTTI} // circumvent old FPC bug of missing RTTI
|
||||
|
||||
{ TInterfaceFactoryDefinition }
|
||||
|
||||
type
|
||||
/// define and manage missing interface RTTI for the following interfaces:
|
||||
{{#soa.services}}
|
||||
// - {{interfaceName}}
|
||||
{{/soa.services}}
|
||||
TInterfaceFactoryDefinition = class(TInterfaceFactoryGenerated)
|
||||
protected
|
||||
procedure AddMethodsFromTypeInfo(aInterface: PTypeInfo); override;
|
||||
end;
|
||||
|
||||
procedure TInterfaceFactoryDefinition.AddMethodsFromTypeInfo(aInterface: PTypeInfo);
|
||||
begin
|
||||
{{#soa.services}}
|
||||
if aInterface=TypeInfo({{interfaceName}}) then begin
|
||||
{{#methods}}
|
||||
AddMethod('{{methodName}}',[
|
||||
{{#args}} ord(smd{{dirName}}),'{{argName}}',TypeInfo({{typeSource}}){{#isArgLast}}]);{{/isArgLast}}{{^isArgLast}},
|
||||
{{/isArgLast}}{{/args}} {{^args}}]);{{/args}}
|
||||
{{/methods}}
|
||||
exit;
|
||||
end;
|
||||
{{/soa.services}}
|
||||
end;
|
||||
|
||||
initialization
|
||||
{{#soa.services}}
|
||||
TInterfaceFactoryDefinition.RegisterInterface(TypeInfo({{interfaceName}}));
|
||||
{{/soa.services}}
|
||||
|
||||
{$endif HASINTERFACERTTI}
|
||||
{{/soa.enabled}}
|
||||
end.
|
@@ -0,0 +1,157 @@
|
||||
/// {{#units}}{{.}} {{/units}}generated types for a FPC mORMot server
|
||||
{{#uri}}
|
||||
// - retrieved from http://{{host}}/{{uri}}
|
||||
// at {{time}} using "{{templateName}}" template
|
||||
{{/uri}}
|
||||
{{^uri}}
|
||||
// - generated at {{time}}
|
||||
{{/uri}}
|
||||
unit {{fileName}};
|
||||
|
||||
(*
|
||||
WARNING:
|
||||
This unit has been generated by a mORMot {{mORMotVersion}} server.
|
||||
Any manual modification of this file may be lost after regeneration.
|
||||
|
||||
Synopse mORMot framework. Copyright (C) {{year}} Arnaud Bouchez
|
||||
Synopse Informatique - http://synopse.info
|
||||
|
||||
This unit is released under a MPL/GPL/LGPL tri-license,
|
||||
and therefore may be freely included in any application.
|
||||
|
||||
This unit is intended to work on older FPC compilers, which lack of RTTI
|
||||
for interfaces and records. As a result, you would be able to compile
|
||||
your server executable for hosting in Linux.
|
||||
|
||||
It will also include RTTI for records for versions prior to Delphi 2010.
|
||||
|
||||
USAGE:
|
||||
|
||||
1. Compile your code using latest versions of Delphi (which supports
|
||||
record definition as published properties since XE5)
|
||||
|
||||
2. Enumerations, sets, dynamic arrays and records type definitions
|
||||
would be shared from the original Delphi units
|
||||
|
||||
3. Add a reference to this {{fileName}} unit to your uses clause, so that
|
||||
missing RTTI would be available for the following types:
|
||||
{{#records}}
|
||||
- {{name}} record
|
||||
{{/records}}
|
||||
{{#soa.services}}
|
||||
- I{{interfaceURI}} interface
|
||||
{{/soa.services}}
|
||||
{{#ORMWithRecords}}
|
||||
|
||||
4. Ensure there is a reference to {$I Synopse.inc} at the beginning of the following units:
|
||||
{{#units}}
|
||||
- {{.}}.pas
|
||||
{{/units}}
|
||||
|
||||
5. Modify the following type definitions to include the information
|
||||
about record published properties:
|
||||
{{#orm}}
|
||||
{{#hasRecords}}
|
||||
|
||||
{{className}} = class({{classParent}}) // in {{unitName}}.pas
|
||||
...
|
||||
public
|
||||
{$ifndef PUBLISHRECORD} // defined in Synopse.inc
|
||||
class procedure InternalRegisterCustomProperties(Props: TSQLRecordProperties); override;
|
||||
{$endif}
|
||||
...
|
||||
|
||||
{$ifndef PUBLISHRECORD}
|
||||
class procedure {{className}}.InternalRegisterCustomProperties(Props: TSQLRecordProperties);
|
||||
begin
|
||||
{{#fields}}
|
||||
{{#isrecord}}
|
||||
Props.RegisterCustomPropertyFromRTTI(Self,TypeInfo({{typeDelphi}}),
|
||||
'{{name}}',@{{className}}(nil).f{{name}});
|
||||
{{/isrecord}}
|
||||
{{/fields}}
|
||||
end;
|
||||
{$endif}
|
||||
{{/hasRecords}}
|
||||
{{/orm}}
|
||||
{{/ORMWithRecords}}
|
||||
*)
|
||||
|
||||
interface
|
||||
|
||||
{$I Synopse.inc} // needed for setting HASINTERFACERTTI and proper FPC modes
|
||||
|
||||
uses
|
||||
SysUtils,
|
||||
Classes,
|
||||
SynCommons,
|
||||
mORMot,
|
||||
mORMotDDD{{#units}},
|
||||
{{.}}{{/units}};
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{$ifndef HASINTERFACERTTI} // circumvent a old FPC bug
|
||||
{{#soa.enabled}}
|
||||
|
||||
{ TInterfaceFactoryDefinition }
|
||||
|
||||
type
|
||||
/// define and manage missing interface RTTI for defined interfaces
|
||||
TInterfaceFactoryDefinition = class(TInterfaceFactoryGenerated)
|
||||
protected
|
||||
/// will declare the following types to the interface factory:
|
||||
{{#soa.services}}
|
||||
// - I{{interfaceURI}}
|
||||
{{/soa.services}}
|
||||
procedure AddMethodsFromTypeInfo(aInterface: PTypeInfo); override;
|
||||
end;
|
||||
|
||||
procedure TInterfaceFactoryDefinition.AddMethodsFromTypeInfo(aInterface: PTypeInfo);
|
||||
begin
|
||||
{{#soa.services}}
|
||||
if aInterface=TypeInfo(I{{interfaceURI}}) then begin
|
||||
{{#methods}}
|
||||
AddMethod('{{methodName}}',[
|
||||
{{#args}} ord(smd{{dirName}}),'{{argName}}',TypeInfo({{typeSource}}){{#isArgLast}}]);{{/isArgLast}}{{^isArgLast}},
|
||||
{{/isArgLast}}{{/args}}
|
||||
{{/methods}}
|
||||
exit;
|
||||
end;
|
||||
{{/soa.services}}
|
||||
end;
|
||||
|
||||
{$endif HASINTERFACERTTI}
|
||||
{{/soa.enabled}}
|
||||
{{#withRecords}}
|
||||
{{<textrec}}{{#fields}}{{propName}} {{#typeDelphi}}{{typeDelphi}}{{/typeDelphi}}{{#nestedRecord}}{ {{>textrec}} }{{/nestedRecord}}{{#nestedSimpleArray}}array of {{typeDelphi}}{{/nestedSimpleArray}}{{#nestedRecordArray}}[ {{>textrec}} ]{{/nestedRecordArray}} {{/fields}}{{/textrec}}
|
||||
|
||||
{$ifndef ISDELPHI2010}
|
||||
|
||||
const // text-based types definition for records and dynamic arrays
|
||||
{{#records}}
|
||||
__{{name}} = '{{>textrec}}';
|
||||
{{/records}}
|
||||
|
||||
{{/withRecords}}
|
||||
initialization
|
||||
{{#enumerates}}
|
||||
TTextWriter.RegisterCustomJSONSerializerFromTextSimpleType(
|
||||
TypeInfo({{name}}));
|
||||
{{/enumerates}}
|
||||
{{#records}}
|
||||
TTextWriter.RegisterCustomJSONSerializerFromText(
|
||||
TypeInfo({{name}}),__{{name}});
|
||||
{{/records}}
|
||||
{{#soa.enabled}}
|
||||
{$ifndef HASINTERFACERTTI} // circumvent a old FPC bug
|
||||
{{#soa.services}}
|
||||
TInterfaceFactoryDefinition.RegisterInterface(
|
||||
TypeInfo(I{{interfaceURI}}));
|
||||
{{/soa.services}}
|
||||
{$endif HASINTERFACERTTI}
|
||||
{{/soa.enabled}}
|
||||
|
||||
{$endif ISDELPHI2010}
|
||||
end.
|
@@ -0,0 +1,361 @@
|
||||
/// remote access to a mORMot server using SmartMobileStudio
|
||||
{{#uri}}
|
||||
// - retrieved from {{protocol}}://{{host}}/{{uri}}
|
||||
// at {{time}} using "{{templateName}}" template
|
||||
{{/uri}}
|
||||
{{^uri}}
|
||||
// - generated at {{time}}
|
||||
{{/uri}}
|
||||
unit {{fileName}};
|
||||
|
||||
{
|
||||
WARNING:
|
||||
This unit has been generated by a mORMot {{mORMotVersion}} server.
|
||||
Any manual modification of this file may be lost after regeneration.
|
||||
|
||||
Synopse mORMot framework. Copyright (C) {{year}} Arnaud Bouchez
|
||||
Synopse Informatique - http://synopse.info
|
||||
|
||||
This unit is released under a MPL/GPL/LGPL tri-license,
|
||||
and therefore may be freely included in any application.
|
||||
|
||||
This unit would work on Smart Mobile Studio 2.1.1 and later.
|
||||
}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
SmartCL.System,
|
||||
System.Types,
|
||||
SynCrossPlatformSpecific,
|
||||
SynCrossPlatformREST;
|
||||
|
||||
{{! recursive partials used to write records type definition}}
|
||||
{{<writerec}}record
|
||||
{{#fields}}
|
||||
{{nestedIdentation}} {{propName}}: {{#typePascal}}{{typePascal}};{{/typePascal}}{{#nestedRecord}}{{>writerec}}{{nestedIdentation}} end;{{/nestedRecord}}{{#nestedSimpleArray}}array of {{typePascal}};{{/nestedSimpleArray}}{{#nestedRecordArray}}array of {{>writerec}}{{nestedIdentation}} end;{{/nestedRecordArray}}
|
||||
{{/fields}}{{/writerec}}
|
||||
{{#withEnumerates}}
|
||||
type // define some enumeration types, used below
|
||||
{{#enumerates}}
|
||||
{{name}} = ({{#values}}{{.}}{{^-last}}, {{/-last}}{{/values}});
|
||||
{{/enumerates}}
|
||||
|
||||
{{/withEnumerates}}
|
||||
{{#withSets}}
|
||||
type // define some set types, used below
|
||||
{{#sets}}
|
||||
{{name}} = set of({{#values}}{{.}}{{^-last}}, {{/-last}}{{/values}});
|
||||
{{/sets}}
|
||||
|
||||
{{/withSets}}
|
||||
{{#withRecords}}
|
||||
type // define some record types, used as properties below
|
||||
{{#records}}
|
||||
{{name}} = {{>writerec}} end;
|
||||
|
||||
{{/records}}
|
||||
{{/withRecords}}
|
||||
{{#withArrays}}
|
||||
type // define some dynamic array types, used as properties below
|
||||
{{#arrays}}
|
||||
{{name}} = array of {{typeSource}};
|
||||
{{/arrays}}
|
||||
|
||||
{{/withArrays}}
|
||||
type{{<methodAsynch}}{{methodName}}({{#args}}{{#dirInput}}{{argName}}: {{typePascal}}; {{/dirInput}}{{/args}}
|
||||
onSuccess: procedure({{#args}}{{#dirOutput}}{{argName}}: {{typePascal}}{{commaOutResult}}{{/dirOutput}}{{/args}}); onError: TSQLRestEvent);{{/methodAsynch}}{{<methodSynch}}_{{methodName}}({{#args}}{{^dirResult}}{{dirNoOut}} {{argName}}: {{typePascal}}{{commaArg}}{{/dirResult}}{{/args}}){{#args}}{{#dirResult}}: {{typePascal}}{{/dirResult}}{{/args}};{{/methodSynch}}
|
||||
{{#orm}}
|
||||
{{^isInMormotPas}}
|
||||
/// map "{{tableName}}" table
|
||||
{{className}} = class(TSQLRecord)
|
||||
protected
|
||||
{{#fields}}
|
||||
f{{name}}: {{typePascal}};
|
||||
{{/fields}}
|
||||
// those overridden methods will emulate the needed RTTI
|
||||
class function ComputeRTTI: TRTTIPropInfos; override;
|
||||
procedure SetProperty(FieldIndex: integer; const Value: variant); override;
|
||||
function GetProperty(FieldIndex: integer): variant; override;
|
||||
public
|
||||
{{#fields}}
|
||||
{{#isSQLRecord}} // defined as {{name}}: {{typeDelphi}} on the server
|
||||
{{/isSQLRecord}}
|
||||
property {{name}}: {{typePascal}} read f{{name}} write f{{name}};
|
||||
{{/fields}}
|
||||
end;
|
||||
|
||||
{{/isInMormotPas}}
|
||||
{{/orm}}
|
||||
{{#soa.services}}
|
||||
/// service accessible {{#uri}}via {{protocol}}://{{host}}/{{root}}/{{uri}}{{/uri}}
|
||||
// - this service will run in sic{{instanceCreationName}} mode
|
||||
// - synchronous and asynchronous methods are available, depending on use case
|
||||
// - synchronous _*() methods will block the browser execution, so won't be
|
||||
// appropriate for long process - on error, they may raise EServiceException
|
||||
{{#isClientDriven}}
|
||||
// - you should call explicitly Free to release the server instance
|
||||
{{/isClientDriven}}
|
||||
TService{{interfaceURI}} = class(TServiceClientAbstract{{#isClientDriven}}ClientDriven{{/isClientDriven}})
|
||||
public
|
||||
/// will initialize an access to the remote service
|
||||
constructor Create(aClient: TSQLRestClientURI); override;
|
||||
{{#methods}}
|
||||
|
||||
procedure {{>methodAsynch}}
|
||||
{{verb}} {{>methodSynch}}
|
||||
{{/methods}}
|
||||
end;
|
||||
|
||||
{{/soa.services}}
|
||||
|
||||
const
|
||||
/// the server port{{#uri}}, corresponding to {{protocol}}://{{host}}{{/uri}}
|
||||
SERVER_PORT = {{port}};
|
||||
/// the server model root name{{#uri}}, corresponding to {{protocol}}://{{host}}/{{root}}{{/uri}}
|
||||
SERVER_ROOT = '{{root}}';
|
||||
|
||||
|
||||
/// return the database Model corresponding to this server
|
||||
function GetModel(aRoot: string=SERVER_ROOT): TSQLModel;
|
||||
|
||||
/// create a TSQLRestClientHTTP instance and connect to the server
|
||||
// - it will use by default port {{port}} over root '{{root}}'{{#host}}, corresponding
|
||||
// to {{protocol}}://{{host}}/{{root}}{{/host}}
|
||||
{{#authClass}}
|
||||
// - secure connection will be established via {{.}}
|
||||
// with the supplied credentials
|
||||
{{/authClass}}
|
||||
// - request will be asynchronous, and trigger onSuccess or onError event
|
||||
procedure GetClient(const aServerAddress{{#authClass}}, aUserName,aPassword{{/authClass}}: string;
|
||||
onSuccess, onError: TSQLRestEvent;
|
||||
aServerPort: integer=SERVER_PORT; aServerRoot: string=SERVER_ROOT;
|
||||
aHttps: boolean={{#https}}true{{/https}}{{^https}}false{{/https}});
|
||||
|
||||
{{#withHelpers}}
|
||||
// publish some low-level helpers for variant conversion
|
||||
// - used internally: you should not need those functions in your end-user code
|
||||
{{#enumerates}}
|
||||
function Variant2{{name}}(const _variant: variant): {{name}};
|
||||
function {{name}}ToText(const value: {{name}}): string;
|
||||
{{/enumerates}}
|
||||
{{#records}}
|
||||
function Variant2{{name}}(const Value: variant): {{name}};
|
||||
function {{name}}2Variant(const Value: {{name}}): variant;
|
||||
{{/records}}
|
||||
{{#arrays}}
|
||||
function Variant2{{name}}(const _variant: variant): {{name}};
|
||||
function {{name}}2Variant(const _array: {{name}}): variant;
|
||||
{{/arrays}}
|
||||
|
||||
{{/withHelpers}}
|
||||
|
||||
implementation
|
||||
{{<setrec}}{{#fields}}
|
||||
{{#isSimple}} result.{{fullPropName}} := Value.{{fullPropName}};
|
||||
{{/isSimple}}{{#nestedRecord}}{{>setrec}}{{/nestedRecord}}{{#fromVariant}} result.{{fullPropName}} := {{fromVariant}}(Value.{{fullPropName}});
|
||||
{{/fromVariant}}{{#nestedSimpleArray}} if VariantType(Value.{{fullPropName}})=jvArray then
|
||||
for var i := 0 to integer(Value.{{fullPropName}}.length)-1 do
|
||||
result.{{fullPropName}}.Add({{typePascal}}(Value.{{fullPropName}}[i]));
|
||||
{{/nestedSimpleArray}}{{#nestedRecordArray}} if VariantType(Value.{{fullPropName}})=jvArray then begin
|
||||
var tmp: {{name}};
|
||||
tmp.{{propName}}.SetLength(1);
|
||||
for var n := 0 to integer(Value.{{fullPropName}}.length)-1 do begin
|
||||
var source := Value.{{fullPropName}}[n];
|
||||
var dest := tmp.{{propName}}[0];
|
||||
{{#fields}}
|
||||
dest.{{propName}} := {{#fromVariant}}{{fromVariant}}({{/fromVariant}}source.{{propName}}{{#fromVariant}}){{/fromVariant}};
|
||||
{{/fields}}
|
||||
result.{{fullPropName}}.Add(dest);
|
||||
end;
|
||||
end;
|
||||
{{/nestedRecordArray}}{{/fields}}{{/setrec}}
|
||||
{{<getrec}}{{#fields}}
|
||||
{{#isSimple}} result.{{fullPropName}} := Value.{{fullPropName}};
|
||||
{{/isSimple}}{{#nestedRecord}} result.{{fullPropName}} := new JObject;
|
||||
{{>getrec}}{{/nestedRecord}}{{#toVariant}} result.{{fullPropName}} := {{toVariant}}(Value.{{fullPropName}});
|
||||
{{/toVariant}}{{#nestedSimpleArray}} result.{{fullPropName}} := variant(Value.{{fullPropName}});
|
||||
{{/nestedSimpleArray}}{{#nestedRecordArray}} result.{{fullPropName}} := TVariant.CreateArray;
|
||||
for var source in Value.{{fullPropName}} do begin
|
||||
var dest: variant := new JObject;
|
||||
{{#fields}}
|
||||
dest.{{propName}} := {{#toVariant}}{{toVariant}}({{/toVariant}}source.{{propName}}{{#toVariant}}){{/toVariant}};
|
||||
{{/fields}}
|
||||
result.{{fullPropName}}.push(dest);
|
||||
end;
|
||||
{{/nestedRecordArray}}{{/fields}}{{/getrec}}
|
||||
{{#withEnumerates}}
|
||||
{ Some helpers for enumerates types }
|
||||
|
||||
{$HINTS OFF} // for begin asm return ... end; end below
|
||||
|
||||
// those functions will use the existing generated string array constant
|
||||
// defined by the SMS compiler for each enumeration
|
||||
|
||||
{{#enumerates}}
|
||||
function Variant2{{name}}(const _variant: variant): {{name}};
|
||||
begin
|
||||
asm return @VariantToEnum(@_variant,@{{name}}); end;
|
||||
end;
|
||||
|
||||
function {{name}}ToText(const value: {{name}}): string;
|
||||
begin
|
||||
asm return @{{name}}[@value]; end;
|
||||
end;
|
||||
|
||||
{{/enumerates}}
|
||||
{$HINTS ON}
|
||||
|
||||
{{/withEnumerates}}
|
||||
{{#withRecords}}
|
||||
{ Some helpers for record types:
|
||||
due to potential obfuscation of generated JavaScript, we can't assume
|
||||
that the JSON used for transmission would match record fields naming }
|
||||
{{#records}}
|
||||
|
||||
function Variant2{{name}}(const Value: variant): {{name}};
|
||||
begin
|
||||
{{>setrec}}
|
||||
end;
|
||||
|
||||
function {{name}}2Variant(const Value: {{name}}): variant;
|
||||
begin
|
||||
result := new JObject;
|
||||
{{>getrec}}
|
||||
end;
|
||||
{{/records}}
|
||||
|
||||
{{/withRecords}}
|
||||
{{#withArrays}}
|
||||
|
||||
{ Some helpers for dynamic array types }
|
||||
|
||||
{{#arrays}}
|
||||
function Variant2{{name}}(const _variant: variant): {{name}};
|
||||
var tmp: {{typeSource}};
|
||||
begin
|
||||
if VariantType(_variant)=jvArray then
|
||||
for var i := 0 to integer(_variant.Length)-1 do begin
|
||||
tmp := {{#fromVariant}}{{fromVariant}}{{/fromVariant}}(_variant[i]);
|
||||
result.Add(tmp);
|
||||
end;
|
||||
end;
|
||||
|
||||
function {{name}}2Variant(const _array: {{name}}): variant;
|
||||
var i: integer;
|
||||
begin
|
||||
result := TVariant.CreateArray;
|
||||
for i := 0 to high(_array) do
|
||||
result.push({{#toVariant}}{{toVariant}}{{/toVariant}}(_array[i]));
|
||||
end;
|
||||
|
||||
{{/arrays}}
|
||||
{{/withArrays}}
|
||||
{{#orm}}
|
||||
|
||||
{{^isInMormotPas}}
|
||||
|
||||
{ {{className}} }
|
||||
|
||||
class function {{className}}.ComputeRTTI: TRTTIPropInfos;
|
||||
begin
|
||||
result := TRTTIPropInfos.Create(
|
||||
[{{#fields}}'{{name}}'{{comma}}{{/fields}}],
|
||||
[{{#fields}}{{typekindname}}{{comma}}{{/fields}}]);
|
||||
end;
|
||||
|
||||
procedure {{className}}.SetProperty(FieldIndex: integer; const Value: variant);
|
||||
begin
|
||||
case FieldIndex of
|
||||
0: fID := Value;
|
||||
{{#fields}}
|
||||
{{index}}: f{{name}} := {{#fromVariant}}{{fromVariant}}({{/fromVariant}}Value{{#fromVariant}}){{/fromVariant}};
|
||||
{{/fields}}
|
||||
end;
|
||||
end;
|
||||
|
||||
function {{className}}.GetProperty(FieldIndex: integer): variant;
|
||||
begin
|
||||
case FieldIndex of
|
||||
0: result := fID;
|
||||
{{#fields}}
|
||||
{{index}}: result := {{#toVariant}}{{toVariant}}({{/toVariant}}f{{name}}{{#toVariant}}){{/toVariant}};
|
||||
{{/fields}}
|
||||
end;
|
||||
end;
|
||||
|
||||
{{/isInMormotPas}}
|
||||
{{/orm}}
|
||||
|
||||
function GetModel(aRoot: string): TSQLModel;
|
||||
begin
|
||||
result := TSQLModel.Create([{{#orm}}{{className}}{{comma}}{{/orm}}],aRoot);
|
||||
end;
|
||||
|
||||
procedure GetClient(const aServerAddress{{#authClass}}, aUserName,aPassword{{/authClass}}: string;
|
||||
onSuccess, onError: TSQLRestEvent; aServerPort: integer; aServerRoot: string;
|
||||
aHttps: boolean);
|
||||
begin
|
||||
var client := TSQLRestClientHTTP.Create(aServerAddress,aServerPort,
|
||||
GetModel(aServerRoot),true,aHttps); // aOwnModel=true
|
||||
client.Connect(
|
||||
lambda
|
||||
try
|
||||
if client.ServerTimeStamp=0 then begin
|
||||
if Assigned(onError) then
|
||||
onError(client);
|
||||
exit;
|
||||
end;
|
||||
{{#authClass}}
|
||||
if not client.SetUser({{.}},aUserName,aPassword) then begin
|
||||
if Assigned(onError) then
|
||||
onError(client);
|
||||
exit;
|
||||
end;
|
||||
{{/authClass}}
|
||||
if Assigned(onSuccess) then
|
||||
onSuccess(client);
|
||||
except
|
||||
if Assigned(onError) then
|
||||
onError(client);
|
||||
end;
|
||||
end,
|
||||
onError);
|
||||
end;
|
||||
|
||||
{{#soa.services}}
|
||||
|
||||
{ TService{{interfaceURI}} }
|
||||
|
||||
constructor TService{{interfaceURI}}.Create(aClient: TSQLRestClientURI);
|
||||
begin
|
||||
fServiceName := '{{interfaceURI}}';
|
||||
fServiceURI := '{{uri}}';
|
||||
fInstanceImplementation := sic{{instanceCreationName}};
|
||||
fContractExpected := '{{contractExpected}}';
|
||||
inherited Create(aClient);
|
||||
end;
|
||||
|
||||
|
||||
{{#methods}}
|
||||
procedure TService{{interfaceURI}}.{{>methodAsynch}}
|
||||
begin
|
||||
fClient.CallRemoteServiceAsynch(self,'{{methodName}}',{{ArgsOutputCount}},
|
||||
[{{#args}}{{#dirInput}}{{#toVariant}}{{toVariant}}({{argName}}){{/toVariant}}{{^toVariant}}{{argName}}{{/toVariant}}{{commaInSingle}}{{/dirInput}}{{/args}}],
|
||||
lambda (res: array of Variant)
|
||||
onSuccess({{#args}}{{#dirOutput}}{{#fromVariant}}{{fromVariant}}({{/fromVariant}}res[{{indexOutResult}}{{#fromVariant}}){{/fromVariant}}{{#commaOutResult}},{{/commaOutResult}}{{/dirOutput}}{{/args}});
|
||||
end, onError{{#resultIsServiceCustomAnswer}}, true{{/resultIsServiceCustomAnswer}});
|
||||
end;
|
||||
|
||||
{{verb}} TService{{interfaceURI}}.{{>methodSynch}}
|
||||
begin
|
||||
var res := fClient.CallRemoteServiceSynch(self,'{{methodName}}',{{ArgsOutputCount}},
|
||||
[{{#args}}{{#dirInput}}{{#toVariant}}{{toVariant}}({{argName}}){{/toVariant}}{{^toVariant}}{{argName}}{{/toVariant}}{{commaInSingle}}{{/dirInput}}{{/args}}]{{#resultIsServiceCustomAnswer}},true{{/resultIsServiceCustomAnswer}});
|
||||
{{#args}}{{#dirOutput}} {{argName}} := {{#fromVariant}}{{fromVariant}}({{/fromVariant}}res[{{indexOutResult}}{{#fromVariant}}){{/fromVariant}};
|
||||
{{/dirOutput}}{{/args}}end;
|
||||
|
||||
|
||||
{{/methods}}
|
||||
{{/soa.services}}
|
||||
|
||||
end.
|
395
contrib/mORMot/CrossPlatform/templates/Swagger.json.mustache
Normal file
395
contrib/mORMot/CrossPlatform/templates/Swagger.json.mustache
Normal file
@@ -0,0 +1,395 @@
|
||||
{{! recursive partial used to expand type definition
|
||||
HACK: Objects, Enums, Records and Arrays, which are used by reference
|
||||
and defined outside the main units have to be handled explicitly.
|
||||
All internal types have their Swagger-Typ defined. }}
|
||||
{{<write-type}}{{#typeSwagger}}{{#Equals typeSwagger,typeSource}}{"$ref":"#/definitions/{{typeSwagger}}"}{{/Equals}}{{^Equals typeSwagger,typeSource}}{{typeSwagger}}{{/Equals}}{{/typeSwagger}}{{^typeSwagger}}{{#nestedSimpleArray}}{"type":"array","items":{{>write-type}}}{{/nestedSimpleArray}}{{/typeSwagger}}{{/write-type}}
|
||||
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "Generated by {{exeInfo}} using mORMot {{mORMotVersion}} at {{time}}",
|
||||
"title": "{{root}} API{{#exeVersion}} {{.}}{{/exeVersion}}",
|
||||
"version": "{{exeVersion}}"
|
||||
},
|
||||
"host": "{{host}}",
|
||||
"basePath": "/{{root}}",
|
||||
"tags": [
|
||||
{{#orm}}
|
||||
{
|
||||
"name": "{{tableName}}",
|
||||
"description": "ORM endpoint for {{root}}/{{tableName}} record"
|
||||
}{{^-last}},{{/-last}}
|
||||
{{/orm}}
|
||||
{{#soa}}{{#hasorm}},{{/hasorm}}
|
||||
{{#services}}
|
||||
{
|
||||
"name": "{{uri}}",
|
||||
"description": {{#serviceDescription}}{{jsonQuote serviceDescription}}{{/serviceDescription}}{{^serviceDescription}}"SOA endpoint for {{root}}/{{uri}} service"{{/serviceDescription}}
|
||||
}{{^-last}},{{/-last}}
|
||||
{{/services}}
|
||||
{{/soa}}
|
||||
],
|
||||
|
||||
"definitions": {
|
||||
{{#orm}}
|
||||
"{{tableName}}": {
|
||||
"type": "object",
|
||||
"description": "ORM {{tableName}} record definition",
|
||||
"properties": {
|
||||
"ID":{"type":"integer","format":"int64"}{{#fields}},"{{name}}":{{typeSwagger}}{{/fields}}
|
||||
}
|
||||
},
|
||||
{{/orm}}
|
||||
{{#records}}
|
||||
"{{name}}": {
|
||||
"type": "object",
|
||||
"description": "SOA {{name}} object DTO definition",
|
||||
"properties": {
|
||||
{{#fields}}
|
||||
"{{propName}}": {{>write-type}}{{^-last}},{{/-last}}
|
||||
{{/fields}}
|
||||
}
|
||||
},
|
||||
|
||||
{{/records}}
|
||||
{{#arrays}}
|
||||
"{{name}}": {
|
||||
"type": "array",
|
||||
"summary": "SOA {{name}} array DTO definition",
|
||||
"items": {{>write-type}}
|
||||
},
|
||||
{{/arrays}}
|
||||
{{#enumerates}}
|
||||
"{{name}}": {
|
||||
"type": "string",
|
||||
"description": "SOA {{name}} enumeration DTO definition",
|
||||
"enum": [
|
||||
{{#values}}
|
||||
"{{.}}"{{^-last}},{{/-last}}
|
||||
{{/values}}
|
||||
],
|
||||
"required": true
|
||||
},
|
||||
|
||||
{{/enumerates}}
|
||||
"__error": {
|
||||
"type": "object",
|
||||
"description": "Generic error information",
|
||||
"properties": {
|
||||
"errorCode": {"type":"integer"},"errorText":{"type":"string"} }
|
||||
}
|
||||
},
|
||||
"paths": {
|
||||
{{#orm}}
|
||||
|
||||
"/{{tableName}}":{
|
||||
"get": {
|
||||
"tags": [
|
||||
"{{tableName}}"
|
||||
],
|
||||
"summary": "query ORM fields values on {{tableName}}",
|
||||
"description": "",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"parameters": [{
|
||||
"name": "select",
|
||||
"in": "query",
|
||||
"description": "define returned fields of {{tableName}} query, set * to return all fields",
|
||||
"required": true,
|
||||
"type":"string"
|
||||
},{
|
||||
"name": "where",
|
||||
"in": "query",
|
||||
"description": "SELECT-like where condition for {{tableName}} query",
|
||||
"required": false,
|
||||
"type":"string"
|
||||
},{
|
||||
"name": "sort",
|
||||
"in": "query",
|
||||
"description": "order fields for {{tableName}} query",
|
||||
"required": false,
|
||||
"type":"string"
|
||||
}],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/{{tableName}}"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "{{tableName}} not properly accessed",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/__error"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "{{tableName}} not found"
|
||||
},
|
||||
"405": {
|
||||
"description": "Unauthorized access to {{tableName}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/{{tableName}}/":{
|
||||
"get": {
|
||||
"tags": [
|
||||
"{{tableName}}"
|
||||
],
|
||||
"summary": "retrieve all {{tableName}} ORM ids",
|
||||
"description": "",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"parameters": [],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/{{tableName}}"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "{{tableName}} not properly accessed",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/__error"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "{{tableName}} not found"
|
||||
},
|
||||
"405": {
|
||||
"description": "Unauthorized access to {{tableName}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
, "post": {
|
||||
"tags": [
|
||||
"{{tableName}}"
|
||||
],
|
||||
"summary": "creates a new {{tableName}} ORM record",
|
||||
"description": "",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"parameters": [{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"description": "new {{tableName}} JSON object content",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/{{tableName}}"
|
||||
},
|
||||
"required": true
|
||||
}],
|
||||
"responses": {
|
||||
"201": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/{{tableName}}"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "{{tableName}} not writable or not properly accessed",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/__error"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "{{tableName}} not found"
|
||||
},
|
||||
"405": {
|
||||
"description": "Unauthorized access to {{tableName}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/{{tableName}}/{id}":{
|
||||
"get": {
|
||||
"tags": [
|
||||
"{{tableName}}"
|
||||
],
|
||||
"summary": "retrieve a {{tableName}} ORM record by id",
|
||||
"description": "",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"parameters": [{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"description": "id to query {{tableName}}",
|
||||
"required": true,
|
||||
"type": "integer",
|
||||
"format":"int64"
|
||||
}],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/{{tableName}}"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "{{tableName}} not properly accessed",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/__error"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "{{tableName}} not found"
|
||||
},
|
||||
"405": {
|
||||
"description": "Unauthorized access to {{tableName}}"
|
||||
}
|
||||
}
|
||||
}, "put": {
|
||||
"tags": [
|
||||
"{{tableName}}"
|
||||
],
|
||||
"summary": "change a {{tableName}} ORM record by id",
|
||||
"description": "",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"parameters": [{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"description": "id to update {{tableName}}",
|
||||
"required": true,
|
||||
"type": "integer",
|
||||
"format":"int64"
|
||||
},{
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/{{tableName}}"
|
||||
},
|
||||
"description": "modified {{tableName}} JSON object content (partial fields accepted)",
|
||||
"required": true
|
||||
}],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/{{tableName}}"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "{{tableName}} not writable or not properly accessed",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/__error"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "{{tableName}} not found"
|
||||
},
|
||||
"405": {
|
||||
"description": "Unauthorized access to {{tableName}}"
|
||||
}
|
||||
}
|
||||
},"delete": {
|
||||
"tags": [
|
||||
"{{tableName}}"
|
||||
],
|
||||
"summary": "remove a {{tableName}} ORM record by id",
|
||||
"description": "",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"parameters": [{
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"description": "id to delete {{tableName}}",
|
||||
"required": true,
|
||||
"type": "integer",
|
||||
"format":"int64"
|
||||
}],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/{{tableName}}"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "{{tableName}} not writable or not properly accessed",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/__error"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "{{tableName}} not found"
|
||||
},
|
||||
"405": {
|
||||
"description": "Unauthorized access to {{tableName}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}{{^-last}},{{/-last}}
|
||||
|
||||
{{/orm}}
|
||||
{{#soa}}{{#hasorm}},{{/hasorm}}{{#services}}
|
||||
{{#methods}}
|
||||
"/{{uri}}/{{methodName}}": {
|
||||
"post": {
|
||||
"description": {{jsonQuote methodDescription}},
|
||||
"tags": [
|
||||
"{{uri}}"
|
||||
],
|
||||
"parameters": [{
|
||||
"in": "body",
|
||||
"name": "body",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": { {{#args}}{{#dirInput}}
|
||||
"{{argName}}": {{>write-type}}{{commaInSingle}}{{/dirInput}}{{/args}}
|
||||
}
|
||||
}
|
||||
}],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "{{uri}}.{{methodName}} executed - check returned content for any application-level error{{^resultAsJSONObjectWithoutResult}}\r\n **Warning: Swagger doesn't support untyped arrays, so isn't able to correctly define the response - please use rather *ResultAsJSONObjectWithoutResult* for a public API**{{/resultAsJSONObjectWithoutResult}}",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
{{#resultAsJSONObjectWithoutResult}}
|
||||
{{#args}} {{#dirOutput}}
|
||||
"{{argName}}": {{>write-type}}{{#commaOutResult}},{{/commaOutResult}}
|
||||
{{/dirOutput}}{{/args}}
|
||||
{{/resultAsJSONObjectWithoutResult}}
|
||||
{{^resultAsJSONObjectWithoutResult}}
|
||||
"result": {
|
||||
"type": "array",
|
||||
"items": {"type":"string"}
|
||||
}
|
||||
{{/resultAsJSONObjectWithoutResult}}
|
||||
}
|
||||
}
|
||||
},
|
||||
"401": {
|
||||
"description": "{{uri}}.{{methodName}} execution not allowed",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/__error"
|
||||
}
|
||||
},
|
||||
"403": {
|
||||
"description": "{{uri}}.{{methodName}} not properly accessed",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/__error"
|
||||
}
|
||||
},
|
||||
"406": {
|
||||
"description": "{{uri}}.{{methodName}} execution failed - probably due to unexpected input",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/__error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}{{^-last}},{{/-last}}
|
||||
{{/methods}}{{^-last}},{{/-last}}
|
||||
|
||||
{{/services}}{{/soa}}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user