failed CONTEXT NO_PATCH LOOP UNSUBMITTED agent_error ยท 31 tool calls ยท 152 s ยท fastapi/fastapi
๐ 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 | Arguments | Result |
|---|---|---|---|
| 1 | run_command | {
"command": "grep -rn \"separation of schemas\" ."
} | {"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "", "stderr": "", "exit_code": 1}}full{"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "", "stderr": "", "exit_code": 1}} |
| 2 | run_command | {
"command": "grep -rn \"separate_openapi_schemas\" ."
} | {"status": "ok", "stdout": "./scripts/playwright/separate_openapi_schemas/image03.py:27: [\"uvicorn\", \"docs_src.separate_openapi_schemas.tutorial001:app\"]\n.full{"status": "ok", "stdout": "./scripts/playwright/separate_openapi_schemas/image03.py:27: [\"uvicorn\", \"docs_src.separate_openapi_schemas.tutorial001:app\"]\n./scripts/playwright/separate_openapi_schemas/image04.py:26: [\"uvicorn\", \"docs_src.separate_openapi_schemas.tutorial001:app\"]\n./scripts/playwright/separate_openapi_schemas/image01.py:26: [\"uvicorn\", \"docs_src.separate_openapi_schemas.tutorial001:app\"]\n./scripts/playwright/separate_openapi_schemas/image05.py:26: [\"uvicorn\", \"docs_src.separate_openapi_schemas.tutorial002:app\"]\n./scripts/playwright/separate_openapi_schemas/image02.py:27: [\"uvicorn\", \"docs_src.separate_openapi_schemas.tutorial001:app\"]\n./tests/test_tutorial/test_separate_openapi_schemas/test_tutorial002.py:18: mod = importlib.import_module(f\"docs_src.separate_openapi_schemas.{request.param}\")\n./tests/test_tutorial/test_separate_openapi_schemas/test_tutorial001.py:18: mod = importlib.import_module(f\"docs_src.separate_openapi_schemas.{request.param}\")\n./docs/es/docs/how-to/separate-openapi-schemas.md:13:{* ../../docs_src/separate_openapi_schemas/tutorial001_py310.py ln[1:7] hl[7] *}\n./docs/es/docs/how-to/separate-openapi-schemas.md:19:{* ../../docs_src/separate_openapi_schemas/tutorial001_py310.py ln[1:15] hl[14] *}\n./docs/es/docs/how-to/separate-openapi-schemas.md:35:{* ../../docs_src/separate_openapi_schemas/tutorial001_py310.py hl[19] *}\n./docs/es/docs/how-to/separate-openapi-schemas.md:94:{* ../../docs_src/separate_openapi_schemas/tutorial002_py310.py hl[10] *}\n./docs/es/docs/how-to/separate-openapi-schemas.md:101:<img src=\"/img/tutorial/separate_openapi_schemas/image05.png\">\n./docs/de/docs/how-to/separate-openapi-schemas.md:13:{* ../../docs_src/separate_openapi_schemas/tutorial001_py310.py ln[1:7] hl[7] *}\n./docs/de/docs/how-to/separate-openapi-schemas.md:19:{* ../../docs_src/separate_openapi_schemas/tutorial001_py310.py ln[1:15] hl[14] *}\n./docs/de/docs/how-to/separate-openapi-schemas.md: |
| 3 | run_command | {
"command": "grep -rn \"separate_openapi_schemas\" fastapi/openapi/"
} | {"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "", "stderr": "", "exit_code": 1}}full{"status": "error", "error_type": "CommandError", "error_message": "Command failed with exit code 1", "details": {"stdout": "", "stderr": "", "exit_code": 1}} |
| 4 | run_command | {
"command": "grep -rn \"openapi\" fastapi/openapi/ | head -20"
} | {"status": "ok", "stdout": "fastapi/openapi/models.py:436: openapi: str\nfastapi/openapi/docs.py:29: openapi_url: Annotated[\nfastapi/openapi/docs.py:36: `/openfull{"status": "ok", "stdout": "fastapi/openapi/models.py:436: openapi: str\nfastapi/openapi/docs.py:29: openapi_url: Annotated[\nfastapi/openapi/docs.py:36: `/openapi.json`.\nfastapi/openapi/docs.py:98: It defaults to [swagger_ui_default_parameters][fastapi.openapi.docs.swagger_ui_default_parameters].\nfastapi/openapi/docs.py:133: url: '{openapi_url}',\nfastapi/openapi/docs.py:164: openapi_url: Annotated[\nfastapi/openapi/docs.py:171: `/openapi.json`.\nfastapi/openapi/docs.py:249: <redoc spec-url=\"{openapi_url}\"></redoc>\nfastapi/openapi/utils.py:24:from fastapi.openapi.constants import METHODS_WITH_BODY, REF_PREFIX\nfastapi/openapi/utils.py:25:from fastapi.openapi.models import OpenAPI\nfastapi/openapi/utils.py:78:def get_openapi_security_definitions(\nfastapi/openapi/utils.py:95:def _get_openapi_operation_parameters(\nfastapi/openapi/utils.py:156: openapi_examples = getattr(field_info, \"openapi_examples\", None)\nfastapi/openapi/utils.py:158: if openapi_examples:\nfastapi/openapi/utils.py:159: parameter[\"examples\"] = jsonable_encoder(openapi_examples)\nfastapi/openapi/utils.py:168:def get_openapi_operation_request_body(\nfastapi/openapi/utils.py:193: if field_info.openapi_examples:\nfastapi/openapi/utils.py:195: field_info.openapi_examples\nfastapi/openapi/utils.py:207: \"fastapi.openapi.utils.generate_operation_id() was deprecated, \"\nfastapi/openapi/utils.py:224:def get_openapi_operation_metadata(\n", "exit_code": 0} |
| 5 | run_command | {
"command": "grep -rn \"get_openapi\" fastapi/openapi/utils.py"
} | {"status": "ok", "stdout": "78:def get_openapi_security_definitions(\n95:def _get_openapi_operation_parameters(\n168:def get_openapi_operation_request_body(\n22full{"status": "ok", "stdout": "78:def get_openapi_security_definitions(\n95:def _get_openapi_operation_parameters(\n168:def get_openapi_operation_request_body(\n224:def get_openapi_operation_metadata(\n250:def get_openapi_path(\n272: operation = get_openapi_operation_metadata(\n277: security_definitions, operation_security = get_openapi_security_definitions(\n284: operation_parameters = _get_openapi_operation_parameters(\n305: request_body_oai = get_openapi_operation_request_body(\n321: ) = get_openapi_path(\n467:def get_openapi(\n511: result = get_openapi_path(\n530: result = get_openapi_path(\n", "exit_code": 0} |
| 6 | read_file | {
"filepath": "fastapi/openapi/utils.py",
"start_line": 467,
"end_line": 550
} | {"status": "ok", "filepath": "fastapi/openapi/utils.py", "content": "def get_openapi(\n *,\n title: str,\n version: str,\n openapi_version: str = \"3.1.0\",\n sfull{"status": "ok", "filepath": "fastapi/openapi/utils.py", "content": "def get_openapi(\n *,\n title: str,\n version: str,\n openapi_version: str = \"3.1.0\",\n summary: Optional[str] = None,\n description: Optional[str] = None,\n routes: Sequence[BaseRoute],\n webhooks: Optional[Sequence[BaseRoute]] = None,\n tags: Optional[List[Dict[str, Any]]] = None,\n servers: Optional[List[Dict[str, Union[str, Any]]]] = None,\n terms_of_service: Optional[str] = None,\n contact: Optional[Dict[str, Union[str, Any]]] = None,\n license_info: Optional[Dict[str, Union[str, Any]]] = None,\n separate_input_output_schemas: bool = True,\n external_docs: Optional[Dict[str, Any]] = None,\n) -> Dict[str, Any]:\n info: Dict[str, Any] = {\"title\": title, \"version\": version}\n if summary:\n info[\"summary\"] = summary\n if description:\n info[\"description\"] = description\n if terms_of_service:\n info[\"termsOfService\"] = terms_of_service\n if contact:\n info[\"contact\"] = contact\n if license_info:\n info[\"license\"] = license_info\n output: Dict[str, Any] = {\"openapi\": openapi_version, \"info\": info}\n if servers:\n output[\"servers\"] = servers\n components: Dict[str, Dict[str, Any]] = {}\n paths: Dict[str, Dict[str, Any]] = {}\n webhook_paths: Dict[str, Dict[str, Any]] = {}\n operation_ids: Set[str] = set()\n all_fields = get_fields_from_routes(list(routes or []) + list(webhooks or []))\n model_name_map = get_compat_model_name_map(all_fields)\n field_mapping, definitions = get_definitions(\n fields=all_fields,\n model_name_map=model_name_map,\n separate_input_output_schemas=separate_input_output_schemas,\n )\n for route in routes or []:\n if isinstance(route, routing.APIRoute):\n result = get_openapi_path(\n route=route,\n operation_ids=operation_ids,\n model_nam |
| 7 | run_command | {
"command": "grep -rn \"get_definitions\" fastapi/openapi/utils.py"
} | {"status": "ok", "stdout": "12: get_definitions,\n504: field_mapping, definitions = get_definitions(\n", "exit_code": 0}full{"status": "ok", "stdout": "12: get_definitions,\n504: field_mapping, definitions = get_definitions(\n", "exit_code": 0} |
| 8 | read_file | {
"end_line": 460,
"filepath": "fastapi/openapi/utils.py",
"start_line": 1
} | {"status": "ok", "filepath": "fastapi/openapi/utils.py", "content": "import http.client\nimport inspect\nimport warnings\nfrom typing import Any, Dict, List, Opfull{"status": "ok", "filepath": "fastapi/openapi/utils.py", "content": "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 |
| 9 | run_command | {
"command": "grep -rn \"def get_definitions\" fastapi/_compat/"
} | {"status": "ok", "stdout": "fastapi/_compat/may_v1.py:61: def get_definitions(\nfastapi/_compat/v1.py:255:def get_definitions(\nfastapi/_compat/main.py:267:def full{"status": "ok", "stdout": "fastapi/_compat/may_v1.py:61: def get_definitions(\nfastapi/_compat/v1.py:255:def get_definitions(\nfastapi/_compat/main.py:267:def get_definitions(\nfastapi/_compat/v2.py:197:def get_definitions(\n", "exit_code": 0} |
| 10 | read_file | {
"end_line": 350,
"filepath": "fastapi/_compat/main.py",
"start_line": 260
} | {"status": "ok", "filepath": "fastapi/_compat/main.py", "content": " return model_name_map\n from fastapi._compat import v1\n\n model_name_map = v1.get_model_nafull{"status": "ok", "filepath": "fastapi/_compat/main.py", "content": " return model_name_map\n from fastapi._compat import v1\n\n model_name_map = v1.get_model_name_map(all_flat_models)\n return model_name_map\n\n\ndef get_definitions(\n *,\n fields: List[ModelField],\n model_name_map: ModelNameMap,\n separate_input_output_schemas: bool = True,\n) -> Tuple[\n Dict[\n Tuple[ModelField, Literal[\"validation\", \"serialization\"]],\n may_v1.JsonSchemaValue,\n ],\n Dict[str, Dict[str, Any]],\n]:\n if sys.version_info < (3, 14):\n v1_fields = [field for field in fields if isinstance(field, may_v1.ModelField)]\n v1_field_maps, v1_definitions = may_v1.get_definitions(\n fields=v1_fields,\n model_name_map=model_name_map,\n separate_input_output_schemas=separate_input_output_schemas,\n )\n if not PYDANTIC_V2:\n return v1_field_maps, v1_definitions\n else:\n from . import v2\n\n v2_fields = [field for field in fields if isinstance(field, v2.ModelField)]\n v2_field_maps, v2_definitions = v2.get_definitions(\n fields=v2_fields,\n model_name_map=model_name_map,\n separate_input_output_schemas=separate_input_output_schemas,\n )\n all_definitions = {**v1_definitions, **v2_definitions}\n all_field_maps = {**v1_field_maps, **v2_field_maps}\n return all_field_maps, all_definitions\n\n # Pydantic v1 is not supported since Python 3.14\n else:\n from . import v2\n\n v2_fields = [field for field in fields if isinstance(field, v2.ModelField)]\n v2_field_maps, v2_definitions = v2.get_definitions(\n fields=v2_fields,\n model_name_map=model_name_map,\n separate_input_output_schemas=separate_input_output_schemas,\n )\n return v2_field_maps, v2_definitions\n\n\ndef get_sch |
| 11 | read_file | {
"end_line": 300,
"filepath": "fastapi/_compat/v2.py",
"start_line": 190
} | {"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": " # Ref: https://github.com/pydantic/pydantic/blob/d61792cc42c80b13b23e3ffa74bc37ec7c77f7d1/pydfull{"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": " # 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, 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 definitions=definitions, # type: ignore[arg-type]\n field_mapping=field_mapping,\n )\n return new_mapping, new_definitions\n\n\ |
| 12 | read_file | {
"end_line": 350,
"filepath": "fastapi/_compat/v2.py",
"start_line": 301
} | {"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": " old_name_to_new_name_map=old_name_to_new_name_map,\n )\n new_field_mapping[field_key] = new_sfull{"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": " old_name_to_new_name_map=old_name_to_new_name_map,\n )\n new_field_mapping[field_key] = new_schema\n\n new_definitions = {}\n for key, value in definitions.items():\n if key in old_name_to_new_name_map:\n new_key = old_name_to_new_name_map[key]\n else:\n new_key = key\n new_value = _replace_refs(\n schema=value,\n old_name_to_new_name_map=old_name_to_new_name_map,\n )\n new_definitions[new_key] = new_value\n return new_field_mapping, new_definitions\n\n\ndef is_scalar_field(field: ModelField) -> bool:\n from fastapi import params\n\n return shared.field_annotation_is_scalar(\n field.field_info.annotation\n ) and not isinstance(field.field_info, params.Body)\n\n\ndef is_sequence_field(field: ModelField) -> bool:\n return shared.field_annotation_is_sequence(field.field_info.annotation)\n\n\ndef is_scalar_sequence_field(field: ModelField) -> bool:\n return shared.field_annotation_is_scalar_sequence(field.field_info.annotation)\n\n\ndef is_bytes_field(field: ModelField) -> bool:\n return shared.is_bytes_or_nonable_bytes_annotation(field.type_)\n\n\ndef is_bytes_sequence_field(field: ModelField) -> bool:\n return shared.is_bytes_sequence_annotation(field.type_)\n\n\ndef copy_field_info(*, field_info: FieldInfo, annotation: Any) -> FieldInfo:\n cls = type(field_info)\n merged_field_info = cls.from_annotation(annotation)\n new_field_info = copy(field_info)\n new_field_info.metadata = merged_field_info.metadata\n new_field_info.annotation = merged_field_info.annotation\n return new_field_info\n\n", "start_line": 301, "end_line": 350, "total_lines": 459, "is_truncated": false} |
| 13 | run_command | {
"command": "grep -rn \"GenerateJsonSchema\" fastapi/_compat/v2.py"
} | {"status": "ok", "stdout": "31:from pydantic.json_schema import GenerateJsonSchema as GenerateJsonSchema\n186: # This expects that GenerateJsonSchema was alreadfull{"status": "ok", "stdout": "31:from pydantic.json_schema import GenerateJsonSchema as GenerateJsonSchema\n186: # This expects that GenerateJsonSchema was already used to generate the definitions\n206: schema_generator = GenerateJsonSchema(ref_template=REF_TEMPLATE)\n", "exit_code": 0} |
| 14 | run_command | {
"command": "grep -rn \"separate_input_output_schemas\" fastapi/_compat/v2.py"
} | {"status": "ok", "stdout": "181: separate_input_output_schemas: bool = True,\n184: None if separate_input_output_schemas else \"validation\"\n201: separate_inpufull{"status": "ok", "stdout": "181: separate_input_output_schemas: bool = True,\n184: None if separate_input_output_schemas else \"validation\"\n201: separate_input_output_schemas: bool = True,\n208: None if separate_input_output_schemas else \"validation\"\n", "exit_code": 0} |
| 15 | read_file | {
"end_line": 210,
"filepath": "fastapi/_compat/v2.py",
"start_line": 180
} | {"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": " ],\n separate_input_output_schemas: bool = True,\n) -> Dict[str, Any]:\n override_mode: Unionfull{"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": " ],\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", "start_line": 180, "end_line": 210, "total_lines": 459, "is_truncated": false} |
| 16 | run_command | {
"command": "grep -rn \"get_schema_from_model_field\" fastapi/_compat/v2.py"
} | {"status": "ok", "stdout": "174:def get_schema_from_model_field(\n", "exit_code": 0}full{"status": "ok", "stdout": "174:def get_schema_from_model_field(\n", "exit_code": 0} |
| 17 | read_file | {
"end_line": 180,
"filepath": "fastapi/_compat/v2.py",
"start_line": 174
} | {"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": "def get_schema_from_model_field(\n *,\n field: ModelField,\n model_name_map: ModelNameMap,\n ffull{"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": "def 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", "start_line": 174, "end_line": 180, "total_lines": 459, "is_truncated": false} |
| 18 | run_command | {
"command": "grep -rn \"get_flat_models_from_fields\" fastapi/_compat/v2.py"
} | {"status": "ok", "stdout": "210: flat_models = get_flat_models_from_fields(fields, known_models=set())\n415: get_flat_models_from_fields(fields, known_models=knfull{"status": "ok", "stdout": "210: flat_models = get_flat_models_from_fields(fields, known_models=set())\n415: get_flat_models_from_fields(fields, known_models=known_models)\n450:def get_flat_models_from_fields(\n", "exit_code": 0} |
| 19 | read_file | {
"end_line": 459,
"filepath": "fastapi/_compat/v2.py",
"start_line": 450
} | {"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": "def get_flat_models_from_fields(\n fields: Sequence[ModelField], known_models: TypeModelSet\n)full{"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": "def get_flat_models_from_fields(\n fields: Sequence[ModelField], known_models: TypeModelSet\n) -> TypeModelSet:\n for field in fields:\n get_flat_models_from_field(field, known_models=known_models)\n return known_models\n\n\ndef get_long_model_name(model: TypeModelOrEnum) -> str:\n return f\"{model.__module__}__{model.__qualname__}\".replace(\".\", \"__\")\n", "start_line": 450, "end_line": 459, "total_lines": 459, "is_truncated": false} |
| 20 | run_command | {
"command": "grep -rn \"get_flat_models_from_field\" fastapi/_compat/v2.py"
} | {"status": "ok", "stdout": "210: flat_models = get_flat_models_from_fields(fields, known_models=set())\n415: get_flat_models_from_fields(fields, known_models=knfull{"status": "ok", "stdout": "210: flat_models = get_flat_models_from_fields(fields, known_models=set())\n415: get_flat_models_from_fields(fields, known_models=known_models)\n434:def get_flat_models_from_field(\n450:def get_flat_models_from_fields(\n454: get_flat_models_from_field(field, known_models=known_models)\n", "exit_code": 0} |
| 21 | read_file | {
"end_line": 449,
"filepath": "fastapi/_compat/v2.py",
"start_line": 434
} | {"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": "def get_flat_models_from_field(\n field: ModelField, known_models: TypeModelSet\n) -> TypeModefull{"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": "def get_flat_models_from_field(\n field: ModelField, known_models: TypeModelSet\n) -> TypeModelSet:\n field_type = field.type_\n if lenient_issubclass(field_type, BaseModel):\n if field_type in known_models:\n return known_models\n known_models.add(field_type)\n get_flat_models_from_model(field_type, known_models=known_models)\n elif lenient_issubclass(field_type, Enum):\n known_models.add(field_type)\n else:\n get_flat_models_from_annotation(field_type, known_models=known_models)\n return known_models\n\n\n", "start_line": 434, "end_line": 449, "total_lines": 459, "is_truncated": false} |
| 22 | run_command | {
"command": "grep -rn \"get_flat_models_from_model\" fastapi/_compat/v2.py"
} | {"status": "ok", "stdout": "410:def get_flat_models_from_model(\n428: get_flat_models_from_model(arg, known_models=known_models)\n442: get_flat_models_from_modefull{"status": "ok", "stdout": "410:def get_flat_models_from_model(\n428: get_flat_models_from_model(arg, known_models=known_models)\n442: get_flat_models_from_model(field_type, known_models=known_models)\n", "exit_code": 0} |
| 23 | read_file | {
"end_line": 429,
"filepath": "fastapi/_compat/v2.py",
"start_line": 410
} | {"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": "def get_flat_models_from_model(\n model: Type[\"BaseModel\"], known_models: Union[TypeModelSetfull{"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": "def get_flat_models_from_model(\n model: Type[\"BaseModel\"], known_models: Union[TypeModelSet, None] = None\n) -> TypeModelSet:\n known_models = known_models or set()\n fields = get_model_fields(model)\n get_flat_models_from_fields(fields, known_models=known_models)\n return known_models\n\n\ndef get_flat_models_from_annotation(\n annotation: Any, known_models: TypeModelSet\n) -> TypeModelSet:\n origin = get_origin(annotation)\n if origin is not None:\n for arg in get_args(annotation):\n if lenient_issubclass(arg, (BaseModel, Enum)) and arg not in known_models:\n known_models.add(arg)\n if lenient_issubclass(arg, BaseModel):\n get_flat_models_from_model(arg, known_models=known_models)\n else:\n", "start_line": 410, "end_line": 429, "total_lines": 459, "is_truncated": false} |
| 24 | run_command | {
"command": "grep -rn \"get_model_fields\" fastapi/_compat/v2.py"
} | {"status": "ok", "stdout": "374:def get_model_fields(model: Type[BaseModel]) -> List[ModelField]:\n414: fields = get_model_fields(model)\n", "exit_code": 0}full{"status": "ok", "stdout": "374:def get_model_fields(model: Type[BaseModel]) -> List[ModelField]:\n414: fields = get_model_fields(model)\n", "exit_code": 0} |
| 25 | read_file | {
"end_line": 385,
"filepath": "fastapi/_compat/v2.py",
"start_line": 374
} | {"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": "def get_model_fields(model: Type[BaseModel]) -> List[ModelField]:\n return [\n ModelField(fielfull{"status": "ok", "filepath": "fastapi/_compat/v2.py", "content": "def get_model_fields(model: Type[BaseModel]) -> List[ModelField]:\n return [\n ModelField(field_info=field_info, name=name)\n for name, field_info in model.model_fields.items()\n ]\n\n\n# Duplicate of several schema functions from Pydantic v1 to make them compatible with\n# Pydantic v2 and allow mixing the models\n\nTypeModelOrEnum = Union[Type[\"BaseModel\"], Type[Enum]]\nTypeModelSet = Set[TypeModelOrEnum]\n", "start_line": 374, "end_line": 385, "total_lines": 459, "is_truncated": false} |
| 26 | run_command | {
"command": "cat <<EOF > /tmp/repro.py\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\nfrom fastapi.openapi.utils import get_openapi\n\napp = FastAPI()\n\nclass Item(BaseModel):\n name: str\n description: str\n\nclass ItemIn(BaseModel):\n name: str\n description: str\n\nclass ItemOut(BaseModel):\n name: str\n description: str\n id: int\n\nclass User(BaseModel):\n id: int\n username: str\n item: Item\n\n@app.post(\"/items/\", response_model=ItemOut)\ndef create_item(item: ItemIn):\n return ItemOut(id=1, **item.model_dump())\n\n@app.get(\"/users/\", response_model=User)\ndef get_user():\n return User(id=1, username=\"test\", item=Item(name=\"n\", description=\"d\"))\n\nopenapi_schema = get_openapi(\n title=\"Test\",\n version=\"1.0.0\",\n routes=app.routes,\n separate_input_output_schemas=True\n)\n\nimport json\nprint(json.dumps(openapi_schema, indent=2))\nEOF\npython3 /tmp/repro.py\n"
} | {"status": "ok", "stdout": "{\n \"openapi\": \"3.1.0\",\n \"info\": {\n \"title\": \"Test\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {\n \"/items/\": {\n \"pfull{"status": "ok", "stdout": "{\n \"openapi\": \"3.1.0\",\n \"info\": {\n \"title\": \"Test\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {\n \"/items/\": {\n \"post\": {\n \"summary\": \"Create Item\",\n \"operationId\": \"create_item_items__post\",\n \"requestBody\": {\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/ItemIn\"\n }\n }\n },\n \"required\": true\n },\n \"responses\": {\n \"200\": {\n \"description\": \"Successful Response\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/ItemOut\"\n }\n }\n }\n },\n \"422\": {\n \"description\": \"Validation Error\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/HTTPValidationError\"\n }\n }\n }\n }\n }\n }\n },\n \"/users/\": {\n \"get\": {\n \"summary\": \"Get User\",\n \"operationId\": \"get_user_users__get\",\n \"responses\": {\n \"200\": {\n \"description\": \"Successful Response\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/User\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"components\": {\n \"schemas\": {\n \"HTTPValidationError\": {\n \"properties\": {\n \"detail\": {\n \"items\": {\n \"$ref\": \"#/components/schemas/ValidationError\"\n },\n \"type\": \"array\",\n \"title\": \"Detail\"\ |
| 27 | run_command | {
"command": "cat <<EOF > /tmp/repro.py\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\nfrom fastapi.openapi.utils import get_openapi\n\napp = FastAPI()\n\nclass Item(BaseModel):\n name: str\n description: str\n\nclass ItemIn(BaseModel):\n name: str\n description: str\n\nclass ItemOut(BaseModel):\n name: str\n description: str\n id: int\n\nclass UserIn(BaseModel):\n id: int\n username: str\n item: ItemIn\n\nclass UserOut(BaseModel):\n id: int\n username: str\n item: ItemOut\n\n@app.post(\"/users/\", response_model=UserOut)\ndef create_user(user: UserIn):\n return UserOut(id=1, username=\"test\", item=ItemOut(id=1, name=\"n\", description=\"d\"))\n\nopenapi_schema = get_openapi(\n title=\"Test\",\n version=\"1.0.0\",\n routes=app.routes,\n separate_input_output_schemas=True\n)\n\nimport json\nprint(json.dumps(openapi_schema, indent=2))\nEOF\npython3 /tmp/repro.py\n"
} | {"status": "ok", "stdout": "{\n \"openapi\": \"3.1.0\",\n \"info\": {\n \"title\": \"Test\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {\n \"/users/\": {\n \"pfull{"status": "ok", "stdout": "{\n \"openapi\": \"3.1.0\",\n \"info\": {\n \"title\": \"Test\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {\n \"/users/\": {\n \"post\": {\n \"summary\": \"Create User\",\n \"operationId\": \"create_user_users__post\",\n \"requestBody\": {\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/UserIn\"\n }\n }\n },\n \"required\": true\n },\n \"responses\": {\n \"200\": {\n \"description\": \"Successful Response\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/UserOut\"\n }\n }\n }\n },\n \"422\": {\n \"description\": \"Validation Error\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/HTTPValidationError\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"components\": {\n \"schemas\": {\n \"HTTPValidationError\": {\n \"properties\": {\n \"detail\": {\n \"items\": {\n \"$ref\": \"#/components/schemas/ValidationError\"\n },\n \"type\": \"array\",\n \"title\": \"Detail\"\n }\n },\n \"type\": \"object\",\n \"title\": \"HTTPValidationError\"\n },\n \"ItemIn\": {\n \"properties\": {\n \"name\": {\n \"type\": \"string\",\n \"title\": \"Name\"\n },\n \"description\": {\n \"type\": \"string\",\n \"title\": \"Description\"\n }\n },\n \"type\": \"object\",\n \"required\": [\n \"name\",\n |
| 28 | run_command | {
"command": "cat <<EOF > /tmp/repro.py\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\nfrom fastapi.openapi.utils import get_openapi\n\napp = FastAPI()\n\nclass Item(BaseModel):\n name: str\n description: str\n\nclass ItemIn(BaseModel):\n name: str\n description: str\n\nclass ItemOut(BaseModel):\n name: str\n description: str\n id: int\n\nclass UserIn(BaseModel):\n id: int\n username: str\n item: Item\n\nclass UserOut(BaseModel):\n id: int\n username: str\n item: Item\n\n@app.post(\"/users/\", response_model=UserOut)\ndef create_user(user: UserIn):\n return UserOut(id=1, username=\"test\", item=Item(id=1, name=\"n\", description=\"d\"))\n\nopenapi_schema = get_openapi(\n title=\"Test\",\n version=\"1.0.0\",\n routes=app.routes,\n separate_input_output_schemas=True\n)\n\nimport json\nprint(json.dumps(openapi_schema, indent=2))\nEOF\npython3 /tmp/repro.py\n"
} | {"status": "ok", "stdout": "{\n \"openapi\": \"3.1.0\",\n \"info\": {\n \"title\": \"Test\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {\n \"/users/\": {\n \"pfull{"status": "ok", "stdout": "{\n \"openapi\": \"3.1.0\",\n \"info\": {\n \"title\": \"Test\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {\n \"/users/\": {\n \"post\": {\n \"summary\": \"Create User\",\n \"operationId\": \"create_user_users__post\",\n \"requestBody\": {\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/UserIn\"\n }\n }\n },\n \"required\": true\n },\n \"responses\": {\n \"200\": {\n \"description\": \"Successful Response\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/UserOut\"\n }\n }\n }\n },\n \"422\": {\n \"description\": \"Validation Error\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/HTTPValidationError\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"components\": {\n \"schemas\": {\n \"HTTPValidationError\": {\n \"properties\": {\n \"detail\": {\n \"items\": {\n \"$ref\": \"#/components/schemas/ValidationError\"\n },\n \"type\": \"array\",\n \"title\": \"Detail\"\n }\n },\n \"type\": \"object\",\n \"title\": \"HTTPValidationError\"\n },\n \"Item\": {\n \"properties\": {\n \"name\": {\n \"type\": \"string\",\n \"title\": \"Name\"\n },\n \"description\": {\n \"type\": \"string\",\n \"title\": \"Description\"\n }\n },\n \"type\": \"object\",\n \"required\": [\n \"name\",\n |
| 29-31 ร3 | run_command | {
"command": "cat <<EOF > /tmp/repro.py\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\nfrom fastapi.openapi.utils import get_openapi\n\napp = FastAPI()\n\nclass Item(BaseModel):\n name: str\n description: str\n\nclass UserIn(BaseModel):\n id: int\n username: str\n item: Item\n\nclass UserOut(BaseModel):\n id: int\n username: str\n item: Item\n\n@app.post(\"/users/\", response_model=UserOut)\ndef create_user(user: UserIn):\n return UserOut(id=1, username=\"test\", item=Item(name=\"n\", description=\"d\"))\n\nopenapi_schema = get_openapi(\n title=\"Test\",\n version=\"1.0.0\",\n routes=app.routes,\n separate_input_output_schemas=True\n)\n\nimport json\nprint(json.dumps(openapi_schema, indent=2))\nEOF\npython3 /tmp/repro.py\n"
} | {"status": "ok", "stdout": "{\n \"openapi\": \"3.1.0\",\n \"info\": {\n \"title\": \"Test\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {\n \"/users/\": {\n \"pfull{"status": "ok", "stdout": "{\n \"openapi\": \"3.1.0\",\n \"info\": {\n \"title\": \"Test\",\n \"version\": \"1.0.0\"\n },\n \"paths\": {\n \"/users/\": {\n \"post\": {\n \"summary\": \"Create User\",\n \"operationId\": \"create_user_users__post\",\n \"requestBody\": {\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/UserIn\"\n }\n }\n },\n \"required\": true\n },\n \"responses\": {\n \"200\": {\n \"description\": \"Successful Response\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/UserOut\"\n }\n }\n }\n },\n \"422\": {\n \"description\": \"Validation Error\",\n \"content\": {\n \"application/json\": {\n \"schema\": {\n \"$ref\": \"#/components/schemas/HTTPValidationError\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"components\": {\n \"schemas\": {\n \"HTTPValidationError\": {\n \"properties\": {\n \"detail\": {\n \"items\": {\n \"$ref\": \"#/components/schemas/ValidationError\"\n },\n \"type\": \"array\",\n \"title\": \"Detail\"\n }\n },\n \"type\": \"object\",\n \"title\": \"HTTPValidationError\"\n },\n \"Item\": {\n \"properties\": {\n \"name\": {\n \"type\": \"string\",\n \"title\": \"Name\"\n },\n \"description\": {\n \"type\": \"string\",\n \"title\": \"Description\"\n }\n },\n \"type\": \"object\",\n \"required\": [\n \"name\",\n |