Metadata API

It is possible to introspect the entity structure and relationships between entities in Jmix via the Metadata mechanism. You can access these capabilities through the REST API endpoints starting with /metadata

The Metadata API consists of the following endpoints:

  • Entity Metadata information about entities and entity attributes.

  • Fetch Plans information about available Fetch Plans.

  • Enum Values information about available Enums and their possible values.

Entity Metadata

The Entity Metadata API consists of two endpoints that allow retrieving information about the entity attributes:

/metadata/entities

Metadata descriptions for all entities

/metadata/entities/:entityName

Metadata descriptions of the given entity

Order Entity Metadata Request
GET http://localhost:8080/rest
            /metadata
            /entities
            /rstex11_Order
Response: 200 - OK
{
  "entityName": "rstex11_Order",
  "ancestor": null,
  "properties": [
    {
      "name": "date",
      "attributeType": "DATATYPE",
      "type": "localDate",
      "cardinality": "NONE",
      "mandatory": true,
      "readOnly": false,
      "description": "Date",
      "persistent": true,
      "transient": false
    },
    {
      "name": "amount",
      "attributeType": "DATATYPE",
      "type": "decimal",
      "cardinality": "NONE",
      "mandatory": true,
      "readOnly": false,
      "description": "Amount",
      "persistent": true,
      "transient": false
    },
    {
      "name": "id",
      "attributeType": "DATATYPE",
      "type": "uuid",
      "cardinality": "NONE",
      "mandatory": true,
      "readOnly": false,
      "description": "Id",
      "persistent": true,
      "transient": false
    },
    {
      "name": "lines",
      "attributeType": "COMPOSITION",
      "type": "rstex11_OrderLine",
      "cardinality": "ONE_TO_MANY",
      "mandatory": false,
      "readOnly": false,
      "description": "Lines",
      "persistent": true,
      "transient": false
    },
    {
      "name": "customer",
      "attributeType": "ASSOCIATION",
      "type": "rstex11_Customer",
      "cardinality": "MANY_TO_ONE",
      "mandatory": true,
      "readOnly": false,
      "description": "Customer",
      "persistent": true,
      "transient": false
    }
  ]
}

Fetch Plans

The Fetch Plan Metadata API exposes information of the structure of the available fetch plans for a given entity. It consists of the two endpoints:

/metadata/entities/:entityName/fetchPlans

All available fetch plans of the given entity

/metadata/entities/:entityName/fetchPlans/:fetchPlanName

Information about a particular fetch plan

In the following example all fetch plans are requested for the rstex11_Order entity:

Available Order Fetch Plans Request
GET http://localhost:8080/rest
            /metadata
            /entities
            /rstex11_Order
            /fetchPlans
Response: 200 - OK
[
  {
    "name": "order-with-details",
    "entity": "rstex11_Order",
    "properties": [
      "date",
      "amount",
      "createdDate",
      "createdBy",
      "lastModifiedDate",
      "deletedDate",
      "lastModifiedBy",
      "id",
      "version",
      "deletedBy",
      "customer",
      {
        "name": "lines",
        "fetchPlan": {
          "name": "_base",
          "properties": [
            "quantity",
            "createdDate",
            "createdBy",
            "lastModifiedDate",
            "deletedDate",
            "lastModifiedBy",
            "id",
            "version",
            "deletedBy",
            {
              "name": "product",
              "fetchPlan": {
                "name": "_instance_name",
                "properties": [
                  "name"
                ]
              }
            }
          ]
        }
      }
    ]
  }
]

Enum Values

The Enum Metadata API provides information about possible values for Enums.

/metadata/enums

Names and values of all enums

/metadata/enums/:enumClassName

Names and values of a given enum

The parameter :enumClassName should contain the full qualified class name of the enum. Example: rest.sample.entity.CustomerType instead of just CustomerType.

In the following example information about the rest.sample.entity.CustomerType enum is requested:

Enum Values Request
GET http://localhost:8080/rest
            /metadata
            /enums
            /rest.sample.entity.CustomerType
Response: 200 - OK
{
  "name": "rest.sample.entity.CustomerType",
  "values": [
    {
      "name": "BUSINESS",
      "id": "BUSINESS",
      "caption": "Business"
    },
    {
      "name": "PRIVATE",
      "id": "PRIVATE",
      "caption": "Private"
    }
  ]
}