Hi Rob,
What do you mean "discarding"? Like are you wondering where the code is that causes the parser to ignore elements it doesn't understand?
If you want an in-memory metamodel you could use to generate swagger's model definitions, one thing you could do it use HAPI's resource defintions and their accompanying child definitions..
The following would give you the patient def:
ResourceDefinition def = ctx.getResourceDefinition("Patient");
Calling methods like getChild() on that lets you walk the hierarchy. You'd need to spend a bit of time with a debugger though seeing what gets returned, since that part of the API isn't as well documented as the more "user facing" stuff.
Cheers,
James