---
title: "💭 Path Operation Advanced Configuration - FastAPI"
description: "!https://fastapi.tiangolo.com/advanced/path-operation-advanced-configuration/#exclude-from-openapi"
date: 2023-12-12
published: true
tags:
  - webdev
  - fastapi
  - thought
template: link
---


<div class="embed-card embed-card-external">
  <a href="https://fastapi.tiangolo.com/advanced/path-operation-advanced-configuration/#exclude-from-openapi" class="embed-card-link" target="_blank" rel="noopener noreferrer">
    <div class="embed-card-image">
      <img src="https://fastapi.tiangolo.com/assets/images/social/advanced/path-operation-advanced-configuration.png" alt="Path Operation Advanced Configuration - FastAPI — FastAPI framework, high performance, easy to learn, fast to code, ready for production" loading="lazy">
    </div>
    <div class="embed-card-content">
      <div class="embed-card-title">Path Operation Advanced Configuration - FastAPI</div>
      <div class="embed-card-description">FastAPI framework, high performance, easy to learn, fast to code, ready for production</div>
      <div class="embed-card-meta">fastapi.tiangolo.com</div>
    </div>
  </a>
</div>


        Excluding routes from fastapi docs, can be done from the route configuration using `include_in_schema`.  This is handy for routes that are not really api based or duplicates.  


## From the Docs

``` python
from fastapi import FastAPI

app = FastAPI()


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

## trailing slash

I've had better luck just routing both naked and trailing slash routes in fastapi.  I've had api's deployed as a subroute to a site rather than a subdomain, and the automatic redirect betweens them tended to always get messed up.  This is pretty easy fix for the pain is causes just give vim a yyp, and if you don't want deuplicates in your docs, ignore one.

``` python
from fastapi import FastAPI

app = FastAPI()

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

## favicon.ico

Now you do not need to deploy favicons to your api in any way,  it is nice to have it in your browser tab, but more importantly to me I hate having console errors that are meaningless, this gives the browser something to automatically grab and not log errors.

``` python
@app.get("/favicon.ico", include_in_schema=False)
def get_favicon():
    return RedirectResponse(url="https://fokais.com/favicon.ico", status_code=status.HTTP_302_FOUND)

```

!!! note

    This post is a <a href="/thoughts/" class="wikilink" data-title="Thoughts" data-description="These are generally my thoughts on a web page or some sort of url, except a rare few don&#39;t have a link. These are dual published off of my..." data-date="2024-04-01">thought</a>. It's a short note that I make
    about someone else's content online <a href="/tags/thoughts/" class="hashtag-tag" data-tag="thoughts" data-count=2 data-reading-time=3 data-reading-time-text="3 minutes">#thoughts</a>
