1

I am building an API using FastAPI. That API is going to have some routes which are defined in my application, e.g. the API includes routes under /org/team1/... as well as perhaps routes under /foo/bar/....

I'd like to be able to have a subset of the overall API as a different app but to appear as a part of the main app. Thus some other team building part of the app might be responsible for routes under /org/team2/....

Is there some way of merging the OpenAPI spec from the team2 subset into the overall API spec, such that FastAPI has just a single OpenAPI spec? i.e. the top-level API is a sort of API Gateway pattern?

I would like to enable team2 to build and deploy their API separately to team1, but for all APIs to appear as a unified API.

John
  • 10,837
  • 17
  • 78
  • 141
  • Not sure do I understand - will it be one repository? If so, what's wrong with using routers? – kosciej16 May 04 '23 at 22:35
  • If these are two independent apps, you're probably better off using something like https://redocly.com/docs/cli/commands/join/ to generate the end documentation (from https://github.com/tiangolo/fastapi/discussions/4163) – MatsLindh May 05 '23 at 07:51
  • In an ideal world, @kosciej16, there would be 2 repos and I’d prefer not to do something like a mount of a sub api or to use git sub modules. – John May 05 '23 at 23:24
  • I would suggest having the teams to create routers instead of sub applications, and in the end include those routers in the main app. Regardless, please be aware that the order in which the endpoints are defined matters (see [here](https://stackoverflow.com/a/74498663/17865804) and [here](https://stackoverflow.com/a/73113792/17865804) for more details). – Chris May 06 '23 at 05:22

0 Answers0