nutritious-telephone-58961
11/01/2024, 12:01 PMOptional
fields, they are marked as required in the generated JSON schema. After investigating, I found that in Python, Optional
means a field can be None
or a specified type, but it still requires a value when creating the class. Therefore, the generated JSON schema will mark them as required. Since determining if a field is required is crucial for checking if they are in superset relationships, would it be reasonable to require a default value for Optional
fields while using the superset match? Or maybe there are any better solutions?
cc @damp-lion-88352 @cool-lifeguard-49380 @thankful-minister-83577 @damp-rain-31363nutritious-telephone-58961
11/01/2024, 12:01 PMnutritious-telephone-58961
11/01/2024, 12:04 PM# upstream
@dataclass
class A:
a: int
# downstream
@dataclass
class A:
a: int
b: Optional[str] = None
damp-lion-88352
11/01/2024, 12:56 PMcool-lifeguard-49380
11/01/2024, 2:21 PMdamp-lion-88352
11/01/2024, 2:28 PMdamp-lion-88352
11/01/2024, 2:28 PMdamp-lion-88352
11/01/2024, 2:28 PMcool-lifeguard-49380
11/01/2024, 2:29 PMdamp-lion-88352
11/08/2024, 3:45 AMdamp-lion-88352
11/08/2024, 3:45 AMdamp-lion-88352
11/08/2024, 3:45 AMnutritious-telephone-58961
11/11/2024, 3:22 AM