Repository: Fatal1ty/mashumaro

Issue:
When using "all_refs=True" to generate a jsonschema, validation fails because the top-level object has invalid reference url
* mashumaro version: latest
* Python version: 3.10
* Operating System: MacOS

### Description

I have the conversion from our old jsonschema generation app (hologram) to mashumaro working okay without the "all_refs" parameter turned on, but that makes the generated jsonschema very large. When I turn on "all_refs", it generates a much smaller jsonschema, but validation fails because the top-level object is a ref.

### What I Did

If you look at https://github.com/dbt-labs/dbt-core/pull/8132/, the schemas/dbt/manifest/v11.json file was generated from mashumaro (it's big and might not load in the browser). The previous generated file was schemas/dbt/manifest/v10.json, for comparison purposes.

When I modify core/dbt/dataclass_schemas.py, dbtClassMixin.json_schema to use "all_refs=True" to the "build_json_schema" call, the generated schema (added to the schemas directory by `scripts/collect-artifact-schema.py --path schemas --artifact manifest`) fails the schema tests (tests/functional/artifacts) with the error message: jsonschema.exceptions.RefResolutionError: Unresolvable JSON pointer: 'defs/WritableManifest'

The WritableManifest is the top-level object that I am creating the jsonschema for, so my guess is that the base object cannot be a ref, but this is not my area of expertise. Let me know if I should try to create a test case.


Discussion:

Patch:
diff --git a/README.md b/README.md
index ecc77a8..ac230a4 100644
--- a/README.md
+++ b/README.md
@@ -2519,7 +2519,7 @@ print(build_json_schema(List[User], all_refs=True).to_json())
         }
     },
     "items": {
-        "$ref": "#/defs/User"
+        "$ref": "#/$defs/User"
     }
 }
 ```
diff --git a/mashumaro/jsonschema/dialects.py b/mashumaro/jsonschema/dialects.py
index da67639..c535f91 100644
--- a/mashumaro/jsonschema/dialects.py
+++ b/mashumaro/jsonschema/dialects.py
@@ -11,7 +11,7 @@ class JSONSchemaDialect:
 @dataclass(frozen=True)
 class JSONSchemaDraft202012Dialect(JSONSchemaDialect):
     uri: str = "https://json-schema.org/draft/2020-12/schema"
-    definitions_root_pointer: str = "#/defs"
+    definitions_root_pointer: str = "#/$defs"
     all_refs: bool = False
 
 


Test patch:
diff --git a/tests/test_jsonschema/test_jsonschema_builder.py b/tests/test_jsonschema/test_jsonschema_builder.py
index 3564d87..4e93b30 100644
--- a/tests/test_jsonschema/test_jsonschema_builder.py
+++ b/tests/test_jsonschema/test_jsonschema_builder.py
@@ -65,8 +65,8 @@ def test_jsonschema_builder_draft_2020_12():
 
 def test_jsonschema_builder_draft_2020_12_with_refs():
     builder = JSONSchemaBuilder(dialect=DRAFT_2020_12, all_refs=True)
-    assert builder.build(A).to_dict() == {"$ref": "#/defs/A"}
-    assert builder.build(B).to_dict() == {"$ref": "#/defs/B"}
+    assert builder.build(A).to_dict() == {"$ref": "#/$defs/A"}
+    assert builder.build(B).to_dict() == {"$ref": "#/$defs/B"}
     assert builder.get_definitions().to_dict() == {
         "A": {
             "type": "object",
diff --git a/tests/test_jsonschema/test_jsonschema_generation.py b/tests/test_jsonschema/test_jsonschema_generation.py
index c26276c..f8d84fd 100644
--- a/tests/test_jsonschema/test_jsonschema_generation.py
+++ b/tests/test_jsonschema/test_jsonschema_generation.py
@@ -156,7 +156,7 @@ def test_jsonschema_for_dataclass():
     )
     assert build_json_schema(DataClass) == schema
     assert build_json_schema(DataClass, all_refs=True) == JSONSchema(
-        reference="#/defs/DataClass", definitions={"DataClass": schema}
+        reference="#/$defs/DataClass", definitions={"DataClass": schema}
     )