@@ -170,28 +170,33 @@ def dereference_refs(
170170full_schema :dict | None = None ,
171171skip_keys :Sequence [str ]| None = None ,
172172)-> dict :
173- """Resolve and inline JSON Schema $ref references in a schema object.
173+ """Resolve and inline JSON Schema` $ref` references in a schema object.
174174
175- This function processes a JSON Schema and resolves all $ref references by replacing
176- them with the actual referenced content. It handles both simple references and
177- complex cases like circular references and mixed $ref objects that contain
178- additional properties alongside the $ref.
175+ This function processes a JSON Schema and resolves all `$ref` references by
176+ replacing them with the actual referenced content.
177+
178+ Handles both simple references and complex cases like circular references and mixed
179+ `$ref` objects that contain additional properties alongside the `$ref`.
179180
180181 Args:
181- schema_obj: The JSON Schema object or fragment to process. This can be a
182- complete schema or just a portion of one.
183- full_schema: The complete schema containing all definitions that $refs might
184- point to. If not provided, defaults to schema_obj (useful when the
185- schema is self-contained).
186- skip_keys: Controls recursion behavior and reference resolution depth:
187- - If `None` (Default): Only recurse under '$defs' and use shallow reference
188- resolution (break cycles but don't deep-inline nested refs)
189- - If provided (even as []): Recurse under all keys and use deep reference
190- resolution (fully inline all nested references)
182+ schema_obj: The JSON Schema object or fragment to process.
183+
184+ This can be a complete schema or just a portion of one.
185+ full_schema: The complete schema containing all definitions that `$refs` might
186+ point to.
187+
188+ If not provided, defaults to `schema_obj` (useful when the schema is
189+ self-contained).
190+ skip_keys: Controls recursion behavior and reference resolution depth.
191+
192+ - If `None` (Default): Only recurse under `'$defs'` and use shallow
193+ reference resolution (break cycles but don't deep-inline nested refs)
194+ - If provided (even as `[]`): Recurse under all keys and use deep reference
195+ resolution (fully inline all nested references)
191196
192197 Returns:
193- A new dictionary with all $ref references resolved and inlined. The original
194- schema_obj is not modified.
198+ A new dictionary with all $ref references resolved and inlined.
199+ The original ` schema_obj` is not modified.
195200
196201 Examples:
197202 Basic reference resolution:
@@ -203,7 +208,8 @@ def dereference_refs(
203208 >>> result = dereference_refs(schema)
204209 >>> result["properties"]["name"] # {"type": "string"}
205210
206- Mixed $ref with additional properties:
211+ Mixed `$ref` with additional properties:
212+
207213 >>> schema = {
208214 ... "properties": {
209215 ... "name": {"$ref": "#/$defs/base", "description": "User name"}
@@ -215,6 +221,7 @@ def dereference_refs(
215221 # {"type": "string", "minLength": 1, "description": "User name"}
216222
217223 Handling circular references:
224+
218225 >>> schema = {
219226 ... "properties": {"user": {"$ref": "#/$defs/User"}},
220227 ... "$defs": {
@@ -227,10 +234,11 @@ def dereference_refs(
227234 >>> result = dereference_refs(schema) # Won't cause infinite recursion
228235
229236 !!! note
237+
230238 - Circular references are handled gracefully by breaking cycles
231- - Mixed $ref objects (with both $ref and other properties) are supported
232- - Additional properties in mixed $refs override resolved properties
233- - The $defs section is preserved in the output by default
239+ - Mixed` $ref` objects (with both` $ref` and other properties) are supported
240+ - Additional properties in mixed` $refs` override resolved properties
241+ - The` $defs` section is preserved in the output by default
234242 """
235243full = full_schema or schema_obj
236244keys_to_skip = list (skip_keys )if skip_keys is not None else ["$defs" ]