tiangolo / full-stack-fastapi-couchbase

Full stack, modern web application generator. Using FastAPI, Couchbase as database, Docker, automatic HTTPS and more.
MIT License
441 stars 84 forks source link

Hide endpoint in interactive documentation #10

Closed zero0nee closed 5 years ago

zero0nee commented 5 years ago

Hi! this is not really a bug or an issue. It's more of a questions.

When I deploy the project I don't want /api/v1/api/v1/users/ and some other endpoints to displayed in the interactive Swagger/Redoc documentation. In other words, I want to hide them from the interactive documentation. Is this possible somehow?

tiangolo commented 5 years ago

Yes, you can exclude them from the generated OpenAPI: https://fastapi.tiangolo.com/tutorial/path-operation-advanced-configuration/#exclude-from-openapi

zero0nee commented 5 years ago

@tiangolo You just made my day! 🥇

tiangolo commented 5 years ago

Great! 😁

danielolson13 commented 4 years ago

Doc for exclusion is now here https://fastapi.tiangolo.com/advanced/path-operation-advanced-configuration/#exclude-from-openapi

david-shiko commented 3 years ago

Yes, you can exclude them from the generated OpenAPI: https://fastapi.tiangolo.com/tutorial/path-operation-advanced-configuration/#exclude-from-openapi

LInk isn't available anymore

yuriy-semen-by commented 3 years ago

Page was moved here: https://fastapi.tiangolo.com/advanced/path-operation-advanced-configuration/#exclude-from-openapi

EriKWDev commented 3 years ago

So many links... The answer is to set the include_in_schema flag to False inside the decorator. Here is the example code from the documentation:

@app.get("/items/", include_in_schema=False)
async def read_items():
    return [{"item_id": "Foo"}]
wadinj commented 2 years ago

Have a use case, here I would like to only hide endpoints without a tag. Any idea how can I achieve that ? Don't see anything related from the documentation