This process will allow you to use Swagger Yaml files for validation. I've only tried this with REST endpoints, however it seems this should work with real-time sockets as well.
You'll need a few npm packages.
yarn add swagger-tools
|var _ = require('/lib/underscore');|
|*This is the lightweight version I use based on Kevin Whinnery's one: https://gist.github.com/kwhinnery/1595307|
|* Wrapper for Titanium UI components. This wrapper provides a few pieces of critical|
|* functionality, currently missing from Titanium UI objects:|
|* - The ability to safely extend components with new members|
|* - Rudimentary resource management and object lifecycle handling|