Skip to content

Commit eea4670

Browse files
authored
chore(doc): Fix json schema generation after pydantic v2 move (#14926)
1 parent 2d7c009 commit eea4670

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

docs-website/genJsonSchema/gen_json_schema.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def get_base() -> Any:
1111
"id": "https://json.schemastore.org/datahub-ingestion",
1212
"title": "Datahub Ingestion",
1313
"description": "Root schema of Datahub Ingestion",
14-
"definitions": {
14+
"$defs": {
1515
"console_sink": {
1616
"type": "object",
1717
"properties": {
@@ -26,7 +26,7 @@ def get_base() -> Any:
2626
"type": "object",
2727
"properties": {
2828
"type": {"type": "string", "enum": ["file"]},
29-
"config": {"$ref": "#/definitions/file_sink_config"},
29+
"config": {"$ref": "#/$defs/file_sink_config"},
3030
},
3131
"required": ["type", "config"],
3232
},
@@ -45,7 +45,7 @@ def get_base() -> Any:
4545
"type": "object",
4646
"properties": {
4747
"type": {"type": "string", "enum": ["datahub-rest"]},
48-
"config": {"$ref": "#/definitions/datahub_rest_sink_config"},
48+
"config": {"$ref": "#/$defs/datahub_rest_sink_config"},
4949
},
5050
"required": ["type", "config"],
5151
"additionalProperties": False,
@@ -102,7 +102,7 @@ def get_base() -> Any:
102102
"type": "object",
103103
"properties": {
104104
"type": {"type": "string", "enum": ["datahub-kafka"]},
105-
"config": {"$ref": "#/definitions/datahub_kafka_sink_config"},
105+
"config": {"$ref": "#/$defs/datahub_kafka_sink_config"},
106106
},
107107
"required": ["type", "config"],
108108
"additionalProperties": False,
@@ -178,10 +178,10 @@ def get_base() -> Any:
178178
"sink": {
179179
"description": "sink",
180180
"anyOf": [
181-
{"$ref": "#/definitions/datahub_kafka_sink"},
182-
{"$ref": "#/definitions/datahub_rest_sink"},
183-
{"$ref": "#/definitions/console_sink"},
184-
{"$ref": "#/definitions/file_sink"},
181+
{"$ref": "#/$defs/datahub_kafka_sink"},
182+
{"$ref": "#/$defs/datahub_rest_sink"},
183+
{"$ref": "#/$defs/console_sink"},
184+
{"$ref": "#/$defs/file_sink"},
185185
],
186186
},
187187
},
@@ -216,22 +216,22 @@ def get_base() -> Any:
216216
"type": "object",
217217
"properties": {
218218
"type": {"type": "string", "enum": [f"{config_name}"]},
219-
"config": {"$ref": f"#/definitions/{config_name}_config"},
219+
"config": {"$ref": f"#/$defs/{config_name}_config"},
220220
},
221221
"required": ["type", "config"],
222222
}
223223
configs[f"{config_name}"] = source_obj
224-
if "definitions" in data:
225-
definitions.update(data["definitions"])
226-
data.pop("definitions", None)
224+
if "$defs" in data:
225+
definitions.update(data["$defs"])
226+
data.pop("$defs", None)
227227

228228
configs[f"{config_name}_config"] = data
229-
ref = {"$ref": f"#/definitions/{config_name}"}
229+
ref = {"$ref": f"#/$defs/{config_name}"}
230230
refs.append(ref)
231231

232232
base = get_base()
233-
base["definitions"].update(configs)
234-
base["definitions"].update(definitions)
233+
base["$defs"].update(configs)
234+
base["$defs"].update(definitions)
235235

236236
print(base["properties"]["source"])
237237

metadata-ingestion/scripts/docgen.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@ def create_plugin_from_capability_data(
243243
if hasattr(source_type, "get_config_class"):
244244
source_config_class: ConfigModel = source_type.get_config_class()
245245

246-
plugin.config_json_schema = source_config_class.schema_json(indent=2)
246+
plugin.config_json_schema = json.dumps(
247+
source_config_class.model_json_schema(), indent=2
248+
)
247249
plugin.config_md = gen_md_table_from_pydantic(
248250
source_config_class, current_source=plugin_name
249251
)

0 commit comments

Comments
 (0)