Api documentation using own external yaml or Json file. #6522
Answered
by
rohit151990
rohit151990
asked this question in
Questions
-
|
Hi Friends, I created my own swagger file and that I want to give for my api definition. I tried with given approach "app = FastAPI(openapi_url="/openapi.json")" but it is not loading my generated json file. Please suggest what should I do so that I can use my own created swagger file in fastapi. Regards, |
Beta Was this translation helpful? Give feedback.
Answered by
rohit151990
Jul 24, 2021
Replies: 2 comments
-
|
Thanks Guys I got the solution. from fastapi import FastAPI app = FastAPI() def custom_openapi(): app.openapi = custom_openapi |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
YuriiMotov
This comment has been hidden.
This comment has been hidden.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks Guys I got the solution.
this is how I can do this.
from fastapi import FastAPI
import json
app = FastAPI()
def custom_openapi():
with open("openapi.json", "r") as openapi:
return json.load(openapi)
app.openapi = custom_openapi