LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coreutilsjson_schemadereference_refs
    Function●Since v0.1

    dereference_refs

    Resolve and inline JSON Schema $ref references in a schema object.

    This function processes a JSON Schema and resolves all $ref references by replacing them with the actual referenced content.

    Handles both simple references and complex cases like circular references and mixed $ref objects that contain additional properties alongside the $ref.

    Copy
    dereference_refs(
      schema_obj: dict,
      *,
      full_schema: dict | None = None,
      skip_keys: Sequence[str] | None = None
    ) -> dict
    • Circular references are handled gracefully by breaking cycles
    • Mixed $ref objects (with both $ref and other properties) are supported
    • Additional properties in mixed $refs override resolved properties
    • The $defs section is preserved in the output by default

    Parameters

    NameTypeDescription
    schema_obj*dict

    The JSON Schema object or fragment to process.

    This can be a complete schema or just a portion of one.

    full_schemadict | None
    Default:None

    The complete schema containing all definitions that $refs might point to.

    If not provided, defaults to schema_obj (useful when the schema is self-contained).

    skip_keysSequence[str] | None
    Default:None

    Controls recursion behavior and reference resolution depth.

    • If None (Default): Only recurse under '$defs' and use shallow reference resolution (break cycles but don't deep-inline nested refs)
    • If provided (even as []): Recurse under all keys and use deep reference resolution (fully inline all nested references)
    View source on GitHub