refactor the swagger doc file processing logic
fix bugs and add exception handling when doc directory doesn't exist