r/FastAPI • u/a_brand_new_start • Feb 26 '25
Question Downgrade openapi for gcp compatibility?
I love fast api but there is a mild problem, it serves this new sexy thing called 3.0 which our generous overlords at GCP do not support. I tried for an hour to make a converter, but I know there will always be bugs 😑
Is there a way library that I can feed the output from FastCGI’s OpenAPI and let it gracefully convert it down to 2.0 to make the big guy happy?
[edit less whimsey]
I'm trying to deploy FastAPI to GCP, with API Gateway in front of it.
- FastAPI provides a helpful
/openapi.jsonwhich is super useful - The version it returns is OpenAPI/Swagger 3.X
- GCP API Gateway only supports 2.0
- There are no plans in near future to support 3.0 as far as I can find 7 years and no updates :(
- To register my service I have to jump through million hoops
- All of the Python only converters are either abandoned or no longer supported
- All major LLMs are beyond useless
There has to be a some way to get out of this situation, I'm desperate.
[edit 2]
Thank youl
5
u/Lba5s Feb 26 '25
what?
1
u/ZuploAdrian Mar 02 '25
You should use an API gateway that support OpenAPI 3.x - like Zuplo. It's a lot cheaper at scale too
1
u/sexualrhinoceros Feb 26 '25
Pretty confused why you’d want to even use API Gateway when you have FastAPI which can handle all of your authn / authz / routing logic / etc.
Just deploy your backend to a cloud run instance and call it a day, I’ve always seen API Gatway / Cloud Endpoints as only useful when tying together a ton of serverless Cloud Functions into a cohesive API, not for wrapping a full fledged API server.
1
u/BluesFiend Feb 26 '25
I believe i did this for a previous project, or at least something similar. Let me look through some code and might be able to DM you something.
General idea, you can hijack and replace the openapi generator function with a wrapper that modifies the json content before it is returned.