JSON Schema
The rest APIs describe the resource using JSON schema standards. Maximo metadata contains more information than JSON schema supports. Therefore, the schema specification is extended with Maximo specific properties that contains more information from the Maximo metadata. Schema’s can be accessed in couple of ways using the REST APIs. A jsonschemas
route provides schema to any object structure. The following example shows that:
GET /oslc/jsonschemas/mxapiwodetail
The JSON schema for the root object of the object structure is returned and contains links to the child objects, such as INVRESERVE
. To get the schema for all the objects in the OS, you need to include the request parameter oslc.select=*
. This fetches all the child objects inline into the root object schema while retaining the hierarchy structure.
Note also that the properties in the schema map to the MBO attributes (which are included as part of the OS). They also have the JSON schema type as well as the subtype
that has the more specific Maximo type.
Additionally, you can specify the oslc.select
clause to filter out the part of the object structure that you need. An example is shown below:
GET /oslc/jsonschemas/mxapiwodetail?oslc.select=wonum,status,invreserve{*}
Details about the workorder
, wonum
, and status
attributes and all attributes from the invreserve
child object are provided .
There is an alternative method to get the schema while you are fetching details in a collection query. The following query is a simple collection query:
GET /oslc/os/mxwodetail?oslc.select=wonum,status,description,invreserve{itemnum},asset.assetnum,asset.status
In addition to fetching the work order records, if you want the schema for this oslc.select
clause that fetches part details from workorder
(wonum
etc), part from invreserve
, and part
from asset (which is not even part of the OS), by using the dot notation, you add the query parameter addschema=1
to the request URL. When you add the parameter, the response JSON objects responseInfo
property will have the schema inlined inside it. This returns the data and the metadata in the same REST API call. Note that this schema will not be fetched for the next page request beacause the next page URL will not have the addschema=1
in the URI. However, if you add that query parameter explicitly, it fetches the schema for any page.
Support for MBO schemas is available for use cases where you need to fetch a related MboSet using the REST API without using the responseos
query parameter. For example, if you want to evaluate the getlist
API for an attribute, such as the status for a given work order, you might use the following API:
GET /oslc/os/mxapiwodetail/{id}/getlist~status?oslc.select=*
This API returns the possible list of status values for that work order state. The response is a serialized version of the synonymdomain
MBO and is not an object structure. If you want to have a schema for the response, you can add the query parameter &addschema=1
, which works for the response MboSet, without needing to set it as an object structure.
GET /oslc/os/mxapiwodetail/{id}/getlist~status?oslc.select=*&addschema=1
This MBO schema can also be accessed standalone by using the jsonmboschemas
route. The following example shows a sample call:
GET /oslc/jsonmboschemas/asset?oslc.select=assetnum,status,location.description,location.status,rel.openwo{wonum,status}
The sample call returns the JSON schema for asset
MBO with the attributes assetnum
and status
, along with the related attributes from location
and workorder
(using the rel.openwo
).
Similarly, when you access some relation as a Mbo(Set), you can apply JSON schemas without using an object structure. The following example shows the use case:
GET /oslc/os/mxapipo/{rest id}/vendor?addschema=1&oslc.select=*
The related vendor for the PO
is accessed and you do not use any responseos
query parameter to render the response to as an OS, but you can access the schema of the vendor
(which is the companies
MBO).