-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
➕ [FEATURE] Mounting app creates API definition #5974
base: master
Are you sure you want to change the base?
Conversation
📝 Docs preview for commit df64be7 at: https://63e2d5b3cd7ae81086b903af--fastapi.netlify.app |
df64be7
to
634a3f9
Compare
📝 Docs preview for commit 634a3f9 at: https://63e2d6bf5148b610f12ba092--fastapi.netlify.app |
634a3f9
to
f9b6f4d
Compare
📝 Docs preview for commit f9b6f4d at: https://63e423d881d8b7009f0fd4e7--fastapi.netlify.app |
looks interesting. |
@ZakharovDenis I'd like to understand this PR a bit more. This looks like a nice feature, but I'd like to understand any overhead that comes with it. Does it require any customization of the SwaggerUI libraries? And how does it affect the compatibility with the out-of-the-box swagger UI we include with fastapi? Since a major open source library like SwaggerUI will change at its own pace, we need to keep our use of it pretty vanilla, IMHO. Otherwise we spend our time maintaining compatibility with external libraries rather than innovating fastapi. |
@Ryandaydev, thanks for the question.
All this steps is something, that, I think, we can call "SwaggerUI API". Things become a little bit different if we talk about Redoc. Because Redoc does not have same feature out-of-the-box, i made a little customization to make this available.
The main risk here that the SwaggerUI maintainers will change topBar classes, so new classes will not correspond with classes, that i wrote for custom topBar, and styles will break. In fact, I think, that the maintainers of SwaggerUI are more likely to change topBar classes than drop the API, but even class changes won't be frequent. Also, as I mentioned in MR head, I think, that I probably did not found information how to enable same or similar feature for vanilla Redoc. Also, It's worth mentioning, that if you do not mount any app and use single FastAPI app, the SwaggerUI and Redoc will look like before, without any topBars. So for single application, all behaviour stays same. If You have any questions, I'm glad to answer. |
Thanks for the explanation, sounds like the new functionality on the swaggerUI doesn't introduce unnecessary customization. On the redocs, like you said it would be better if we didn't have to customize quite so much. How does Swagger describe this functionality in their docs? (Maybe we could find or suggest something similar to the maintainers of redocs.) |
Feature
With this MR, if
subapp
is mounted tomainapp
, you will see dropdown with ability to select API definition on themainapp
docs page.Description
http://localhost:8000/docs
and you will see this3. You can select the mounted app API from dropdown
4. Select mounted API and it will appear on the screen
5. ReDoc now comes with same feature
Help wanted / Discussion
Swagger UI comes with API definition feature almost out the box, unlike Redoc, that does not have this feature(or i did not found). So current solution is to use customized Swagger UI top bar with some JS on top of it.
So, if somebody know how to add this feature to redoc properly, I'll really appreciate your help.
Maybe Redoc does ned this feature if there's not native support.