e  ](../../project-generation/)
    * [ External Links and Articles  ](../../external-links/)
    * [ FastAPI and friends newsletter  ](../../newsletter/)
  * [ About  ](../../about/)

About

    * [ Alternatives, Inspiration and Comparisons  ](../../alternatives/)
    * [ History, Design and Future  ](../../history-design-future/)
    * [ Benchmarks  ](../../benchmarks/)
  * [ Help  ](../../help/)

Help

    * [ Help FastAPI - Get Help  ](../../help-fastapi/)
    * [ Development - Contributing  ](../../contributing/)
  * [ Release Notes  ](../../release-notes/)

Table of contents

  * OpenAPI operationId 
    * Using the _path operation function_ name as the operationId 
  * Exclude from OpenAPI 
  * Advanced description from docstring 
  * Additional Responses 
  * OpenAPI Extra 
    * OpenAPI Extensions 
    * Custom OpenAPI _path operation_ schema 
    * Custom OpenAPI content type 

  1. [ FastAPI  ](../..)
  2. [ Learn  ](../../learn/)
  3. [ Advanced User Guide  ](../)

#  Path Operation Advanced Configuration  ¶

##  OpenAPI operationId  ¶

Warning

If you are not an "expert" in OpenAPI, you probably don't need this.

You can set the OpenAPI ` operationId ` to be used in your _path operation_
with the parameter ` operation_id ` .

You would have to make sure that it is unique for each operation.

    
    
    from fastapi import FastAPI
    
    app = FastAPI()
    
    
    @app.get("/items/", operation_id="some_specific_id_you_define")
    async def read_items():
        return [{"item_id": "Foo"}]
    

###  Using the _path operation function_ name as the operationId  ¶

If you want to use your APIs' function names as ` operationId ` s, you can
iterate over all of them and override each _path operation's_ ` operation_id `
using their ` APIRoute.name ` .

You should do it after adding all your _path operations_ .

    
    
    from fastapi import FastAPI
    from fastapi.routing import APIRoute
    
    app = FastAPI()
    
    
    @app.get("/items/")
    async def read_items():
        return [{"item_id": "Foo"}]
    
    
    def use_route_names_as_operation_ids(app: FastAPI) -> None:
        """
        Simplify operation IDs so that generated API clients have simpler function
        names.
    
        Should be called only after all routes have been added.
        """
        for route in app.routes:
            if isinstance(route, APIRoute):
                route.operation_id = route.name  # in this case, 'read_items'
    
    
    use_route_names_as_operation_ids(app)
    

Tip

If you manually call ` app.openapi() ` , you should update the ` operationId `
s before that.

Warning

If you do this, you have to make sure each one of your _path operation
functions_ has a unique name.

Even if they are in different modules (Python files).

##  Exclude from OpenAPI  ¶

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 ` :

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

##  Advanced description from docstring  ¶

You can limit the lines used from the docstring of a _path operation function_
for OpenAPI.

Adding an ` \f ` (an escaped "form feed" character) causes **FastAPI** to
truncate the output used for OpenAPI at this point.

It won't show up in the documentation, but other tools (such as Sphinx) will
be able to use the rest.

    
    
    from typing import Set, Union
    
    from fastapi import FastAPI
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
        description: Union[str, None] = None
        price: float
        tax: Union[float, None] = None
        tags: Set[str] = set()
    
    
    @app.post("/items/", response_model=Item, summary="Create an item")