Open APIs

Expand all | Collapse all

Correct use of @type when making simple extensions

  • 1.  Correct use of @type when making simple extensions

    TM Forum Member
    Posted Jun 23, 2020 12:58

    I have a probably basic query about the correct use of @type and schemaLocation when extending an existng class.

    It is clear from the examples that when one is truly subclassing an entity to make a different entity, a new @type should be declared

    @type = MyFancyEquipment

    Where I've had some doubt is the slightly more subtle example where there is a need to simply extend something by adding more attributes.

    For example - when using Contact/ContactMedium/MediumCharacteristic, we have Operators in jurisdictions where a postal address won't fit into the street1/street2/city/postcode/country pattern - suppose for example we need to add 'POBox'.

    Or the 'Place' entity against Resource Inventory which has no fields at all beyond ID/name

    Is the correct approach:

    (a) Keep the @type=MediumCharacteristic and ​​​set a custom SchemaLocation (Design Guidelines part 2 mention a way of referencing original schema inside our own)
    (b) Define a new @type=​OurVendorExtendedMediumCharacteristic with @basetype=MediumCharacteristic with SchemaLocation defining our new schema​

    While I understand the analogy used to classes/polymorphism, from a practical implementation point of view I am torn between

    'Do (b) it's a new class, so it must have a new name' and 'If we make up a new name, External systems that can only consume the standard MediumCharacteristic would be more likely to fall over if they don't recongise the @type, even though they can get value from the standard fields and just ignore the extras'.​ Or is it expected that all API consumers crawl @type/@baseType til they find something they can consume?


    Andrew Torrance
    Cerillion Technologies Limited

  • 2.  RE: Correct use of @type when making simple extensions

    TM Forum Member
    Posted Jun 24, 2020 03:12
    Hi Andrew
    As far as I am aware, also adding attributes to a class is an extension, and so you need to use the extension pattern, as per (b) in your post.

    Hope it helps

    Jonathan Goldberg
    Amdocs Management Limited
    Any opinions and statements made by me on this forum are purely personal, and do not necessarily reflect the position of the TM Forum or my employer.