1212from typing import Union , Literal
1313from typing_extensions import Self
1414
15- from pydantic import BaseModel , Field , model_validator
15+ from pydantic import BaseModel , Field , model_validator , ConfigDict
1616
1717ConfigSettingValue = Union [int , float , bool , str , None ]
1818
@@ -23,6 +23,9 @@ class ConfigEntryDetails(BaseModel):
2323 for a library, target, or application.
2424 """
2525
26+ # Throw an error during validation if there are extra fields
27+ model_config = ConfigDict (extra = "forbid" )
28+
2629 macro_name : str | None = None
2730 """
2831 Name of the macro that this setting shall generate. If unset, defaults to
@@ -71,6 +74,9 @@ class MemoryBankConfiguration(BaseModel):
7174 This is a "mini" version of MemoryBankDefinition that just allows setting the size and start address.
7275 """
7376
77+ # Throw an error during validation if there are extra fields
78+ model_config = ConfigDict (extra = "forbid" )
79+
7480 start : int | None = None
7581 """
7682 Start address of the memory region.
@@ -88,6 +94,9 @@ class BaseJSONConfig(BaseModel):
8894 as well as each entry in targets.json5.
8995 """
9096
97+ # Throw an error during validation if there are extra fields
98+ model_config = ConfigDict (extra = "forbid" )
99+
91100 config : dict [str , ConfigSettingValue | ConfigEntryDetails ] = Field (default_factory = dict )
92101 """
93102 Configuration items for this library or app. These can be defined directly as "name": default value, or as
@@ -158,6 +167,9 @@ class MbedLibJSON(BaseJSONConfig):
158167 to the Mbed configuration system.
159168 """
160169
170+ # Throw an error during validation if there are extra fields
171+ model_config = ConfigDict (extra = "forbid" )
172+
161173 name : str
162174 """
163175 The name of this library. This is also considered the 'namespace' and will be prepended to all
@@ -196,6 +208,9 @@ class MemoryBankDefinition(BaseModel):
196208 (though this data gets converted from XML to JSON by the cmsis-pack-manager tool)
197209 """
198210
211+ # Throw an error during validation if there are extra fields
212+ model_config = ConfigDict (extra = "forbid" )
213+
199214 default : bool = False
200215 """
201216 Hint from the CMSIS data that this memory region should be used for storing general data/code.
@@ -240,6 +255,9 @@ class TargetJSON(BaseJSONConfig):
240255 Schema for one entry in targets.json5.
241256 """
242257
258+ # Throw an error during validation if there are extra fields
259+ model_config = ConfigDict (extra = "forbid" )
260+
243261 inherits : list [str ] = Field (default_factory = list )
244262 """
245263 Parent target(s) to inherit this target's attributes from.
@@ -563,6 +581,9 @@ class MbedAppJSON(BaseJSONConfig):
563581 Schema for mbed_app.json5 files.
564582 """
565583
584+ # Throw an error during validation if there are extra fields
585+ model_config = ConfigDict (extra = "forbid" )
586+
566587 target_overrides : dict [str , dict [str , ConfigSettingValue | MemoryBankConfiguration ]] = Field (default_factory = dict )
567588 """
568589 List of overrides applied based on target labels. This is similar to the "overrides" section,
0 commit comments