back to Claude Sonnet 3.5 - Fill-in summary
Claude Sonnet 3.5 - Fill-in: fastapi
Pytest Summary for test tests
status | count |
---|---|
failed | 29 |
skipped | 3 |
total | 32 |
collected | 32 |
passed | 0 |
Failed pytests:
test_tutorial003_04.py::test_invalid_response_model
test_tutorial003_04.py::test_invalid_response_model
def test_invalid_response_model(): with pytest.raises(FastAPIError): > from docs_src.response_model.tutorial003_04 import app tests/test_tutorial/test_response_model/test_tutorial003_04.py:7: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/response_model/tutorial003_04.py:3: infrom fastapi import FastAPI, Response fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial003_04_py310.py::test_invalid_response_model
test_tutorial003_04_py310.py::test_invalid_response_model
@needs_py310 def test_invalid_response_model(): with pytest.raises(FastAPIError): > from docs_src.response_model.tutorial003_04_py310 import app tests/test_tutorial/test_response_model/test_tutorial003_04_py310.py:10: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/response_model/tutorial003_04_py310.py:1: infrom fastapi import FastAPI, Response fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_app02.py::test_settings
test_app02.py::test_settings
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7eee53d790c0> @needs_pydanticv2 def test_settings(monkeypatch: MonkeyPatch): > from docs_src.settings.app02 import main tests/test_tutorial/test_settings/test_app02.py:8: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/settings/app02/main.py:3: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_app02.py::test_override_settings
test_app02.py::test_override_settings
@needs_pydanticv2 def test_override_settings(): > from docs_src.settings.app02 import test_main tests/test_tutorial/test_settings/test_app02.py:18: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .venv/lib/python3.10/site-packages/_pytest/assertion/rewrite.py:184: in exec_module exec(co, module.__dict__) docs_src/settings/app02/test_main.py:1: infrom fastapi.testclient import TestClient fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_main_b_an_py310.py::test_app
test_main_b_an_py310.py::test_app
@needs_py310 def test_app(): > from docs_src.app_testing.app_b_an_py310 import test_main tests/test_tutorial/test_testing/test_main_b_an_py310.py:6: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .venv/lib/python3.10/site-packages/_pytest/assertion/rewrite.py:184: in exec_module exec(co, module.__dict__) docs_src/app_testing/app_b_an_py310/test_main.py:1: infrom fastapi.testclient import TestClient fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_main_b_an_py39.py::test_app
test_main_b_an_py39.py::test_app
@needs_py39 def test_app(): > from docs_src.app_testing.app_b_an_py39 import test_main tests/test_tutorial/test_testing/test_main_b_an_py39.py:6: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .venv/lib/python3.10/site-packages/_pytest/assertion/rewrite.py:184: in exec_module exec(co, module.__dict__) docs_src/app_testing/app_b_an_py39/test_main.py:1: infrom fastapi.testclient import TestClient fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_main_b_py310.py::test_app
test_main_b_py310.py::test_app
@needs_py310 def test_app(): > from docs_src.app_testing.app_b_py310 import test_main tests/test_tutorial/test_testing/test_main_b_py310.py:6: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .venv/lib/python3.10/site-packages/_pytest/assertion/rewrite.py:184: in exec_module exec(co, module.__dict__) docs_src/app_testing/app_b_py310/test_main.py:1: infrom fastapi.testclient import TestClient fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial003.py::test_main
test_tutorial003.py::test_main
def test_main(): with pytest.warns(DeprecationWarning): > from docs_src.app_testing.tutorial003 import test_read_items tests/test_tutorial/test_testing/test_tutorial003.py:6: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/app_testing/tutorial003.py:1: infrom fastapi import FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError During handling of the above exception, another exception occurred: def test_main(): > with pytest.warns(DeprecationWarning): E Failed: DID NOT WARN. No warnings of type ( ,) were emitted. E Emitted warnings: []. tests/test_tutorial/test_testing/test_tutorial003.py:5: Failed
test_tutorial001_an_py310.py::test_override_in_items_run
test_tutorial001_an_py310.py::test_override_in_items_run
@needs_py310 def test_override_in_items_run(): > from docs_src.dependency_testing.tutorial001_an_py310 import test_override_in_items tests/test_tutorial/test_testing_dependencies/test_tutorial001_an_py310.py:6: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_an_py310.py:3: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_an_py310.py::test_override_in_items_with_q_run
test_tutorial001_an_py310.py::test_override_in_items_with_q_run
@needs_py310 def test_override_in_items_with_q_run(): > from docs_src.dependency_testing.tutorial001_an_py310 import ( test_override_in_items_with_q, ) tests/test_tutorial/test_testing_dependencies/test_tutorial001_an_py310.py:13: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_an_py310.py:3: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_an_py310.py::test_override_in_items_with_params_run
test_tutorial001_an_py310.py::test_override_in_items_with_params_run
@needs_py310 def test_override_in_items_with_params_run(): > from docs_src.dependency_testing.tutorial001_an_py310 import ( test_override_in_items_with_params, ) tests/test_tutorial/test_testing_dependencies/test_tutorial001_an_py310.py:22: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_an_py310.py:3: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_an_py310.py::test_override_in_users
test_tutorial001_an_py310.py::test_override_in_users
@needs_py310 def test_override_in_users(): > from docs_src.dependency_testing.tutorial001_an_py310 import client tests/test_tutorial/test_testing_dependencies/test_tutorial001_an_py310.py:31: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_an_py310.py:3: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_an_py310.py::test_override_in_users_with_q
test_tutorial001_an_py310.py::test_override_in_users_with_q
@needs_py310 def test_override_in_users_with_q(): > from docs_src.dependency_testing.tutorial001_an_py310 import client tests/test_tutorial/test_testing_dependencies/test_tutorial001_an_py310.py:43: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_an_py310.py:3: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_an_py310.py::test_override_in_users_with_params
test_tutorial001_an_py310.py::test_override_in_users_with_params
@needs_py310 def test_override_in_users_with_params(): > from docs_src.dependency_testing.tutorial001_an_py310 import client tests/test_tutorial/test_testing_dependencies/test_tutorial001_an_py310.py:55: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_an_py310.py:3: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_an_py310.py::test_normal_app
test_tutorial001_an_py310.py::test_normal_app
@needs_py310 def test_normal_app(): > from docs_src.dependency_testing.tutorial001_an_py310 import app, client tests/test_tutorial/test_testing_dependencies/test_tutorial001_an_py310.py:67: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_an_py310.py:3: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_an_py39.py::test_override_in_items_run
test_tutorial001_an_py39.py::test_override_in_items_run
@needs_py39 def test_override_in_items_run(): > from docs_src.dependency_testing.tutorial001_an_py39 import test_override_in_items tests/test_tutorial/test_testing_dependencies/test_tutorial001_an_py39.py:6: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_an_py39.py:3: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_an_py39.py::test_override_in_items_with_q_run
test_tutorial001_an_py39.py::test_override_in_items_with_q_run
@needs_py39 def test_override_in_items_with_q_run(): > from docs_src.dependency_testing.tutorial001_an_py39 import ( test_override_in_items_with_q, ) tests/test_tutorial/test_testing_dependencies/test_tutorial001_an_py39.py:13: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_an_py39.py:3: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_an_py39.py::test_override_in_items_with_params_run
test_tutorial001_an_py39.py::test_override_in_items_with_params_run
@needs_py39 def test_override_in_items_with_params_run(): > from docs_src.dependency_testing.tutorial001_an_py39 import ( test_override_in_items_with_params, ) tests/test_tutorial/test_testing_dependencies/test_tutorial001_an_py39.py:22: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_an_py39.py:3: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_an_py39.py::test_override_in_users
test_tutorial001_an_py39.py::test_override_in_users
@needs_py39 def test_override_in_users(): > from docs_src.dependency_testing.tutorial001_an_py39 import client tests/test_tutorial/test_testing_dependencies/test_tutorial001_an_py39.py:31: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_an_py39.py:3: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_an_py39.py::test_override_in_users_with_q
test_tutorial001_an_py39.py::test_override_in_users_with_q
@needs_py39 def test_override_in_users_with_q(): > from docs_src.dependency_testing.tutorial001_an_py39 import client tests/test_tutorial/test_testing_dependencies/test_tutorial001_an_py39.py:43: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_an_py39.py:3: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_an_py39.py::test_override_in_users_with_params
test_tutorial001_an_py39.py::test_override_in_users_with_params
@needs_py39 def test_override_in_users_with_params(): > from docs_src.dependency_testing.tutorial001_an_py39 import client tests/test_tutorial/test_testing_dependencies/test_tutorial001_an_py39.py:55: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_an_py39.py:3: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_an_py39.py::test_normal_app
test_tutorial001_an_py39.py::test_normal_app
@needs_py39 def test_normal_app(): > from docs_src.dependency_testing.tutorial001_an_py39 import app, client tests/test_tutorial/test_testing_dependencies/test_tutorial001_an_py39.py:67: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_an_py39.py:3: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_py310.py::test_override_in_items_run
test_tutorial001_py310.py::test_override_in_items_run
@needs_py310 def test_override_in_items_run(): > from docs_src.dependency_testing.tutorial001_py310 import test_override_in_items tests/test_tutorial/test_testing_dependencies/test_tutorial001_py310.py:6: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_py310.py:1: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_py310.py::test_override_in_items_with_q_run
test_tutorial001_py310.py::test_override_in_items_with_q_run
@needs_py310 def test_override_in_items_with_q_run(): > from docs_src.dependency_testing.tutorial001_py310 import ( test_override_in_items_with_q, ) tests/test_tutorial/test_testing_dependencies/test_tutorial001_py310.py:13: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_py310.py:1: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_py310.py::test_override_in_items_with_params_run
test_tutorial001_py310.py::test_override_in_items_with_params_run
@needs_py310 def test_override_in_items_with_params_run(): > from docs_src.dependency_testing.tutorial001_py310 import ( test_override_in_items_with_params, ) tests/test_tutorial/test_testing_dependencies/test_tutorial001_py310.py:22: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_py310.py:1: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_py310.py::test_override_in_users
test_tutorial001_py310.py::test_override_in_users
@needs_py310 def test_override_in_users(): > from docs_src.dependency_testing.tutorial001_py310 import client tests/test_tutorial/test_testing_dependencies/test_tutorial001_py310.py:31: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_py310.py:1: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_py310.py::test_override_in_users_with_q
test_tutorial001_py310.py::test_override_in_users_with_q
@needs_py310 def test_override_in_users_with_q(): > from docs_src.dependency_testing.tutorial001_py310 import client tests/test_tutorial/test_testing_dependencies/test_tutorial001_py310.py:43: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_py310.py:1: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_py310.py::test_override_in_users_with_params
test_tutorial001_py310.py::test_override_in_users_with_params
@needs_py310 def test_override_in_users_with_params(): > from docs_src.dependency_testing.tutorial001_py310 import client tests/test_tutorial/test_testing_dependencies/test_tutorial001_py310.py:55: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_py310.py:1: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
test_tutorial001_py310.py::test_normal_app
test_tutorial001_py310.py::test_normal_app
@needs_py310 def test_normal_app(): > from docs_src.dependency_testing.tutorial001_py310 import app, client tests/test_tutorial/test_testing_dependencies/test_tutorial001_py310.py:67: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ docs_src/dependency_testing/tutorial001_py310.py:1: infrom fastapi import Depends, FastAPI fastapi/__init__.py:7: in from .applications import FastAPI as FastAPI fastapi/applications.py:3: in from fastapi import routing fastapi/routing.py:9: in from fastapi import params fastapi/params.py:4: in from fastapi.openapi.models import Example _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ from enum import Enum from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union > from fastapi._compat import PYDANTIC_V2, CoreSchema, GetJsonSchemaHandler, JsonSchemaValue, _model_rebuild, with_info_plain_validator_function E ImportError: cannot import name '_model_rebuild' from 'fastapi._compat' (/testbed/fastapi/_compat.py) fastapi/openapi/models.py:3: ImportError
Patch diff
diff --git a/fastapi/background.py b/fastapi/background.py
index 368be9bc..10d3f1ec 100644
--- a/fastapi/background.py
+++ b/fastapi/background.py
@@ -46,4 +46,4 @@ class BackgroundTasks(StarletteBackgroundTasks):
Read more about it in the
[FastAPI docs for Background Tasks](https://fastapi.tiangolo.com/tutorial/background-tasks/).
"""
- pass
+ super().add_task(func, *args, **kwargs)
diff --git a/fastapi/datastructures.py b/fastapi/datastructures.py
index e6043019..8f03ea18 100644
--- a/fastapi/datastructures.py
+++ b/fastapi/datastructures.py
@@ -63,7 +63,7 @@ class UploadFile(StarletteUploadFile):
To be awaitable, compatible with async, this is run in threadpool.
"""
- pass
+ await self._run_in_threadpool(self.file.write, data)
async def read(self, size: Annotated[int, Doc(
"""
@@ -75,7 +75,7 @@ class UploadFile(StarletteUploadFile):
To be awaitable, compatible with async, this is run in threadpool.
"""
- pass
+ return await self._run_in_threadpool(self.file.read, size)
async def seek(self, offset: Annotated[int, Doc(
"""
@@ -89,7 +89,7 @@ class UploadFile(StarletteUploadFile):
To be awaitable, compatible with async, this is run in threadpool.
"""
- pass
+ await self._run_in_threadpool(self.file.seek, offset)
async def close(self) ->None:
"""
@@ -97,7 +97,7 @@ class UploadFile(StarletteUploadFile):
To be awaitable, compatible with async, this is run in threadpool.
"""
- pass
+ await self._run_in_threadpool(self.file.close)
@classmethod
def __get_validators__(cls: Type['UploadFile']) ->Iterable[Callable[...,
@@ -148,4 +148,4 @@ def Default(value: DefaultType) ->DefaultType:
It's used internally to recognize when a default value has been overwritten, even
if the overridden default value was truthy.
"""
- pass
+ return cast(DefaultType, DefaultPlaceholder(value))
diff --git a/fastapi/encoders.py b/fastapi/encoders.py
index 66986830..e6a4b4a7 100644
--- a/fastapi/encoders.py
+++ b/fastapi/encoders.py
@@ -33,7 +33,10 @@ def decimal_encoder(dec_value: Decimal) ->Union[int, float]:
>>> decimal_encoder(Decimal("1"))
1
"""
- pass
+ if dec_value.as_tuple().exponent == 0:
+ return int(dec_value)
+ else:
+ return float(dec_value)
ENCODERS_BY_TYPE: Dict[Type[Any], Callable[[Any], Any]] = {bytes: lambda o:
@@ -114,4 +117,100 @@ def jsonable_encoder(obj: Annotated[Any, Doc(
Read more about it in the
[FastAPI docs for JSON Compatible Encoder](https://fastapi.tiangolo.com/tutorial/encoder/).
"""
- pass
+ if custom_encoder is None:
+ custom_encoder = {}
+
+ if isinstance(obj, BaseModel):
+ encoder = getattr(obj.__config__, "json_encoders", {})
+ if custom_encoder:
+ encoder.update(custom_encoder)
+ return _model_dump(
+ obj,
+ mode="json",
+ include=include,
+ exclude=exclude,
+ by_alias=by_alias,
+ exclude_unset=exclude_unset,
+ exclude_defaults=exclude_defaults,
+ exclude_none=exclude_none,
+ custom_encoder=encoder,
+ )
+
+ if dataclasses.is_dataclass(obj):
+ return dataclasses.asdict(obj)
+
+ if isinstance(obj, Enum):
+ return obj.value
+
+ if isinstance(obj, PurePath):
+ return str(obj)
+
+ if isinstance(obj, (str, int, float, type(None))):
+ return obj
+
+ if isinstance(obj, dict):
+ encoded_dict = {}
+ for key, value in obj.items():
+ if isinstance(key, bytes):
+ encoded_key = key.decode()
+ else:
+ encoded_key = jsonable_encoder(
+ key,
+ by_alias=by_alias,
+ exclude_unset=exclude_unset,
+ exclude_defaults=exclude_defaults,
+ exclude_none=exclude_none,
+ custom_encoder=custom_encoder,
+ sqlalchemy_safe=sqlalchemy_safe,
+ )
+ encoded_value = jsonable_encoder(
+ value,
+ by_alias=by_alias,
+ exclude_unset=exclude_unset,
+ exclude_defaults=exclude_defaults,
+ exclude_none=exclude_none,
+ custom_encoder=custom_encoder,
+ sqlalchemy_safe=sqlalchemy_safe,
+ )
+ encoded_dict[encoded_key] = encoded_value
+ return encoded_dict
+
+ if isinstance(obj, (list, set, frozenset, GeneratorType, tuple)):
+ return [
+ jsonable_encoder(
+ item,
+ include=include,
+ exclude=exclude,
+ by_alias=by_alias,
+ exclude_unset=exclude_unset,
+ exclude_defaults=exclude_defaults,
+ exclude_none=exclude_none,
+ custom_encoder=custom_encoder,
+ sqlalchemy_safe=sqlalchemy_safe,
+ )
+ for item in obj
+ ]
+
+ if type(obj) in ENCODERS_BY_TYPE:
+ return ENCODERS_BY_TYPE[type(obj)](obj)
+
+ for encoder, classes_tuple in encoders_by_class_tuples:
+ if isinstance(obj, classes_tuple):
+ return encoder(obj)
+
+ try:
+ data = dict(obj)
+ except Exception:
+ return str(obj)
+
+ return jsonable_encoder(
+ data,
+ include=include,
+ exclude=exclude,
+ by_alias=by_alias,
+ exclude_unset=exclude_unset,
+ exclude_defaults=exclude_defaults,
+ exclude_none=exclude_none,
+ custom_encoder=custom_encoder,
+ sqlalchemy_safe=sqlalchemy_safe,
+ )
diff --git a/fastapi/openapi/docs.py b/fastapi/openapi/docs.py
index a9c03e54..f7c0cdf0 100644
--- a/fastapi/openapi/docs.py
+++ b/fastapi/openapi/docs.py
@@ -71,7 +71,43 @@ def get_swagger_ui_html(*, openapi_url: Annotated[str, Doc(
[FastAPI docs for Configure Swagger UI](https://fastapi.tiangolo.com/how-to/configure-swagger-ui/)
and the [FastAPI docs for Custom Docs UI Static Assets (Self-Hosting)](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/).
"""
- pass
+ if swagger_ui_parameters is None:
+ swagger_ui_parameters = swagger_ui_default_parameters
+
+ html = f"""
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <link type="text/css" rel="stylesheet" href="{swagger_css_url}">
+ <link rel="shortcut icon" href="{swagger_favicon_url}">
+ <title>{title}</title>
+ </head>
+ <body>
+ <div id="swagger-ui">
+ </div>
+ <script src="{swagger_js_url}"></script>
+ <!-- `SwaggerUIBundle` is now available on the page -->
+ <script>
+ const ui = SwaggerUIBundle({{
+ url: '{openapi_url}',
+ oauth2RedirectUrl: {json.dumps(oauth2_redirect_url)},
+ dom_id: '#swagger-ui',
+ presets: [
+ SwaggerUIBundle.presets.apis,
+ SwaggerUIBundle.SwaggerUIStandalonePreset
+ ],
+ layout: "BaseLayout",
+ deepLinking: true,
+ showExtensions: true,
+ showCommonExtensions: true,
+ {f"initOAuth: {json.dumps(jsonable_encoder(init_oauth))}," if init_oauth else ""}
+ ...{json.dumps(swagger_ui_parameters)}
+ }})
+ </script>
+ </body>
+ </html>
+ """
+ return HTMLResponse(html)
def get_redoc_html(*, openapi_url: Annotated[str, Doc(
@@ -113,7 +149,38 @@ def get_redoc_html(*, openapi_url: Annotated[str, Doc(
Read more about it in the
[FastAPI docs for Custom Docs UI Static Assets (Self-Hosting)](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/).
"""
- pass
+ html = f"""
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <title>{title}</title>
+ <!-- needed for adaptive design -->
+ <meta charset="utf-8"/>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ """
+ if with_google_fonts:
+ html += """
+ <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
+ """
+ html += f"""
+ <link rel="shortcut icon" href="{redoc_favicon_url}">
+ <!--
+ ReDoc doesn't change outer page styles
+ -->
+ <style>
+ body {{
+ margin: 0;
+ padding: 0;
+ }}
+ </style>
+ </head>
+ <body>
+ <redoc spec-url="{openapi_url}"></redoc>
+ <script src="{redoc_js_url}"> </script>
+ </body>
+ </html>
+ """
+ return HTMLResponse(html)
def get_swagger_ui_oauth2_redirect_html() ->HTMLResponse:
@@ -122,4 +189,73 @@ def get_swagger_ui_oauth2_redirect_html() ->HTMLResponse:
You normally don't need to use or change this.
"""
- pass
+ html = """
+ <!DOCTYPE html>
+ <html lang="en-US">
+ <body onload="run()">
+ </body>
+ </html>
+ <script>
+ 'use strict';
+ function run () {
+ var oauth2 = window.opener.swaggerUIRedirectOauth2;
+ var sentState = oauth2.state;
+ var redirectUrl = oauth2.redirectUrl;
+ var isValid, qp, arr;
+
+ if (/code|token|error/.test(window.location.hash)) {
+ qp = window.location.hash.substring(1);
+ } else {
+ qp = location.search.substring(1);
+ }
+
+ arr = qp.split("&")
+ arr.forEach(function (v,i,_arr) { _arr[i] = '"' + v.replace('=', '":"') + '"';})
+ qp = qp ? JSON.parse('{' + arr.join() + '}',
+ function (key, value) {
+ return key === "" ? value : decodeURIComponent(value)
+ }
+ ) : {}
+
+ isValid = qp.state === sentState
+
+ if ((
+ oauth2.auth.schema.get("flow") === "accessCode"||
+ oauth2.auth.schema.get("flow") === "authorizationCode"
+ ) && !oauth2.auth.code) {
+ if (!isValid) {
+ oauth2.errCb({
+ authId: oauth2.auth.name,
+ source: "auth",
+ level: "warning",
+ message: "Authorization may be unsafe, passed state was changed in server Passed state wasn't returned from auth server"
+ });
+ }
+
+ if (qp.code) {
+ delete oauth2.state;
+ oauth2.auth.code = qp.code;
+ oauth2.callback({auth: oauth2.auth, redirectUrl: redirectUrl});
+ } else {
+ let oauthErrorMsg
+ if (qp.error) {
+ oauthErrorMsg = "["+qp.error+"]: " +
+ (qp.error_description ? qp.error_description+ ". " : "no accessCode received from the server. ") +
+ (qp.error_uri ? "More info: "+qp.error_uri : "");
+ }
+
+ oauth2.errCb({
+ authId: oauth2.auth.name,
+ source: "auth",
+ level: "error",
+ message: oauthErrorMsg || "[Authorization failed]: no accessCode received from the server"
+ });
+ }
+ } else {
+ oauth2.callback({auth: oauth2.auth, token: qp, isValid: isValid, redirectUrl: redirectUrl});
+ }
+ window.close();
+ }
+ </script>
+ """
+ return HTMLResponse(content=html)
diff --git a/fastapi/param_functions.py b/fastapi/param_functions.py
index 298d63fa..c99dc23d 100644
--- a/fastapi/param_functions.py
+++ b/fastapi/param_functions.py
@@ -180,7 +180,37 @@ def Path(default: Annotated[Any, Doc(
return {"item_id": item_id}
```
"""
- pass
+ return params.Path(
+ default=default,
+ default_factory=default_factory,
+ alias=alias,
+ alias_priority=alias_priority,
+ validation_alias=validation_alias,
+ serialization_alias=serialization_alias,
+ title=title,
+ description=description,
+ gt=gt,
+ ge=ge,
+ lt=lt,
+ le=le,
+ min_length=min_length,
+ max_length=max_length,
+ pattern=pattern,
+ regex=regex,
+ discriminator=discriminator,
+ strict=strict,
+ multiple_of=multiple_of,
+ allow_inf_nan=allow_inf_nan,
+ max_digits=max_digits,
+ decimal_places=decimal_places,
+ examples=examples,
+ example=example,
+ openapi_examples=openapi_examples,
+ deprecated=deprecated,
+ include_in_schema=include_in_schema,
+ json_schema_extra=json_schema_extra,
+ **extra
+ )
def Depends(dependency: Annotated[Optional[Callable[..., Any]], Doc(
@@ -230,7 +260,7 @@ def Depends(dependency: Annotated[Optional[Callable[..., Any]], Doc(
return commons
```
"""
- pass
+ return params.Depends(dependency=dependency, use_cache=use_cache)
def Security(dependency: Annotated[Optional[Callable[..., Any]], Doc(
@@ -299,4 +329,4 @@ def Security(dependency: Annotated[Optional[Callable[..., Any]], Doc(
return [{"item_id": "Foo", "owner": current_user.username}]
```
"""
- pass
+ return params.Security(dependency=dependency, scopes=scopes, use_cache=use_cache)
diff --git a/fastapi/utils.py b/fastapi/utils.py
index a742b860..cd0b7efd 100644
--- a/fastapi/utils.py
+++ b/fastapi/utils.py
@@ -24,7 +24,33 @@ def create_response_field(name: str, type_: Type[Any], class_validators:
"""
Create a new response field. Raises if type_ is invalid.
"""
- pass
+ try:
+ if PYDANTIC_V2:
+ from pydantic.fields import FieldInfo as PydanticFieldInfo
+ field_info = field_info or PydanticFieldInfo()
+ return ModelField(
+ name=name,
+ type_=type_,
+ class_validators=class_validators,
+ default=default,
+ required=required,
+ model_config=model_config,
+ field_info=field_info,
+ alias=alias,
+ )
+ else:
+ return ModelField(
+ name=name,
+ type_=type_,
+ class_validators=class_validators,
+ default=default,
+ required=required,
+ model_config=model_config,
+ field_info=field_info,
+ alias=alias,
+ )
+ except PydanticSchemaGenerationError as e:
+ raise ValueError(f"Invalid type for response field: {e}")
def get_value_or_default(first_item: Union[DefaultPlaceholder, DefaultType],
@@ -37,4 +63,7 @@ def get_value_or_default(first_item: Union[DefaultPlaceholder, DefaultType],
Otherwise, the first item (a `DefaultPlaceholder`) will be returned.
"""
- pass
+ for item in (first_item, *extra_items):
+ if not isinstance(item, DefaultPlaceholder):
+ return item
+ return first_item