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 !
With [express-sitemap-html](https://www.npmjs.com/package/express-sitemap-html) you may automatically generate a minimalistic Open API definition (only including route parameters) and install a Swagger UI for all routes of an existing express app. You only need:

```js
const sitemap = require('express-sitemap-html')
...
sitemap.swagger('Your app name', app) // given that app is an express instance

```

Instead of analyzing HTTP requests at runtime, this approach inspects express `app` instance and mounted routes.

**PROs** you don't need to perform ahead requests to get an updated list of available routes.

**CONs** it provides untyped parameters features.