openapi() — fastapi Function Reference
Architecture documentation for the openapi() function in applications.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD a9c07abb_aad1_48b4_2dbe_359121a449b2["openapi()"] 587454b3_6db6_011f_9fa4_3e4e2e09b72d["FastAPI"] a9c07abb_aad1_48b4_2dbe_359121a449b2 -->|defined in| 587454b3_6db6_011f_9fa4_3e4e2e09b72d c029d7d0_68b4_7ce7_47cc_25c5b9dccd5d["setup()"] c029d7d0_68b4_7ce7_47cc_25c5b9dccd5d -->|calls| a9c07abb_aad1_48b4_2dbe_359121a449b2 d8a9ec8b_6a53_c575_f568_9201405b8883["get_openapi()"] a9c07abb_aad1_48b4_2dbe_359121a449b2 -->|calls| d8a9ec8b_6a53_c575_f568_9201405b8883 style a9c07abb_aad1_48b4_2dbe_359121a449b2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
fastapi/applications.py lines 1049–1080
def openapi(self) -> dict[str, Any]:
"""
Generate the OpenAPI schema of the application. This is called by FastAPI
internally.
The first time it is called it stores the result in the attribute
`app.openapi_schema`, and next times it is called, it just returns that same
result. To avoid the cost of generating the schema every time.
If you need to modify the generated OpenAPI schema, you could modify it.
Read more in the
[FastAPI docs for OpenAPI](https://fastapi.tiangolo.com/how-to/extending-openapi/).
"""
if not self.openapi_schema:
self.openapi_schema = get_openapi(
title=self.title,
version=self.version,
openapi_version=self.openapi_version,
summary=self.summary,
description=self.description,
terms_of_service=self.terms_of_service,
contact=self.contact,
license_info=self.license_info,
routes=self.routes,
webhooks=self.webhooks.routes,
tags=self.openapi_tags,
servers=self.servers,
separate_input_output_schemas=self.separate_input_output_schemas,
external_docs=self.openapi_external_docs,
)
return self.openapi_schema
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does openapi() do?
openapi() is a function in the fastapi codebase, defined in fastapi/applications.py.
Where is openapi() defined?
openapi() is defined in fastapi/applications.py at line 1049.
What does openapi() call?
openapi() calls 1 function(s): get_openapi.
What calls openapi()?
openapi() is called by 1 function(s): setup.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free