So today I was exploring FastAPI, and I found out it auto generates OpenAPI spec just by defining normal routes like we do in ExpressJS.
No extra setup. You write the route, add type hints, and FastAPI gives you /docs, /redoc, and /openapi.json.
If you don't know OpenAPI spec is basically a standard that describes your whole API: endpoints, payloads, responses, etc. It is used to create proper docs, test suites, SDKs, even mock servers(postman).
What's crazy is you can use /openapi.json to build your own custom docs page, just like how Binance and other big platforms do for example, their trading API docs.
And let me be real doing this in Node.js is painful. You have to manually define types from request payload to response, set up validation separately, and make sure everything stays in sync. Even with TypeScript, it's a lot.
In Rust, it's better since strict typing is already enforced, but still, you have to plug in OpenAPI libraries and macros.
FastAPI? You write your route model once using Python type hints and it gives you everything.
Docs, schemas, validation, testingready API all auto.
Today I am genuinely amazed how clean and powerful this is. Might be the best thing I found lately.