[Feature] Add argument to disable FastAPI docs #2540
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily receiving feedbacks. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.
Motivation
This PR is to add a new argument option to disable the
/
,/openapi.json
,/redoc
and/docs/oauth2-redirect
. My company doesn't allow using such endpoints in production environments. A new argument is added to disable the endpointreference doc: https://fastapi.tiangolo.com/tutorial/metadata/
Modification
Add argument
--disable-fastapi-docs
BC-breaking (Optional)
N/A
Use cases (Optional)
Before
![开启文档](https://private-user-images.githubusercontent.com/26166959/372115865-cf5d0a0d-5a2e-4408-92e1-524f3702c1f2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1OTI0OTEsIm5iZiI6MTczOTU5MjE5MSwicGF0aCI6Ii8yNjE2Njk1OS8zNzIxMTU4NjUtY2Y1ZDBhMGQtNWEyZS00NDA4LTkyZTEtNTI0ZjM3MDJjMWYyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVz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