REST Views
In iDempiere, models typically have many columns and use a database-oriented naming convention. This structure may not align well with typical JSON schema practices. To address this, the REST View feature introduces a layer of abstraction, allowing developers to configure a simplified, JSON-oriented schema on top of iDempiere models.
Overview
REST Views provide a mechanism to:
- Select a subset of columns relevant to specific use cases.
- Rename fields for better readability and consistency with frontend naming conventions.
- Configure expand behavior for master-detail relationships.
Core Window and Tabs in iDempiere
Rest_View
Name: Name of the viewAD_Table_ID: Reference to the iDempiere tableWhereClause: Optional filter for the data
Rest_ViewColumn
Name: JSON field nameRest_View_ID: Associated REST ViewAD_Column_ID: Reference to the database columnREST_ReferenceView_ID: (Optional) Reference to another REST View for expanding master data
Rest_ViewRelated
Name: Relation nameRest_View_ID: Associated REST ViewREST_RelatedRestView_ID: Reference to related REST View for detail dataIsRestAutoExpand: Automatically expand related data when fetching a record by ID
API Endpoints
These endpoints behave identically to those under api/v1/models, but they operate on the defined REST Views instead of raw database models.
GET /api/v1/views
Retrieve the list of active REST View definitions (Rest_View, Rest_ViewColumn, Rest_ViewRelated).
Usage
You can use any model-based API method with REST Views by simply replacing:
modelswithviews{tableName}with{viewName}
Examples
GET /api/v1/views/{viewName}— Equivalent to querying all records from a modelGET /api/v1/views/{viewName}/{id}— Equivalent to fetching a single record by IDPOST /api/v1/views/{viewName}— Create a record based on the REST View schema
For more information and examples, see: GitHub Issue #281