webapi-parser
webapi-parser copied to clipboard
Exposing types on the parsed model objects
Once the model is parsed and resolved, I am attempting to traverse the generated NodeShape tree to gather some information about the shape of our APIs. In order to properly traverse the tree, I need to differentiate between the different types of shapes (NodeShape, ArrayShape, ...). And I haven't found a proper way to do so.
My current workaround is to inspect the different object and retrieve the original class name via the special $classData that is defined on all the Scala objects.
export function isObjectNode(node) {
return node.$classData.name.endsWith('ObjectNode');
}
It would be great if all the model objects carry along with their types. Or even better if the library provides helper functions like isObject, isArrayNode, ...