Application Packaging Standard

Last updated 18-Mar-2019

Type Inheritance

This document describes the rules that developers of APS packages should follow when they create or use an APS type derived from other APS types.

Inheritance Rules

A derived type (a child) must have at least one implements property that refers to the parent type inherited by the child.

General rules for the case when one declares an APS type (type-1) that implements another APS type (type-0):

  • It is allowed to add new properties, operations, or relations if their name attributes do not match a name of corresponding inherited elements (properties, operations, or relations).
  • It is not possible to delete properties, operations, or relations declared in the parent type (type-0).
  • If one needs to add definition of an attribute or change it in a property, operation, or relation, then the whole property, operation, or relation with all its attributes must be redefined in the derived type (type-1). Otherwise, the default values would be assigned to all non-defined attributes.

Properties and Structures

It is allowed to add new properties if their names do not match a name of an inherited property:

../../../../_images/inheritance-new-property.png

However, it is not allowed to change data declarations in non-backwards-compatible manner. For example, it is not allowed to change the type attribute:

../../../../_images/inheritance-change-type.png

Operations

When redefining an operation, only backwards-compatible changes in signatures are allowed. Actually, you can only add optional parameters. Those parameters should be declared after parameters of the base type.

Example:

/* Base Type */
{
  "stop": {
      "path": "/stop",
      "verb": "PUT",
      "parameters": { }
  }
}
/* Derived Type */
{
   "stop": {
      "path": "/stop",
      "verb": "PUT",
      "parameters": {
          "poweroff": { "kind": "query", "type": "boolean", "required": false }
      }
   }
}

Relationship

It is allowed to define new relations in derived types, however the name of a new relation should not match any of the relations of the base types.