โ† eval8_submission_v1e

fastapi_14246

failed CONTEXT NO_PATCH UNSUBMITTED agent_error ยท 20 tool calls ยท 62 s ยท fastapi/fastapi

Task input

๐Ÿ› Fix separation of schemas with nested models introduced in 0.119.0

๐Ÿ› Fix separation of schemas with nested models introduced in 0.119.0

This should fix / related to https://github.com/fastapi/fastapi/issues/14247 (https://github.com/fastapi/fastapi/discussions/14177)

Tool calls (20)

#ToolArgumentsResult
1run_command
{
 "command": "grep -rn \"separation of schemas\" ."
}
{"status": "error", "error_type": "CommandError", "error_message": "", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
full
{"status": "error", "error_type": "CommandError", "error_message": "", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
2run_command
{
 "command": "grep -rn \"14247\" ."
}
{"status": "ok", "stdout": "./docs/en/docs/img/sponsors/doist-banner.svg:5:<path d=\"M36.4366 -5.93745C36.4538 -6.0756 36.4433 -6.21716 36.4483 -6.37084L37.1813
full
{"status": "ok", "stdout": "./docs/en/docs/img/sponsors/doist-banner.svg:5:<path d=\"M36.4366 -5.93745C36.4538 -6.0756 36.4433 -6.21716 36.4483 -6.37084L37.1813 -7.07956L37.5635 -6.54123L38.7134 -6.53909C38.7199 -6.93103 38.7074 -7.28321 38.7087 -7.63372C38.8779 -7.64081 39.0489 -7.66172 39.2319 -7.6671C39.2815 -8.06773 39.3364 -8.3976 39.1667 -8.83943C39.0239 -8.36618 38.6254 -8.09289 38.7209 -7.61817C38.448 -7.68003 38.4105 -7.26387 38.1669 -7.33613C37.863 -7.37378 37.7833 -7.63614 37.6019 -7.7568C37.619 -7.89495 37.5912 -8.01066 37.6791 -8.15406C37.9273 -8.57218 38.1859 -8.96096 38.1836 -9.5083C38.1797 -9.92959 38.3949 -10.4219 38.7883 -10.6537C39.6338 -11.1381 40.0233 -11.7912 40.1708 -12.7548C40.2479 -13.2642 40.8846 -13.6482 40.9771 -14.282C41.369 -14.3877 41.6553 -14.6608 41.9312 -14.9633C42.244 -14.7703 42.5118 -14.5547 42.4036 -14.0211L43.2349 -14.8439L43.2326 -15.3912C43.5222 -15.8042 44.0676 -16.0171 44.124 -16.5852C44.7006 -16.598 44.7432 -17.1678 44.9794 -17.4892C45.2673 -17.8884 45.6728 -18.1047 45.9953 -18.4435C46.3178 -18.7823 46.6525 -19.1054 47.006 -19.4684C47.4084 -19.4326 47.7448 -19.6574 48.1003 -19.8098L48.5012 -19.5357C48.7326 -19.479 48.8067 -19.6241 48.9257 -19.6794C49.3882 -19.9027 48.9352 -20.548 49.4149 -20.7971L51.2221 -21.3447L52.4328 -22.6255C52.8195 -22.6898 53.1289 -22.3569 53.3429 -22.3865C54.446 -22.5724 55.5874 -22.5011 56.6488 -22.9167C56.8697 -23.0015 56.8108 -23.2053 56.8641 -23.4091C57.3196 -23.6893 57.9884 -23.1996 58.3814 -23.7681C58.5214 -23.6526 58.6079 -23.4455 58.91 -23.5063C59.2069 -23.6378 59.0768 -24.1729 59.4858 -24.3046C60.432 -24.3557 61.3224 -24.8626 62.3155 -24.6133C62.5469 -24.5566 62.4781 -24.3407 62.5283 -24.1802C62.7116 -23.9611 62.9704 -24.1254 63.2018 -24.0686L63.6571 -24.5734L67.4015 -25.1334C67.5829 -25.0127 68.0008 -24.989 68.21 -24.7527C69.6995 -25.2274 70.9554 -24.7212 72.4755 -24.084L74.019 -24.0892L74.7472 -22.947C75.8675 -23.1588 76.8782 -22.5987 78.006 -22.3047L78.7683 -21.5511L80.2273 -21.5527C80.
3run_command
{
 "command": "grep -rn \"separation of schemas\" ."
}
{"status": "error", "error_type": "CommandError", "error_message": "", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
full
{"status": "error", "error_type": "CommandError", "error_message": "", "details": {"stdout": "", "stderr": "", "exit_code": 1}}
4run_command
{
 "command": "find . -maxdepth 3 -name \"*schema*\""
}
{"status": "ok", "stdout": "./scripts/playwright/separate_openapi_schemas\n./tests/test_repeated_dependency_schema.py\n./tests/test_openapi_schema_type.py\n./te
full
{"status": "ok", "stdout": "./scripts/playwright/separate_openapi_schemas\n./tests/test_repeated_dependency_schema.py\n./tests/test_openapi_schema_type.py\n./tests/test_custom_schema_fields.py\n./tests/test_tutorial/test_schema_extra_example\n./tests/test_tutorial/test_separate_openapi_schemas\n./tests/test_openapi_separate_input_output_schemas.py\n./tests/test_schema_extra_examples.py\n./tests/test_param_include_in_schema.py\n./docs_src/schema_extra_example\n./docs_src/separate_openapi_schemas\n", "stderr": "", "exit_code": 0}
5run_command
{
 "command": "ls -R tests/test_tutorial/test_separate_openapi_schemas"
}
{"status": "ok", "stdout": "tests/test_tutorial/test_separate_openapi_schemas:\n__init__.py\ntest_tutorial001.py\ntest_tutorial002.py\n", "stderr": "", "exit_co
full
{"status": "ok", "stdout": "tests/test_tutorial/test_separate_openapi_schemas:\n__init__.py\ntest_tutorial001.py\ntest_tutorial002.py\n", "stderr": "", "exit_code": 0}
6run_command
{
 "command": "cat tests/test_tutorial/test_separate_openapi_schemas/test_tutorial001.py"
}
{"status": "ok", "stdout": "import importlib\n\nimport pytest\nfrom fastapi.testclient import TestClient\n\nfrom ...utils import needs_py39, needs_py310, needs_
full
{"status": "ok", "stdout": "import importlib\n\nimport pytest\nfrom fastapi.testclient import TestClient\n\nfrom ...utils import needs_py39, needs_py310, needs_pydanticv2\n\n\n@pytest.fixture(\n    name=\"client\",\n    params=[\n        \"tutorial001\",\n        pytest.param(\"tutorial001_py310\", marks=needs_py310),\n        pytest.param(\"tutorial001_py39\", marks=needs_py39),\n    ],\n)\ndef get_client(request: pytest.FixtureRequest) -> TestClient:\n    mod = importlib.import_module(f\"docs_src.separate_openapi_schemas.{request.param}\")\n\n    client = TestClient(mod.app)\n    return client\n\n\ndef test_create_item(client: TestClient) -> None:\n    response = client.post(\"/items/\", json={\"name\": \"Foo\"})\n    assert response.status_code == 200, response.text\n    assert response.json() == {\"name\": \"Foo\", \"description\": None}\n\n\ndef test_read_items(client: TestClient) -> None:\n    response = client.get(\"/items/\")\n    assert response.status_code == 200, response.text\n    assert response.json() == [\n        {\n            \"name\": \"Portal Gun\",\n            \"description\": \"Device to travel through the multi-rick-verse\",\n        },\n        {\"name\": \"Plumbus\", \"description\": None},\n    ]\n\n\n@needs_pydanticv2\ndef test_openapi_schema(client: TestClient) -> None:\n    response = client.get(\"/openapi.json\")\n    assert response.status_code == 200, response.text\n    assert response.json() == {\n        \"openapi\": \"3.1.0\",\n        \"info\": {\"title\": \"FastAPI\", \"version\": \"0.1.0\"},\n        \"paths\": {\n            \"/items/\": {\n                \"get\": {\n                    \"summary\": \"Read Items\",\n                    \"operationId\": \"read_items_items__get\",\n                    \"responses\": {\n                        \"200\": {\n                            \"description\": \"Successful Response\",\n                            \"content\": {\n                                \"application/json\": {\n    
7run_command
{
 "command": "cat docs_src/separate_openapi_schemas/tutorial001.py"
}
{"status": "ok", "stdout": "from typing import List, Union\n\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\n\n\nclass Item(BaseModel):\n name: st
full
{"status": "ok", "stdout": "from typing import List, Union\n\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\n\n\nclass Item(BaseModel):\n    name: str\n    description: Union[str, None] = None\n\n\napp = FastAPI()\n\n\n@app.post(\"/items/\")\ndef create_item(item: Item):\n    return item\n\n\n@app.get(\"/items/\")\ndef read_items() -> List[Item]:\n    return [\n        Item(\n            name=\"Portal Gun\",\n            description=\"Device to travel through the multi-rick-verse\",\n        ),\n        Item(name=\"Plumbus\"),\n    ]\n", "stderr": "", "exit_code": 0}
8run_command
{
 "command": "cat docs_src/separate_openapi_schemas/tutorial002.py"
}
{"status": "ok", "stdout": "from typing import List, Union\n\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\n\n\nclass Item(BaseModel):\n name: st
full
{"status": "ok", "stdout": "from typing import List, Union\n\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\n\n\nclass Item(BaseModel):\n    name: str\n    description: Union[str, None] = None\n\n\napp = FastAPI(separate_input_output_schemas=False)\n\n\n@app.post(\"/items/\")\ndef create_item(item: Item):\n    return item\n\n\n@app.get(\"/items/\")\ndef read_items() -> List[Item]:\n    return [\n        Item(\n            name=\"Portal Gun\",\n            description=\"Device to travel through the multi-rick-verse\",\n        ),\n        Item(name=\"Plumbus\"),\n    ]\n", "stderr": "", "exit_code": 0}
9run_command
{
 "command": "cat tests/test_tutorial/test_separate_openapi_schemas/test_tutorial002.py"
}
{"status": "ok", "stdout": "import importlib\n\nimport pytest\nfrom fastapi.testclient import TestClient\n\nfrom ...utils import needs_py39, needs_py310, needs_
full
{"status": "ok", "stdout": "import importlib\n\nimport pytest\nfrom fastapi.testclient import TestClient\n\nfrom ...utils import needs_py39, needs_py310, needs_pydanticv2\n\n\n@pytest.fixture(\n    name=\"client\",\n    params=[\n        \"tutorial002\",\n        pytest.param(\"tutorial002_py310\", marks=needs_py310),\n        pytest.param(\"tutorial002_py39\", marks=needs_py39),\n    ],\n)\ndef get_client(request: pytest.FixtureRequest) -> TestClient:\n    mod = importlib.import_module(f\"docs_src.separate_openapi_schemas.{request.param}\")\n\n    client = TestClient(mod.app)\n    return client\n\n\ndef test_create_item(client: TestClient) -> None:\n    response = client.post(\"/items/\", json={\"name\": \"Foo\"})\n    assert response.status_code == 200, response.text\n    assert response.json() == {\"name\": \"Foo\", \"description\": None}\n\n\ndef test_read_items(client: TestClient) -> None:\n    response = client.get(\"/items/\")\n    assert response.status_code == 200, response.text\n    assert response.json() == [\n        {\n            \"name\": \"Portal Gun\",\n            \"description\": \"Device to travel through the multi-rick-verse\",\n        },\n        {\"name\": \"Plumbus\", \"description\": None},\n    ]\n\n\n@needs_pydanticv2\ndef test_openapi_schema(client: TestClient) -> None:\n    response = client.get(\"/openapi.json\")\n    assert response.status_code == 200, response.text\n    assert response.json() == {\n        \"openapi\": \"3.1.0\",\n        \"info\": {\"title\": \"FastAPI\", \"version\": \"0.1.0\"},\n        \"paths\": {\n            \"/items/\": {\n                \"get\": {\n                    \"summary\": \"Read Items\",\n                    \"operationId\": \"read_items_items__get\",\n                    \"responses\": {\n                        \"200\": {\n                            \"description\": \"Successful Response\",\n                            \"content\": {\n                                \"application/json\": {\n    
10run_command
{
 "command": "grep -rn \"separate_input_output_schemas\" ."
}
{"status": "ok", "stdout": "./fastapi/_compat/may_v1.py:65: separate_input_output_schemas: bool = True,\n./fastapi/_compat/v1.py:243: separate_input_output_sche
full
{"status": "ok", "stdout": "./fastapi/_compat/may_v1.py:65:        separate_input_output_schemas: bool = True,\n./fastapi/_compat/v1.py:243:    separate_input_output_schemas: bool = True,\n./fastapi/_compat/v1.py:259:    separate_input_output_schemas: bool = True,\n./fastapi/_compat/main.py:271:    separate_input_output_schemas: bool = True,\n./fastapi/_compat/main.py:284:            separate_input_output_schemas=separate_input_output_schemas,\n./fastapi/_compat/main.py:295:                separate_input_output_schemas=separate_input_output_schemas,\n./fastapi/_compat/main.py:309:            separate_input_output_schemas=separate_input_output_schemas,\n./fastapi/_compat/main.py:322:    separate_input_output_schemas: bool = True,\n./fastapi/_compat/main.py:331:            separate_input_output_schemas=separate_input_output_schemas,\n./fastapi/_compat/main.py:341:            separate_input_output_schemas=separate_input_output_schemas,\n./fastapi/_compat/v2.py:181:    separate_input_output_schemas: bool = True,\n./fastapi/_compat/v2.py:184:        None if separate_input_output_schemas else \"validation\"\n./fastapi/_compat/v2.py:201:    separate_input_output_schemas: bool = True,\n./fastapi/_compat/v2.py:208:        None if separate_input_output_schemas else \"validation\"\n./fastapi/applications.py:786:        separate_input_output_schemas: Annotated[\n./fastapi/applications.py:870:        self.separate_input_output_schemas = separate_input_output_schemas\n./fastapi/applications.py:1073:                separate_input_output_schemas=self.separate_input_output_schemas,\n./fastapi/openapi/utils.py:102:    separate_input_output_schemas: bool = True,\n./fastapi/openapi/utils.py:133:                separate_input_output_schemas=separate_input_output_schemas,\n./fastapi/openapi/utils.py:175:    separate_input_output_schemas: bool = True,\n./fastapi/openapi/utils.py:184:        separate_input_output_schemas=separate_input_output_schemas,\n./fastapi/openapi/utils.py:258:    se
11run_command
{
 "command": "cat tests/test_openapi_separate_input_output_schemas.py"
}
{"status": "ok", "stdout": "from typing import List, Optional\n\nfrom fastapi import FastAPI\nfrom fastapi.testclient import TestClient\nfrom inline_snapshot im
full
{"status": "ok", "stdout": "from typing import List, Optional\n\nfrom fastapi import FastAPI\nfrom fastapi.testclient import TestClient\nfrom inline_snapshot import snapshot\nfrom pydantic import BaseModel\n\nfrom .utils import PYDANTIC_V2, needs_pydanticv2\n\n\nclass SubItem(BaseModel):\n    subname: str\n    sub_description: Optional[str] = None\n    tags: List[str] = []\n    if PYDANTIC_V2:\n        model_config = {\"json_schema_serialization_defaults_required\": True}\n\n\nclass Item(BaseModel):\n    name: str\n    description: Optional[str] = None\n    sub: Optional[SubItem] = None\n    if PYDANTIC_V2:\n        model_config = {\"json_schema_serialization_defaults_required\": True}\n\n\ndef get_app_client(separate_input_output_schemas: bool = True) -> TestClient:\n    app = FastAPI(separate_input_output_schemas=separate_input_output_schemas)\n\n    @app.post(\"/items/\", responses={402: {\"model\": Item}})\n    def create_item(item: Item) -> Item:\n        return item\n\n    @app.post(\"/items-list/\")\n    def create_item_list(item: List[Item]):\n        return item\n\n    @app.get(\"/items/\")\n    def read_items() -> List[Item]:\n        return [\n            Item(\n                name=\"Portal Gun\",\n                description=\"Device to travel through the multi-rick-verse\",\n                sub=SubItem(subname=\"subname\"),\n            ),\n            Item(name=\"Plumbus\"),\n        ]\n\n    client = TestClient(app)\n    return client\n\n\ndef test_create_item():\n    client = get_app_client()\n    client_no = get_app_client(separate_input_output_schemas=False)\n    response = client.post(\"/items/\", json={\"name\": \"Plumbus\"})\n    response2 = client_no.post(\"/items/\", json={\"name\": \"Plumbus\"})\n    assert response.status_code == response2.status_code == 200, response.text\n    assert (\n        response.json()\n        == response2.json()\n        == {\"name\": \"Plumbus\", \"description\": None, \"sub\": None}\n    )\n\n\ndef test_create_
12run_command
{
 "command": "python -m pytest tests/test_openapi_separate_input_output_schemas.py"
}
{"status": "ok", "stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.13.14, pytest-9.1.1, pl
full
{"status": "ok", "stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.13.14, pytest-9.1.1, pluggy-1.6.0\ncodspeed: 5.0.3 (disabled, mode: walltime, callgraph: enabled, timer_resolution: 1.0ns)\nrootdir: /workspace\nconfigfile: pytest.ini (WARNING: ignoring pytest config in pyproject.toml!)\nplugins: anyio-4.15.1, sugar-1.1.1, inline-snapshot-0.35.4, timeout-2.4.0, xdist-3.8.0, codspeed-5.0.3, cov-7.1.0\ncollected 6 items\n\ntests/test_openapi_separate_input_output_schemas.py ......               [100%]\n\n=============================== warnings summary ===============================\n../../../../../../kaggle/tmp/envs/overlays/starlette-0.49.3-py3-none-any/starlette/testclient.py:51\n  /kaggle/tmp/envs/overlays/starlette-0.49.3-py3-none-any/starlette/testclient.py:51: DeprecationWarning: The anyio.abc.BlockingPortal alias is deprecated, use anyio.from_thread.BlockingPortal instead.\n    _PortalFactoryType = Callable[[], AbstractContextManager[anyio.abc.BlockingPortal]]\n\n-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html\n========================= 6 passed, 1 warning in 0.72s =========================\n", "stderr": "", "exit_code": 0}
13run_command
{
 "command": "cat fastapi/openapi/utils.py"
}
{"status": "ok", "stdout": "import http.client\nimport inspect\nimport warnings\nfrom typing import Any, Dict, List, Optional, Sequence, Set, Tuple, Type, Union
full
{"status": "ok", "stdout": "import http.client\nimport inspect\nimport warnings\nfrom typing import Any, Dict, List, Optional, Sequence, Set, Tuple, Type, Union, cast\n\nfrom fastapi import routing\nfrom fastapi._compat import (\n    JsonSchemaValue,\n    ModelField,\n    Undefined,\n    get_compat_model_name_map,\n    get_definitions,\n    get_schema_from_model_field,\n    lenient_issubclass,\n)\nfrom fastapi.datastructures import DefaultPlaceholder\nfrom fastapi.dependencies.models import Dependant\nfrom fastapi.dependencies.utils import (\n    _get_flat_fields_from_params,\n    get_flat_dependant,\n    get_flat_params,\n)\nfrom fastapi.encoders import jsonable_encoder\nfrom fastapi.openapi.constants import METHODS_WITH_BODY, REF_PREFIX\nfrom fastapi.openapi.models import OpenAPI\nfrom fastapi.params import Body, ParamTypes\nfrom fastapi.responses import Response\nfrom fastapi.types import ModelNameMap\nfrom fastapi.utils import (\n    deep_dict_update,\n    generate_operation_id_for_path,\n    is_body_allowed_for_status_code,\n)\nfrom pydantic import BaseModel\nfrom starlette.responses import JSONResponse\nfrom starlette.routing import BaseRoute\nfrom typing_extensions import Literal\n\nfrom .._compat import _is_model_field\n\nvalidation_error_definition = {\n    \"title\": \"ValidationError\",\n    \"type\": \"object\",\n    \"properties\": {\n        \"loc\": {\n            \"title\": \"Location\",\n            \"type\": \"array\",\n            \"items\": {\"anyOf\": [{\"type\": \"string\"}, {\"type\": \"integer\"}]},\n        },\n        \"msg\": {\"title\": \"Message\", \"type\": \"string\"},\n        \"type\": {\"title\": \"Error Type\", \"type\": \"string\"},\n    },\n    \"required\": [\"loc\", \"msg\", \"type\"],\n}\n\nvalidation_error_response_definition = {\n    \"title\": \"HTTPValidationError\",\n    \"type\": \"object\",\n    \"properties\": {\n        \"detail\": {\n            \"title\": \"Detail\",\n            \"type\": \"array\",\n            \"
14run_command
{
 "command": "sed -n '100,550p' fastapi/openapi/utils.py"
}
{"status": "ok", "stdout": " Tuple[ModelField, Literal[\"validation\", \"serialization\"]], JsonSchemaValue\n ],\n separate_input_output_schemas: bool = True,\n
full
{"status": "ok", "stdout": "        Tuple[ModelField, Literal[\"validation\", \"serialization\"]], JsonSchemaValue\n    ],\n    separate_input_output_schemas: bool = True,\n) -> List[Dict[str, Any]]:\n    parameters = []\n    flat_dependant = get_flat_dependant(dependant, skip_repeats=True)\n    path_params = _get_flat_fields_from_params(flat_dependant.path_params)\n    query_params = _get_flat_fields_from_params(flat_dependant.query_params)\n    header_params = _get_flat_fields_from_params(flat_dependant.header_params)\n    cookie_params = _get_flat_fields_from_params(flat_dependant.cookie_params)\n    parameter_groups = [\n        (ParamTypes.path, path_params),\n        (ParamTypes.query, query_params),\n        (ParamTypes.header, header_params),\n        (ParamTypes.cookie, cookie_params),\n    ]\n    default_convert_underscores = True\n    if len(flat_dependant.header_params) == 1:\n        first_field = flat_dependant.header_params[0]\n        if lenient_issubclass(first_field.type_, BaseModel):\n            default_convert_underscores = getattr(\n                first_field.field_info, \"convert_underscores\", True\n            )\n    for param_type, param_group in parameter_groups:\n        for param in param_group:\n            field_info = param.field_info\n            # field_info = cast(Param, field_info)\n            if not getattr(field_info, \"include_in_schema\", True):\n                continue\n            param_schema = get_schema_from_model_field(\n                field=param,\n                model_name_map=model_name_map,\n                field_mapping=field_mapping,\n                separate_input_output_schemas=separate_input_output_schemas,\n            )\n            name = param.alias\n            convert_underscores = getattr(\n                param.field_info,\n                \"convert_underscores\",\n                default_convert_underscores,\n            )\n            if (\n                param_type == ParamTypes.header\n        
15run_command
{
 "command": "grep -n \"get_schema_from_model_field\" fastapi/openapi/utils.py"
}
{"status": "ok", "stdout": "13: get_schema_from_model_field,\n129: param_schema = get_schema_from_model_field(\n180: body_schema = get_schema_from_model_field(\
full
{"status": "ok", "stdout": "13:    get_schema_from_model_field,\n129:            param_schema = get_schema_from_model_field(\n180:    body_schema = get_schema_from_model_field(\n352:                        response_schema = get_schema_from_model_field(\n385:                        additional_field_schema = get_schema_from_model_field(\n", "stderr": "", "exit_code": 0}
16run_command
{
 "command": "grep -rn \"def get_schema_from_model_field\" ."
}
{"status": "ok", "stdout": "./fastapi/_compat/v1.py:236:def get_schema_from_model_field(\n./fastapi/_compat/main.py:314:def get_schema_from_model_field(\n./fast
full
{"status": "ok", "stdout": "./fastapi/_compat/v1.py:236:def get_schema_from_model_field(\n./fastapi/_compat/main.py:314:def get_schema_from_model_field(\n./fastapi/_compat/v2.py:174:def get_schema_from_model_field(\n", "stderr": "", "exit_code": 0}
17run_command
{
 "command": "cat fastapi/_compat/v2.py"
}
{"status": "ok", "stdout": "import re\nimport warnings\nfrom copy import copy, deepcopy\nfrom dataclasses import dataclass\nfrom enum import Enum\nfrom typing i
full
{"status": "ok", "stdout": "import re\nimport warnings\nfrom copy import copy, deepcopy\nfrom dataclasses import dataclass\nfrom enum import Enum\nfrom typing import (\n    Any,\n    Dict,\n    List,\n    Sequence,\n    Set,\n    Tuple,\n    Type,\n    Union,\n    cast,\n)\n\nfrom fastapi._compat import may_v1, shared\nfrom fastapi.openapi.constants import REF_TEMPLATE\nfrom fastapi.types import IncEx, ModelNameMap\nfrom pydantic import BaseModel, TypeAdapter, create_model\nfrom pydantic import PydanticSchemaGenerationError as PydanticSchemaGenerationError\nfrom pydantic import PydanticUndefinedAnnotation as PydanticUndefinedAnnotation\nfrom pydantic import ValidationError as ValidationError\nfrom pydantic._internal._schema_generation_shared import (  # type: ignore[attr-defined]\n    GetJsonSchemaHandler as GetJsonSchemaHandler,\n)\nfrom pydantic._internal._typing_extra import eval_type_lenient\nfrom pydantic._internal._utils import lenient_issubclass as lenient_issubclass\nfrom pydantic.fields import FieldInfo as FieldInfo\nfrom pydantic.json_schema import GenerateJsonSchema as GenerateJsonSchema\nfrom pydantic.json_schema import JsonSchemaValue as JsonSchemaValue\nfrom pydantic_core import CoreSchema as CoreSchema\nfrom pydantic_core import PydanticUndefined, PydanticUndefinedType\nfrom pydantic_core import Url as Url\nfrom typing_extensions import Annotated, Literal, get_args, get_origin\n\ntry:\n    from pydantic_core.core_schema import (\n        with_info_plain_validator_function as with_info_plain_validator_function,\n    )\nexcept ImportError:  # pragma: no cover\n    from pydantic_core.core_schema import (\n        general_plain_validator_function as with_info_plain_validator_function,  # noqa: F401\n    )\n\nRequiredParam = PydanticUndefined\nUndefined = PydanticUndefined\nUndefinedType = PydanticUndefinedType\nevaluate_forwardref = eval_type_lenient\nValidator = Any\n\n\nclass BaseConfig:\n    pass\n\n\nclass ErrorWrapper(Exception):\n    pass\n\n\n@data
18run_command
{
 "command": "sed -n '170,250p' fastapi/_compat/v2.py"
}
{"status": "ok", "stdout": "def _get_model_config(model: BaseModel) -> Any:\n return model.model_config\n\n\ndef get_schema_from_model_field(\n *,\n field: Mode
full
{"status": "ok", "stdout": "def _get_model_config(model: BaseModel) -> Any:\n    return model.model_config\n\n\ndef get_schema_from_model_field(\n    *,\n    field: ModelField,\n    model_name_map: ModelNameMap,\n    field_mapping: Dict[\n        Tuple[ModelField, Literal[\"validation\", \"serialization\"]], JsonSchemaValue\n    ],\n    separate_input_output_schemas: bool = True,\n) -> Dict[str, Any]:\n    override_mode: Union[Literal[\"validation\"], None] = (\n        None if separate_input_output_schemas else \"validation\"\n    )\n    # This expects that GenerateJsonSchema was already used to generate the definitions\n    json_schema = field_mapping[(field, override_mode or field.mode)]\n    if \"$ref\" not in json_schema:\n        # TODO remove when deprecating Pydantic v1\n        # Ref: https://github.com/pydantic/pydantic/blob/d61792cc42c80b13b23e3ffa74bc37ec7c77f7d1/pydantic/schema.py#L207\n        json_schema[\"title\"] = field.field_info.title or field.alias.title().replace(\n            \"_\", \" \"\n        )\n    return json_schema\n\n\ndef get_definitions(\n    *,\n    fields: Sequence[ModelField],\n    model_name_map: ModelNameMap,\n    separate_input_output_schemas: bool = True,\n) -> Tuple[\n    Dict[Tuple[ModelField, Literal[\"validation\", \"serialization\"]], JsonSchemaValue],\n    Dict[str, Dict[str, Any]],\n]:\n    schema_generator = GenerateJsonSchema(ref_template=REF_TEMPLATE)\n    override_mode: Union[Literal[\"validation\"], None] = (\n        None if separate_input_output_schemas else \"validation\"\n    )\n    flat_models = get_flat_models_from_fields(fields, known_models=set())\n    flat_model_fields = [\n        ModelField(field_info=FieldInfo(annotation=model), name=model.__name__)\n        for model in flat_models\n    ]\n    input_types = {f.type_ for f in fields}\n    unique_flat_model_fields = {\n        f for f in flat_model_fields if f.type_ not in input_types\n    }\n\n    inputs = [\n        (field, override_mode or field.mode
19run_command
{
 "command": "sed -n '250,350p' fastapi/_compat/v2.py"
}
{"status": "ok", "stdout": " new_schema[\"$ref\"] = schema[\"$ref\"]\n continue\n if isinstance(value, dict):\n new_schema[key] = _replace_refs(\n schema=value,
full
{"status": "ok", "stdout": "                new_schema[\"$ref\"] = schema[\"$ref\"]\n            continue\n        if isinstance(value, dict):\n            new_schema[key] = _replace_refs(\n                schema=value,\n                old_name_to_new_name_map=old_name_to_new_name_map,\n            )\n        elif isinstance(value, list):\n            new_value = []\n            for item in value:\n                if isinstance(item, dict):\n                    new_item = _replace_refs(\n                        schema=item,\n                        old_name_to_new_name_map=old_name_to_new_name_map,\n                    )\n                    new_value.append(new_item)\n\n                else:\n                    new_value.append(item)\n            new_schema[key] = new_value\n    return new_schema\n\n\ndef _remap_definitions_and_field_mappings(\n    *,\n    model_name_map: ModelNameMap,\n    definitions: Dict[str, Any],\n    field_mapping: Dict[\n        Tuple[ModelField, Literal[\"validation\", \"serialization\"]], JsonSchemaValue\n    ],\n) -> Tuple[\n    Dict[Tuple[ModelField, Literal[\"validation\", \"serialization\"]], JsonSchemaValue],\n    Dict[str, Any],\n]:\n    old_name_to_new_name_map = {}\n    for field_key, schema in field_mapping.items():\n        model = field_key[0].type_\n        if model not in model_name_map:\n            continue\n        new_name = model_name_map[model]\n        old_name = schema[\"$ref\"].split(\"/\")[-1]\n        if old_name in {f\"{new_name}-Input\", f\"{new_name}-Output\"}:\n            continue\n        old_name_to_new_name_map[old_name] = new_name\n\n    new_field_mapping: Dict[\n        Tuple[ModelField, Literal[\"validation\", \"serialization\"]], JsonSchemaValue\n    ] = {}\n    for field_key, schema in field_mapping.items():\n        new_schema = _replace_refs(\n            schema=schema,\n            old_name_to_new_name_map=old_name_to_new_name_map,\n        )\n        new_field_mapping[field_key] = new_schema\n\n 
20run_command
{
 "command": "sed -n '200,230p' fastapi/_compat/v2.py"
}
{"status": "ok", "stdout": " model_name_map: ModelNameMap,\n separate_input_output_schemas: bool = True,\n) -> Tuple[\n Dict[Tuple[ModelField, Literal[\"validat
full
{"status": "ok", "stdout": "    model_name_map: ModelNameMap,\n    separate_input_output_schemas: bool = True,\n) -> Tuple[\n    Dict[Tuple[ModelField, Literal[\"validation\", \"serialization\"]], JsonSchemaValue],\n    Dict[str, Dict[str, Any]],\n]:\n    schema_generator = GenerateJsonSchema(ref_template=REF_TEMPLATE)\n    override_mode: Union[Literal[\"validation\"], None] = (\n        None if separate_input_output_schemas else \"validation\"\n    )\n    flat_models = get_flat_models_from_fields(fields, known_models=set())\n    flat_model_fields = [\n        ModelField(field_info=FieldInfo(annotation=model), name=model.__name__)\n        for model in flat_models\n    ]\n    input_types = {f.type_ for f in fields}\n    unique_flat_model_fields = {\n        f for f in flat_model_fields if f.type_ not in input_types\n    }\n\n    inputs = [\n        (field, override_mode or field.mode, field._type_adapter.core_schema)\n        for field in list(fields) + list(unique_flat_model_fields)\n    ]\n    field_mapping, definitions = schema_generator.generate_definitions(inputs=inputs)\n    for item_def in cast(Dict[str, Dict[str, Any]], definitions).values():\n        if \"description\" in item_def:\n            item_description = cast(str, item_def[\"description\"]).split(\"\\f\")[0]\n            item_def[\"description\"] = item_description\n    new_mapping, new_definitions = _remap_definitions_and_field_mappings(\n        model_name_map=model_name_map,\n", "stderr": "", "exit_code": 0}