|
8 | 8 | from fastapi import routing |
9 | 9 | from fastapi._compat import ( |
10 | 10 | ModelField, |
11 | | - Undefined, |
12 | 11 | get_definitions, |
13 | 12 | get_flat_models_from_fields, |
14 | 13 | get_model_name_map, |
15 | 14 | get_schema_from_model_field, |
16 | 15 | lenient_issubclass, |
17 | 16 | ) |
18 | | -from fastapi.datastructures import DefaultPlaceholder |
| 17 | +from fastapi.datastructures import DefaultPlaceholder, _Unset |
19 | 18 | from fastapi.dependencies.models import Dependant |
20 | 19 | from fastapi.dependencies.utils import ( |
21 | 20 | _get_flat_fields_from_params, |
@@ -170,7 +169,7 @@ def _get_openapi_operation_parameters( |
170 | 169 | example = getattr(field_info, "example", None) |
171 | 170 | if openapi_examples: |
172 | 171 | parameter["examples"] = jsonable_encoder(openapi_examples) |
173 | | - elif example != Undefined: |
| 172 | + elif example is not _Unset: |
174 | 173 | parameter["example"] = jsonable_encoder(example) |
175 | 174 | if getattr(field_info, "deprecated", None): |
176 | 175 | parameter["deprecated"] = True |
@@ -207,7 +206,7 @@ def get_openapi_operation_request_body( |
207 | 206 | request_media_content["examples"] = jsonable_encoder( |
208 | 207 | field_info.openapi_examples |
209 | 208 | ) |
210 | | - elif field_info.example != Undefined: |
| 209 | + elif field_info.example is not _Unset: |
211 | 210 | request_media_content["example"] = jsonable_encoder(field_info.example) |
212 | 211 | request_body_oai["content"] = {request_media_type: request_media_content} |
213 | 212 | return request_body_oai |
|
0 commit comments