From 1320fcbf0a67d3afa2210b16d5093c915cc33960 Mon Sep 17 00:00:00 2001 From: Alexander Shadchin Date: Thu, 1 Feb 2024 19:50:30 +0300 Subject: [PATCH] Fix #1787 (#1791) --- datamodel_code_generator/parser/jsonschema.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/datamodel_code_generator/parser/jsonschema.py b/datamodel_code_generator/parser/jsonschema.py index 6a20fd01..16b64a40 100644 --- a/datamodel_code_generator/parser/jsonschema.py +++ b/datamodel_code_generator/parser/jsonschema.py @@ -270,6 +270,8 @@ class Config: def __init__(self, **data: Any) -> None: super().__init__(**data) self.extras = {k: v for k, v in data.items() if k not in EXCLUDE_FIELD_KEYS} + if 'const' in data.get(self.__extra_key__, {}): + self.extras['const'] = data[self.__extra_key__]['const'] @cached_property def is_object(self) -> bool: