V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
yumenlong
V2EX  ›  Python

fastapi 如何实现 swagger 隐藏某个具体 api 呢

  •  
  •   yumenlong · Jun 12, 2020 · 3273 views
    This topic created in 2158 days ago, the information mentioned may be changed or developed.
    想用 fastapi 来做个小站,提供 api,但部分接口如注册接口这些想隐藏一下,不在 swagger 显示,请问如何实现.
    mirrorpen
        1
    mirrorpen  
       Jun 12, 2020
    那注册接口不写 swagger 注释不就行了吗?是这个意思吗..
    yRebelHero
        2
    yRebelHero  
       Jun 12, 2020
    yumenlong
        3
    yumenlong  
    OP
       Jun 12, 2020
    找到了,@app.get("/items/", include_in_schema=False) To exclude a path operation from the generated OpenAPI schema (and thus, from the automatic documentation systems), use the parameter include_in_schema and set it to False;
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2964 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 56ms · UTC 08:41 · PVG 16:41 · LAX 01:41 · JFK 04:41
    ♥ Do have faith in what you're doing.