Flask Integration¶
This section provides documentation for the Flask-specific components of Flask-X-OpenAPI-Schema.
Flask Module¶
Flask-specific implementations for OpenAPI schema generation.
OpenAPIMethodViewMixin
¶
A mixin class for Flask.MethodView to collect OpenAPI metadata.
This mixin class adds OpenAPI schema generation capabilities to Flask's MethodView. It provides a method to register the view to a blueprint while collecting metadata for OpenAPI schema generation.
Examples:
>>> from flask import Blueprint
>>> from flask.views import MethodView
>>> from flask_x_openapi_schema.x.flask import OpenAPIMethodViewMixin, openapi_metadata
>>> from pydantic import BaseModel, Field
>>>
>>> class ItemResponse(BaseModel):
... id: str = Field(..., description="Item ID")
... name: str = Field(..., description="Item name")
>>>
>>> class ItemView(OpenAPIMethodViewMixin, MethodView):
... @openapi_metadata(summary="Get an item")
... def get(self, item_id: str):
... return {"id": item_id, "name": "Example Item"}
>>>
>>> bp = Blueprint("items", __name__)
>>> # Register the view to the blueprint
>>> _ = ItemView.register_to_blueprint(bp, "/items/<item_id>")
Source code in src/flask_x_openapi_schema/x/flask/views.py
register_to_blueprint(blueprint, url, endpoint=None, **kwargs)
classmethod
¶
Register the MethodView to a blueprint and collect OpenAPI metadata.
This method registers the view to a blueprint and stores metadata for OpenAPI schema generation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
blueprint
|
Any
|
The Flask blueprint to register to |
required |
url
|
str
|
The URL rule to register |
required |
endpoint
|
str | None
|
The endpoint name (defaults to the class name) |
None
|
**kwargs
|
Any
|
Additional arguments to pass to add_url_rule |
{}
|
Returns:
Name | Type | Description |
---|---|---|
Any |
Any
|
The view function |
Examples:
>>> from flask import Blueprint
>>> from flask.views import MethodView
>>> from flask_x_openapi_schema.x.flask import OpenAPIMethodViewMixin
>>> class ItemView(OpenAPIMethodViewMixin, MethodView):
... def get(self, item_id: str):
... return {"id": item_id, "name": "Example Item"}
>>> bp = Blueprint("items", __name__)
>>> # Register the view to the blueprint
>>> _ = ItemView.register_to_blueprint(bp, "/items/<item_id>")
Source code in src/flask_x_openapi_schema/x/flask/views.py
openapi_metadata(*, summary=None, description=None, tags=None, operation_id=None, responses=None, deprecated=False, security=None, external_docs=None, language=None, prefix_config=None, content_type=None, request_content_types=None, response_content_types=None, content_type_resolver=None)
¶
Decorator to add OpenAPI metadata to a Flask MethodView endpoint.
This decorator adds OpenAPI metadata to a Flask MethodView endpoint and handles parameter binding for request data. It automatically binds request body, query parameters, path parameters, and file uploads to function parameters based on their type annotations and parameter name prefixes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
summary
|
str | I18nStr | None
|
A short summary of what the operation does |
None
|
description
|
str | I18nStr | None
|
A verbose explanation of the operation behavior |
None
|
tags
|
list[str] | None
|
A list of tags for API documentation control |
None
|
operation_id
|
str | None
|
Unique string used to identify the operation |
None
|
responses
|
OpenAPIMetaResponse | None
|
The responses the API can return |
None
|
deprecated
|
bool
|
Declares this operation to be deprecated |
False
|
security
|
list[dict[str, list[str]]] | None
|
A declaration of which security mechanisms can be used for this operation |
None
|
external_docs
|
dict[str, str] | None
|
Additional external documentation |
None
|
language
|
str | None
|
Language code to use for I18nString values (default: current language) |
None
|
prefix_config
|
ConventionalPrefixConfig | None
|
Configuration object for parameter prefixes |
None
|
content_type
|
str | None
|
Custom content type for request body. If None, will be auto-detected. |
None
|
request_content_types
|
RequestContentTypes | None
|
Multiple content types for request body. |
None
|
response_content_types
|
ResponseContentTypes | None
|
Multiple content types for response body. |
None
|
content_type_resolver
|
Callable[[Any], str] | None
|
Function to determine content type based on request. |
None
|
Returns:
Type | Description |
---|---|
Callable[[F], F]
|
The decorated function with OpenAPI metadata attached |
Examples:
>>> from flask.views import MethodView
>>> from flask_x_openapi_schema.x.flask import openapi_metadata
>>> from flask_x_openapi_schema import OpenAPIMetaResponse, OpenAPIMetaResponseItem
>>> from pydantic import BaseModel, Field
>>>
>>> class ItemRequest(BaseModel):
... name: str = Field(..., description="Item name")
... price: float = Field(..., description="Item price")
>>>
>>> class ItemResponse(BaseModel):
... id: str = Field(..., description="Item ID")
... name: str = Field(..., description="Item name")
... price: float = Field(..., description="Item price")
>>>
>>> class ItemView(MethodView):
... @openapi_metadata(
... summary="Create a new item",
... description="Create a new item with the provided information",
... tags=["items"],
... operation_id="createItem",
... responses=OpenAPIMetaResponse(
... responses={
... "201": OpenAPIMetaResponseItem(model=ItemResponse, description="Item created successfully"),
... "400": OpenAPIMetaResponseItem(description="Invalid request data"),
... }
... ),
... )
... def post(self, _x_body: ItemRequest):
... item = {"id": "123", "name": _x_body.name, "price": _x_body.price}
... return item, 201
Source code in src/flask_x_openapi_schema/x/flask/decorators.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
|
Decorators¶
Decorators for adding OpenAPI metadata to Flask MethodView endpoints.
This module provides decorators that can be used to add OpenAPI metadata to Flask MethodView endpoints. The decorators handle parameter binding for request data, including request body, query parameters, path parameters, and file uploads.
FlaskOpenAPIDecorator
¶
Bases: DecoratorBase
OpenAPI metadata decorator for Flask MethodView.
This class implements a decorator that adds OpenAPI metadata to Flask MethodView endpoints and handles parameter binding for request data.
Source code in src/flask_x_openapi_schema/x/flask/decorators.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
|
__call__(func)
¶
Apply the decorator to the function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func
|
Callable
|
The function to decorate |
required |
Returns:
Type | Description |
---|---|
Callable
|
The decorated function |
Source code in src/flask_x_openapi_schema/x/flask/decorators.py
__init__(summary=None, description=None, tags=None, operation_id=None, responses=None, deprecated=False, security=None, external_docs=None, language=None, prefix_config=None, content_type=None, request_content_types=None, response_content_types=None, content_type_resolver=None)
¶
Initialize the decorator with OpenAPI metadata parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
summary
|
str | I18nStr | None
|
A short summary of what the operation does |
None
|
description
|
str | I18nStr | None
|
A verbose explanation of the operation behavior |
None
|
tags
|
list[str] | None
|
A list of tags for API documentation control |
None
|
operation_id
|
str | None
|
Unique string used to identify the operation |
None
|
responses
|
OpenAPIMetaResponse | None
|
The responses the API can return |
None
|
deprecated
|
bool
|
Declares this operation to be deprecated |
False
|
security
|
list[dict[str, list[str]]] | None
|
A declaration of which security mechanisms can be used for this operation |
None
|
external_docs
|
dict[str, str] | None
|
Additional external documentation |
None
|
language
|
str | None
|
Language code to use for I18nString values |
None
|
prefix_config
|
ConventionalPrefixConfig | None
|
Configuration object for parameter prefixes |
None
|
content_type
|
str | None
|
Custom content type for request body. If None, will be auto-detected. |
None
|
request_content_types
|
RequestContentTypes | None
|
Multiple content types for request body. |
None
|
response_content_types
|
ResponseContentTypes | None
|
Multiple content types for response body. |
None
|
content_type_resolver
|
Callable[[Any], str] | None
|
Function to determine content type based on request. |
None
|
Source code in src/flask_x_openapi_schema/x/flask/decorators.py
extract_parameters_from_models(query_model, path_params)
¶
Extract OpenAPI parameters from models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query_model
|
type[BaseModel] | None
|
The query parameter model |
required |
path_params
|
list[str] | None
|
List of path parameter names |
required |
Returns:
Type | Description |
---|---|
list[dict[str, Any]]
|
List of OpenAPI parameter objects |
Source code in src/flask_x_openapi_schema/x/flask/decorators.py
process_additional_params(kwargs, param_names)
¶
Process additional framework-specific parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs
|
dict[str, Any]
|
The keyword arguments to update |
required |
param_names
|
list[str]
|
List of parameter names that have been processed |
required |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
Updated kwargs dictionary |
Source code in src/flask_x_openapi_schema/x/flask/decorators.py
process_query_params(param_name, model, kwargs)
¶
Process query parameters for Flask.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param_name
|
str
|
The parameter name to bind the model instance to |
required |
model
|
type[BaseModel]
|
The Pydantic model class to use for validation |
required |
kwargs
|
dict[str, Any]
|
The keyword arguments to update |
required |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
Updated kwargs dictionary with the model instance |
Source code in src/flask_x_openapi_schema/x/flask/decorators.py
process_request_body(param_name, model, kwargs)
¶
Process request body parameters for Flask.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param_name
|
str
|
The parameter name to bind the model instance to |
required |
model
|
type[BaseModel]
|
The Pydantic model class to use for validation |
required |
kwargs
|
dict[str, Any]
|
The keyword arguments to update |
required |
Returns:
Type | Description |
---|---|
dict[str, Any]
|
Updated kwargs dictionary with the model instance |
Source code in src/flask_x_openapi_schema/x/flask/decorators.py
openapi_metadata(*, summary=None, description=None, tags=None, operation_id=None, responses=None, deprecated=False, security=None, external_docs=None, language=None, prefix_config=None, content_type=None, request_content_types=None, response_content_types=None, content_type_resolver=None)
¶
Decorator to add OpenAPI metadata to a Flask MethodView endpoint.
This decorator adds OpenAPI metadata to a Flask MethodView endpoint and handles parameter binding for request data. It automatically binds request body, query parameters, path parameters, and file uploads to function parameters based on their type annotations and parameter name prefixes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
summary
|
str | I18nStr | None
|
A short summary of what the operation does |
None
|
description
|
str | I18nStr | None
|
A verbose explanation of the operation behavior |
None
|
tags
|
list[str] | None
|
A list of tags for API documentation control |
None
|
operation_id
|
str | None
|
Unique string used to identify the operation |
None
|
responses
|
OpenAPIMetaResponse | None
|
The responses the API can return |
None
|
deprecated
|
bool
|
Declares this operation to be deprecated |
False
|
security
|
list[dict[str, list[str]]] | None
|
A declaration of which security mechanisms can be used for this operation |
None
|
external_docs
|
dict[str, str] | None
|
Additional external documentation |
None
|
language
|
str | None
|
Language code to use for I18nString values (default: current language) |
None
|
prefix_config
|
ConventionalPrefixConfig | None
|
Configuration object for parameter prefixes |
None
|
content_type
|
str | None
|
Custom content type for request body. If None, will be auto-detected. |
None
|
request_content_types
|
RequestContentTypes | None
|
Multiple content types for request body. |
None
|
response_content_types
|
ResponseContentTypes | None
|
Multiple content types for response body. |
None
|
content_type_resolver
|
Callable[[Any], str] | None
|
Function to determine content type based on request. |
None
|
Returns:
Type | Description |
---|---|
Callable[[F], F]
|
The decorated function with OpenAPI metadata attached |
Examples:
>>> from flask.views import MethodView
>>> from flask_x_openapi_schema.x.flask import openapi_metadata
>>> from flask_x_openapi_schema import OpenAPIMetaResponse, OpenAPIMetaResponseItem
>>> from pydantic import BaseModel, Field
>>>
>>> class ItemRequest(BaseModel):
... name: str = Field(..., description="Item name")
... price: float = Field(..., description="Item price")
>>>
>>> class ItemResponse(BaseModel):
... id: str = Field(..., description="Item ID")
... name: str = Field(..., description="Item name")
... price: float = Field(..., description="Item price")
>>>
>>> class ItemView(MethodView):
... @openapi_metadata(
... summary="Create a new item",
... description="Create a new item with the provided information",
... tags=["items"],
... operation_id="createItem",
... responses=OpenAPIMetaResponse(
... responses={
... "201": OpenAPIMetaResponseItem(model=ItemResponse, description="Item created successfully"),
... "400": OpenAPIMetaResponseItem(description="Invalid request data"),
... }
... ),
... )
... def post(self, _x_body: ItemRequest):
... item = {"id": "123", "name": _x_body.name, "price": _x_body.price}
... return item, 201
Source code in src/flask_x_openapi_schema/x/flask/decorators.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
|
Views¶
Utilities for integrating Pydantic models with Flask.MethodView.
This module provides utilities for integrating Pydantic models with Flask.MethodView classes. It includes classes and functions for collecting OpenAPI metadata from MethodView classes and generating OpenAPI schema documentation.
Examples:
Basic usage with Flask blueprint and MethodView:
>>> from flask import Blueprint
>>> from flask.views import MethodView
>>> from flask_x_openapi_schema.x.flask import OpenAPIMethodViewMixin, openapi_metadata
>>> from pydantic import BaseModel, Field
>>>
>>> class ItemResponse(BaseModel):
... id: str = Field(..., description="Item ID")
... name: str = Field(..., description="Item name")
>>>
>>> class ItemView(OpenAPIMethodViewMixin, MethodView):
... @openapi_metadata(summary="Get an item")
... def get(self, item_id: str):
... return {"id": item_id, "name": "Example Item"}
>>>
>>> bp = Blueprint("items", __name__)
>>> # Register the view to the blueprint
>>> _ = ItemView.register_to_blueprint(bp, "/items/<item_id>")
MethodViewOpenAPISchemaGenerator
¶
Bases: OpenAPISchemaGenerator
OpenAPI schema generator for Flask.MethodView classes.
This class extends the base OpenAPISchemaGenerator to provide specific functionality for generating OpenAPI schema from Flask.MethodView classes. It processes MethodView resources registered to blueprints and extracts metadata for OpenAPI schema generation.
Source code in src/flask_x_openapi_schema/x/flask/views.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
|
process_methodview_resources(blueprint)
¶
Process MethodView resources registered to a blueprint.
Extracts OpenAPI metadata from MethodView classes registered to a blueprint and adds them to the OpenAPI schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
blueprint
|
Any
|
The Flask blueprint with registered MethodView resources |
required |
Source code in src/flask_x_openapi_schema/x/flask/views.py
OpenAPIMethodViewMixin
¶
A mixin class for Flask.MethodView to collect OpenAPI metadata.
This mixin class adds OpenAPI schema generation capabilities to Flask's MethodView. It provides a method to register the view to a blueprint while collecting metadata for OpenAPI schema generation.
Examples:
>>> from flask import Blueprint
>>> from flask.views import MethodView
>>> from flask_x_openapi_schema.x.flask import OpenAPIMethodViewMixin, openapi_metadata
>>> from pydantic import BaseModel, Field
>>>
>>> class ItemResponse(BaseModel):
... id: str = Field(..., description="Item ID")
... name: str = Field(..., description="Item name")
>>>
>>> class ItemView(OpenAPIMethodViewMixin, MethodView):
... @openapi_metadata(summary="Get an item")
... def get(self, item_id: str):
... return {"id": item_id, "name": "Example Item"}
>>>
>>> bp = Blueprint("items", __name__)
>>> # Register the view to the blueprint
>>> _ = ItemView.register_to_blueprint(bp, "/items/<item_id>")
Source code in src/flask_x_openapi_schema/x/flask/views.py
register_to_blueprint(blueprint, url, endpoint=None, **kwargs)
classmethod
¶
Register the MethodView to a blueprint and collect OpenAPI metadata.
This method registers the view to a blueprint and stores metadata for OpenAPI schema generation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
blueprint
|
Any
|
The Flask blueprint to register to |
required |
url
|
str
|
The URL rule to register |
required |
endpoint
|
str | None
|
The endpoint name (defaults to the class name) |
None
|
**kwargs
|
Any
|
Additional arguments to pass to add_url_rule |
{}
|
Returns:
Name | Type | Description |
---|---|---|
Any |
Any
|
The view function |
Examples:
>>> from flask import Blueprint
>>> from flask.views import MethodView
>>> from flask_x_openapi_schema.x.flask import OpenAPIMethodViewMixin
>>> class ItemView(OpenAPIMethodViewMixin, MethodView):
... def get(self, item_id: str):
... return {"id": item_id, "name": "Example Item"}
>>> bp = Blueprint("items", __name__)
>>> # Register the view to the blueprint
>>> _ = ItemView.register_to_blueprint(bp, "/items/<item_id>")
Source code in src/flask_x_openapi_schema/x/flask/views.py
extract_openapi_parameters_from_methodview(view_class, method, url)
¶
Extract OpenAPI parameters from a MethodView class method.
Analyzes a MethodView class method to extract path parameters and their types for OpenAPI schema generation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
view_class
|
type[MethodView]
|
The MethodView class |
required |
method
|
str
|
The HTTP method (get, post, etc.) |
required |
url
|
str
|
The URL rule |
required |
Returns:
Type | Description |
---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: List of OpenAPI parameter objects |
Source code in src/flask_x_openapi_schema/x/flask/views.py
Utilities¶
Utility functions for Flask integration.
This module provides utility functions for integrating Flask with OpenAPI schema generation. It includes functions for generating OpenAPI schemas from Flask blueprints, registering Pydantic models with schema generators, and extracting data from requests based on Pydantic models.
extract_pydantic_data(model_class)
¶
Extract data from the request based on a Pydantic model.
This function extracts data from the current Flask request and validates it against the provided Pydantic model. It handles JSON data, form data, and query parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_class
|
type[BaseModel]
|
The Pydantic model class to use for validation. |
required |
Returns:
Name | Type | Description |
---|---|---|
BaseModel |
BaseModel
|
A validated instance of the provided Pydantic model. |
Raises:
Type | Description |
---|---|
ValidationError
|
If the request data doesn't match the model's schema. |
Examples:
>>> from flask import Flask, request
>>> from pydantic import BaseModel, Field
>>> app = Flask(__name__)
>>> class UserCreate(BaseModel):
... username: str
... email: str
... age: int = Field(gt=0)
>>> @app.route("/users", methods=["POST"])
... def create_user():
... # In a real request context:
... user_data = extract_pydantic_data(UserCreate)
... # user_data is now a validated UserCreate instance
... return {"id": 1, "username": user_data.username}
Note
This function combines data from request.json, request.form, and request.args.
Source code in src/flask_x_openapi_schema/x/flask/utils.py
generate_openapi_schema(blueprint, title, version, description='', output_format='yaml', language=None)
¶
Generate an OpenAPI schema from a Flask blueprint with MethodView classes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
blueprint
|
Blueprint
|
The Flask blueprint with registered MethodView classes. |
required |
title
|
str | I18nStr
|
The title of the API. Can be a string or I18nStr for internationalization. |
required |
version
|
str
|
The version of the API. |
required |
description
|
str | I18nStr
|
The description of the API. Can be a string or I18nStr for internationalization. |
''
|
output_format
|
str
|
The output format. Options are "yaml" or "json". Defaults to "yaml". |
'yaml'
|
language
|
str | None
|
The language to use for internationalized strings. If None, uses the current language. |
None
|
Returns:
Type | Description |
---|---|
dict[str, Any] | str
|
dict or str: The OpenAPI schema as a dictionary (if output_format is "json") or as a YAML string (if output_format is "yaml"). |
Examples:
>>> from flask import Blueprint
>>> bp = Blueprint("api", __name__)
>>> schema = generate_openapi_schema(
... blueprint=bp, title="My API", version="1.0.0", description="My API Description", output_format="yaml"
... )
>>> isinstance(schema, str)
True
>>> "title: My API" in schema
True
Source code in src/flask_x_openapi_schema/x/flask/utils.py
register_model_schema(generator, model)
¶
Register a Pydantic model schema with an OpenAPI schema generator.
This function registers a Pydantic model with the OpenAPI schema generator, making it available in the components/schemas section of the generated OpenAPI schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
generator
|
OpenAPISchemaGenerator
|
The OpenAPI schema generator instance. |
required |
model
|
type[BaseModel]
|
The Pydantic model class to register. |
required |
Examples:
>>> from pydantic import BaseModel, Field
>>> from flask_x_openapi_schema.x.flask.views import MethodViewOpenAPISchemaGenerator
>>> class User(BaseModel):
... id: int = Field(..., description="User ID")
... name: str = Field(..., description="User name")
>>> generator = MethodViewOpenAPISchemaGenerator(title="My API", version="1.0.0")
>>> register_model_schema(generator, User)
>>> schema = generator.generate_schema()
>>> "User" in schema["components"]["schemas"]
True
Note
This function uses the internal _register_model method of the generator.