test_dereference_refs_list_index() — langchain Function Reference
Architecture documentation for the test_dereference_refs_list_index() function in test_json_schema.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD cb637ecf_b594_c32d_923f_ebe411d202b0["test_dereference_refs_list_index()"] 5d9c8eae_7a4a_0ffa_fa7c_a89825bcf1fa["test_json_schema.py"] cb637ecf_b594_c32d_923f_ebe411d202b0 -->|defined in| 5d9c8eae_7a4a_0ffa_fa7c_a89825bcf1fa style cb637ecf_b594_c32d_923f_ebe411d202b0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/utils/test_json_schema.py lines 275–452
def test_dereference_refs_list_index() -> None:
"""Test dereferencing refs that use list indices (e.g., anyOf/1)."""
# Test case from the issue report - anyOf array with numeric index reference
schema = {
"type": "object",
"properties": {
"payload": {
"anyOf": [
{ # variant 0
"type": "object",
"properties": {"kind": {"type": "string", "const": "ONE"}},
},
{ # variant 1
"type": "object",
"properties": {
"kind": {"type": "string", "const": "TWO"},
"startDate": {
"type": "string",
"pattern": r"^\d{4}-\d{2}-\d{2}$",
},
"endDate": {
"$ref": (
"#/properties/payload/anyOf/1/properties/startDate"
)
},
},
},
]
}
},
}
expected = {
"type": "object",
"properties": {
"payload": {
"anyOf": [
{ # variant 0
"type": "object",
"properties": {"kind": {"type": "string", "const": "ONE"}},
},
{ # variant 1
"type": "object",
"properties": {
"kind": {"type": "string", "const": "TWO"},
"startDate": {
"type": "string",
"pattern": r"^\d{4}-\d{2}-\d{2}$",
},
"endDate": {
"type": "string",
"pattern": r"^\d{4}-\d{2}-\d{2}$",
},
},
},
]
}
},
}
actual = dereference_refs(schema)
assert actual == expected
# Test oneOf array with numeric index reference
schema_oneof = {
"type": "object",
"properties": {
"data": {
"oneOf": [
{"type": "string"},
{"type": "number"},
{
"type": "object",
"properties": {"value": {"$ref": "#/properties/data/oneOf/1"}},
},
]
}
},
}
expected_oneof = {
Domain
Subdomains
Source
Frequently Asked Questions
What does test_dereference_refs_list_index() do?
test_dereference_refs_list_index() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/utils/test_json_schema.py.
Where is test_dereference_refs_list_index() defined?
test_dereference_refs_list_index() is defined in libs/core/tests/unit_tests/utils/test_json_schema.py at line 275.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free