This page documents Dense Analysis recommendations for connecting APIs together and how microservices in general ought to be bridged together.
Principles
- You should never write REST client code by hand: generate it.
- Swagger specs are obsolete: use OpenAPI specs.
- Always write async or concurrent code: write for the future.
How to Make REST Calls
This section lists the best ways to make REST API request calls from code in different languages.
- Go –
net/httpstandard library calls with goroutines - Python – aiohttp is the best solution
- TypeScript – Use fetch()
OpenAPI
Use the Dense Analysis down converter for OpenAPI specs where you only have 3.0 spec support. See: https://denseanalysis.org/blog/post/2025-03-27-openapi-spec-converter/
- Go – OpenAPI 3.0: https://github.com/oapi-codegen/oapi-codegen which uses https://github.com/getkin/kin-openapi
- Python – OpenAPI 3.0, 3.1:
https://github.com/MarcoMuellner/openapi-python-generator
(Use
aiohttpmode) - TypeScript – OpenAPI 2.0, 3.0, 3.1:
https://github.com/hey-api/openapi-ts
(Generate
fetchcalls)
How to Export OpenAPI Specs
- Use CI or CD rules to generate specs from code and publish them.
- Publish in OpenAPI 3.0 as JSON with the Dense Analysis down-converter.
- Publish in OpenAPI 3.1 JSON as well, which may not suffer from down-conversion bugs.
git commitand use generated spec files and generated code in other repos.- Never modify generated code by hand: import and extend it.
Documentation
Use Redoc to take a generated spec and
serve it via the web. You can run it via a Docker image. If you are building a
FastAPI web app, Redoc support
is enabled by default and is available via the /redoc endpoint by default.