Question: I inherited an existing API and I would like to document it with swagger, but I don't yet know the full scope of it. Can Swagger (or another middleware/tool) auto-magically generate the yaml (for swagger) based on the existing express routes?

For what I saw on other questions, it would appear that this is mostly a manual job, but I'm double-checking if someone here found a way around this.

Answer: 
**Yes !!!**. You can use this awesome project [typescript-test](https://github.com/thiagobustamante/typescript-rest). Here is [sample app](https://github.com/vrudikov/typescript-rest-boilerplate). Clone it, run `npm i`,`npm run swagger` and go to */dist/swagger.json*. Done. Swagger yaml and json is generated based on express routes !
Have a look to [swagger-jsdoc](https://github.com/Surnet/swagger-jsdoc). It's a different approach.

The docs stick to the code, and also lets the express code to remain pure.

Guides:

* <https://dev.to/acanimal/express-api-with-autogenerated-openapi-doc-through-swagger-7na>
* <https://dev.to/akshendra/generating-documentation-on-the-fly-in-express-2652>