Skip to content
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

✨ Enable configuring Swagger UI parameters #2568

Merged
merged 8 commits into from Jan 16, 2022
Merged

✨ Enable configuring Swagger UI parameters #2568

merged 8 commits into from Jan 16, 2022

Conversation

jmriebold
Copy link
Contributor

At present there are a number of Swagger UI parameters that are not configurable when using FastAPI. Under normal circumstances most of these wouldn't need to be used at all, however there are some cases where you might need to override some of these. For example, Swagger UI's syntax highlighting is known to be slow, and being able to easily disable this would be very useful in certain situations.

@github-actions
Copy link
Contributor

📝 Docs preview for commit b6d0d6424865fa8fbd49d4ec12e2012dab42dc27 at: https://5fe42722500f90b60ec3643e--fastapi.netlify.app

@codecov
Copy link

codecov bot commented Dec 24, 2020

Codecov Report

Merging #2568 (efdfffc) into master (fe086a4) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##            master     #2568     +/-   ##
===========================================
  Coverage   100.00%   100.00%             
===========================================
  Files          410       504     +94     
  Lines        10281     12707   +2426     
===========================================
+ Hits         10281     12707   +2426     
Impacted Files Coverage Δ
docs_src/extending_openapi/tutorial003.py 100.00% <100.00%> (ø)
docs_src/extending_openapi/tutorial004.py 100.00% <100.00%> (ø)
docs_src/extending_openapi/tutorial005.py 100.00% <100.00%> (ø)
fastapi/applications.py 100.00% <100.00%> (ø)
fastapi/openapi/docs.py 100.00% <100.00%> (ø)
...utorial/test_extending_openapi/test_tutorial003.py 100.00% <100.00%> (ø)
...utorial/test_extending_openapi/test_tutorial004.py 100.00% <100.00%> (ø)
...utorial/test_extending_openapi/test_tutorial005.py 100.00% <100.00%> (ø)
fastapi/utils.py 100.00% <0.00%> (ø)
fastapi/concurrency.py 100.00% <0.00%> (ø)
... and 99 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe086a4...efdfffc. Read the comment docs.

@github-actions
Copy link
Contributor

📝 Docs preview for commit fc976680dc9d1a76fafdad8bf5b6f0918278bbbf at: https://5fe428d611f328a5bbc9ed4c--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit 643ec18bca4f874857f14718f7a2a7d058a8ec87 at: https://5fe6e411605fe15cdca29bc0--fastapi.netlify.app

@jmriebold
Copy link
Contributor Author

@pablogamboa, any other changes needed to wrap this one up?

Copy link
Contributor

@pablogamboa pablogamboa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm great work @jmriebold

@jmriebold
Copy link
Contributor Author

Thanks, appreciate the review @pablogamboa!

@long2ice
Copy link

long2ice commented Jan 7, 2021

Look forward for this merge!

Copy link

@akihiro-inui akihiro-inui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swagger_ui_parameters argument type

fastapi/openapi/docs.py Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

📝 Docs preview for commit c85e977 at: https://6000c2f94184b067b242674b--fastapi.netlify.app

@jmriebold
Copy link
Contributor Author

@pablogamboa, @akihiro-inui, @ycd, this PR's been approved for several weeks now, could we get this merged? Do you need anything else from me?

@ycd
Copy link
Contributor

ycd commented Feb 8, 2021

Nope, the change looks good, but only @tiangolo has access to master branch. We need to wait his input.

@jmriebold
Copy link
Contributor Author

Understood, thanks @ycd!

@c-shekhar
Copy link

Hey, @tiangolo, any plans to get this PR merged soon?
Also @jmriebold great addition! 💯
We are having a use-case where we are exposing alpha release of our APIs to customers and tryItOutEnabled display configuration of swagegr-ui will be very helpful and handy there for a particular group of end users.

@stvnksslr
Copy link

Bumping this as it would be a huge help to my teams everyday workflow specifically the syntax highlighting being slow for even fairly small datasets is a killer.

@jziolkowski
Copy link

jziolkowski commented Jun 21, 2021

another 👍 for this PR from our team as we needed to add some ugly hacks to achieve the same result, while we could have this builtin so nicely. Great job @jmriebold ! @tiangolo pls consider merging this!

fastapi/openapi/docs.py Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2021

📝 Docs preview for commit 858a7c381e61f9acbdc9fd576ce6570960f6ce7e at: https://6106e96986f404dc14abd0be--fastapi.netlify.app

@github-actions
Copy link
Contributor

github-actions bot commented Aug 1, 2021

📝 Docs preview for commit 3d7b0f9d4debaaf7ed3b7d02652b5574967033f9 at: https://6106eca7f5c202bbed0c53ea--fastapi.netlify.app

fastapi/openapi/docs.py Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2021

📝 Docs preview for commit f51131f39dc7cc5325b83e75f7346418efe16ef3 at: https://61073618f4f7e80b3fd1c4a2--fastapi.netlify.app

@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2021

📝 Docs preview for commit dc18657 at: https://6107378eac0828105034dbbf--fastapi.netlify.app

@aperullo
Copy link

aperullo commented Sep 7, 2021

What's holding this MR up?

@jmriebold
Copy link
Contributor Author

@aperullo, as I understand it @tiangolo is the only one with write-access, so it's blocked on him reviewing and/merging it.

@elrik75
Copy link

elrik75 commented Sep 7, 2021

And @tiangolo seems to be focused on other projects now. SQLModel and Typed. FastAPI needs more maintainers.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2021

📝 Docs preview for commit 0eaccf4 at: https://615661bf80442e26f8fa1a09--fastapi.netlify.app

@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2021

📝 Docs preview for commit fb507cd at: https://615662848725b5256eb10d3a--fastapi.netlify.app

@Armster15
Copy link

@tiangolo is there a specific reason this hasn't gotten merged yet? This PR has been approved by the reviewers, and this is something many people want (personally me as well 😄). I find it a little odd that there is no official response from you yet.

I hope this didn't come off as condescending by the way, thanks so much for your work on FastAPI :)

@ghandic
Copy link
Contributor

ghandic commented Nov 6, 2021

I've put in a PR for a plug-in system too, I think it would be better to have an approach that is more general and flexible

@long2ice
Copy link

long2ice commented Nov 6, 2021

This project probably don't like new feature, check the recent activity

@alexjolig
Copy link

I'm having a big issue with large response JSONs and because I'm not able to deactivate syntax highlights from Swagger UI, my project flow is freezing. Merging this would really keeps me going. @tiangolo I hope you're somewhere to be found!

@github-actions
Copy link
Contributor

📝 Docs preview for commit d5a9853 at: https://619d28f1f53911381b724316--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit efdfffc at: https://61e46f51232a1327a2186f3d--fastapi.netlify.app

@tiangolo
Copy link
Owner

Thanks for your work @jmriebold! 🍰

And thanks for the discussion everyone.

I fixed an error in the implementation that would break Swagger UI if parameters with dots like syntaxHighlight.theme were used.

I also refactored the other default configurations included by FastAPI to allow overriding them, and documented it.

I refactored and updated the docs, to include source code examples that are now tested, explain defaults and overrides, and added some screenshots.

This will be available in FastAPI version 0.72.0, I'll release it in a couple of hours. 🔖

@tiangolo tiangolo changed the title Enable configuration of Swagger UI ✨ Enable configuring Swagger UI parameters Jan 16, 2022
@tiangolo tiangolo merged commit a85aa12 into tiangolo:master Jan 16, 2022
@jmriebold
Copy link
Contributor Author

Thanks @tiangolo!

@ghandic
Copy link
Contributor

ghandic commented Jan 16, 2022

This will now require rework to the plug-in system, is there still interest in having that? Don't want to reinvest the time if there isn't the appetite #4060

JeanArhancet pushed a commit to JeanArhancet/fastapi that referenced this pull request Aug 20, 2022
Co-authored-by: Artem Ivanov <artem@worklife.io>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet