RestGenerator is a DSL package (a plugin module) for Rhetos development platform. It automatically generates RESTful JSON web service for all entities, actions and other data structures that are defined in a Rhetos application.
See rhetos.org for more information on Rhetos.
For each data structure, a service is available at <rhetos server url>/Rest/<module name>/<entity name>
.
Example - a service for entity Claim in module Common, on default local server installation:
- Base service URI (reading service metadata):
http://localhost/Rhetos/Rest/Common/Claim
- Reading all entity's records:
http://localhost/Rhetos/Rest/Common/Claim/
(don't forget the slash at the end)
Following are URI templates for the web methods.
Reading data:
- Reading records:
/?filters={{filters}}&top={{top}}&skip={{skip}}&sort={{sort}}
- For filters, see Filters paragraph below.
- Example of sorting by multiple properties:
sort=CreationDate desc,Name,ID
.
- Reading total records count for paging:
/TotalCount?filters={{filters}}&sort={{sort}}
- Reading records and total count:
/RecordsAndTotalCount?filters={{filters}}&top={{top}}&skip={{skip}}&sort={{sort}}
- Reading a single record:
/{{id}}
Writing data:
- Inserting a record: POST at the entity's service base URI.
- Updating a record: PUT
/{{id}}
- Deleting a record: DELETE
/{{id}}
Actions:
- Executing an action: POST at the action's service base URI.
Reports:
- Downloading a report:
/?parameter={{parameter}}&convertFormat={{convertFormat}}
- Query parameters
parameter
andconvertFormat
are optional. - Example format
http://localhost/Rhetos/Rest/TestModule/TestReport/?parameter={"Prefix":"a"}&convertFormat=pdf
- Query parameters
Filters are given as a JSON-serialized array containing any number of filters of the following types:
- Property filter
- Example: select items where year is greater than 2005:
[{"Property":"Year","Operation":"Greater", "Value":2005}]
- Available operations:
Equals
,NotEquals
,Greater
,GreaterEqual
,Less
,LessEqual
,StartsWith
,EndsWith
,Contains
,NotContains
-- String only,DateIn
,DateNotIn
-- Date or DateTime property only, provided value must be string. Returns whether the property's value is within a given day, month or year. Valid value format is yyyy-mm-dd, yyyy-mm or yyyy.
- Example: select items where year is greater than 2005:
- Predefined filter without a parameter
- Example: select active records (filter name: "Common.Active"):
[{"Filter":"Common.Active"}]
- Example: select active records (filter name: "Common.Active"):
- Predefined filter with a parameter
- Example: select records that contain pattern "abc" (filter name: "Common.SmartSearch" with parameter property "Pattern"):
[{"Filter":"Common.SmartSearch","Value":{"Pattern":"abc"}}]
- Example: select records that contain pattern "abc" (filter name: "Common.SmartSearch" with parameter property "Pattern"):
When combining multiple filters, the intersection of the filters is returned (AND).
These features are available for backward compatibility. They will be removed in future versions.
/Count
WEB API method. Use/TotalCount
method instead.- Reading method query parameters
page
andpsize
. Usetop
andskip
. - Reading method query parameters
filter
andfparam
. Usefilters
instead (see "Predefined filter with a parameter"). - Reading method query parameter
genericfilter
. Renamed tofilters
. - Property filter operations
Equal
andNotEqual
. UseEquals
andNotEquals
instead.
- CommonConcepts package must be deployed along with RestGenerator.
- Build utilities in this project are based on relative path to Rhetos repository.
Rhetos source should be downloaded to a folder
with relative path
..\..\Rhetos
and compiled (useBuild.bat
), before this package'sBuild.bat
script is executed.
Sample folder structure:
\ROOT
\Rhetos
\RhetosPackages
\RestGenerator
- Build this package by executing
Build.bat
. The script will pause in case of an error.- The script automatically copies all needed dll files from Rhetos folder and builds the Rhetos.RestGenerator.sln using Visual Studio (command-line).
- Set the new version number in
ChangeVersion.bat
and execute it. - Execute
Build.bat
. - Execute
CreatePackage.bat
. It creates installation package (.zip) in parent directory of RestGenerator.