Refactor swagger logic into a new file
Fix tests