Open-Orange-Button / Orange-Button-Taxonomy

OpenAPI Orange Button taxonomy
https://Open-Orange-Button.github.io/Orange-Button-Taxonomy
Apache License 2.0
14 stars 19 forks source link

Fixing taxonomy checker error about OB elements. #134

Closed reepoi closed 1 year ago

reepoi commented 1 year ago

Closes #120.

The taxonomy checker has validation rules that apply only to OB elements, so these rules filter the taxonomy definitions to find the OB elements. Since the taxonomy checker resolves all $ref pointers before running the filters, this filter cannot check the $ref pointer string for containing TaxonomyElement. Instead, this filter decides that a definition is an OB element if allOf exists, and allOf[0].properties.Value exists.

This implementation crashes when allOf[0].properties does not exist, and this happens when there is a chain of inheritance of length two or more. #117 included the chain of inheritance Scope -> MeasScope -> IrradPlaneOfArrayMeas where superclass -> subclass. Here IrradPlaneOfArrayMeas.allOf[0] equals MeasScope.allOf which is an array so IrradPlaneOfArrayMeas.allOf[0].properties does not exist. To avoid crashing in this case, the filter now checks that allOf exists, allOf[0].properties exists, and finally that allOf[0].properties.Value exists.

cwhanse commented 1 year ago

I think #127 undid the length two inheritance, but this is still needed. What happens if the chain is length 3? Would we have to add another condition to that rule? If that's the case, then we should rather have a development rule discouraging inheritance chains.

reepoi commented 1 year ago

The filtering condition does not need to change if a length three inheritance is added because the condition needs to only check one level up the inheritance chain from the definition to determine if it is an OB element. All OB elements inherit directly from TaxonomyElement<type>, so any definition at the end of an inheritance chain longer than one is not an OB element.